-
Notifications
You must be signed in to change notification settings - Fork 42
Signal failure status from fsck in headless mode #878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,11 +80,17 @@ func main() { | |
| } | ||
| f := fsck.New(*origin, v, src, defaultMerkleLeafHasher, fsck.Opts{N: *N}) | ||
|
|
||
| checkErr := make(chan error, 1) | ||
| go func() { | ||
| if err := f.Check(ctx); err != nil { | ||
| err := f.Check(ctx) | ||
|
|
||
| // Only log the error if we're using the TUI, otherwise it will be double logged in headless mode. | ||
| if err != nil && *ui { | ||
| klog.Errorf("fsck failed: %v", err) | ||
| } | ||
| klog.V(1).Infof("Completed ranges:\n%s", f.Status()) | ||
|
|
||
| checkErr <- err | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: strictly, you should probably close(checkErr) here. |
||
| cancel() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this |
||
| }() | ||
|
|
||
|
|
@@ -97,7 +103,10 @@ func main() { | |
| } else { | ||
| for { | ||
| select { | ||
| case <-ctx.Done(): | ||
| case err := <-checkErr: | ||
| if err != nil { | ||
| klog.Exitf("fsck failed: %v", err) | ||
| } | ||
| return | ||
| case <-time.After(time.Second): | ||
| klog.V(1).Infof("Ranges:\n%s", f.Status()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename this
checkResult? I spend some time trying to reason about the replacement ofctx.Donewith<-checkErrin the loop below before I noticed that you just send whatevererris, even if it'snil.Probably worth a comment to that effect on this channel, too as it's a little unusual.