Fix the intermittent failure of TestRemovePrimaryValidSecondaries #10581
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There were two different causes of the intermittent failure. Both had to do with the expectations of the worker main loop, and things actually happening differently.
Given that all the inputs to the worker were controlled, we should be able to be deterministic.
The first failure case was when passing through the loop we had a success then a failure to write. This would give two waiters. However if we had failure followed by success, there would be only one waiter. This was fixed by the change in logic that says if there was a pevious failure when we get a success, update the wait time to be the poll interval.
The second failure case was during the initialize function call where the call would return before the time.After channel had been signalled. There was the assumption that init wasn't complete until there had been a poll happen, but it was possible to have this return before the updateChan was signalled. This caused the rest of the test to progress before things were ready.
QA steps
Bug reference
https://bugs.launchpad.net/juju/+bug/1802590