-
Notifications
You must be signed in to change notification settings - Fork 204
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
Fix: asoctl deadlock #4475
Fix: asoctl deadlock #4475
Conversation
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.
Partial review, I should keep packing rather than getting sidetracked by fun concurrency fixes! Looks good so far though!
case rsrc, ok := <-resources: | ||
if !ok { | ||
// Channel closed | ||
running = false |
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.
It'd be clearer to label the for loop and use a labelled break here (assuming I haven't missed some other stuff that needs to happen after the select).
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.
Done.
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.
Minor comments. Just double checking on a few things, feel free to ignore if you think the comments are irrelevant.
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.
Looks nice!
} | ||
|
||
// Close the channel when we're done, so that workers shut down too | ||
close(uniqueResources) |
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.
Defer this at the top of the goroutine func to ensure it's closed even in the case of panics?
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.
Done.
ri.reporter.Completed(1) | ||
watchdog.stopped() |
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.
I'd put these into a method on ResourceImporter and then call it from both the success and error workers. Tying them together makes it harder to forget to do it in one place.
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.
Done.
What this PR does
Fixes an ASO deadlock introduced in #4452.
The immediate cause of the deadlock was an omitted call to
Completed(1)
when collating import errors, leaving the progress bar incomplete.However, this coupling between the progress bar and the importer isn't ideal, and leaves the door open for addition problems in the future. To avoid this, I've made two additional changes.
watchdog
to keep track of inflight resources, to monitor the import, and to shut things down when everything is done