Conversation
The retry loop added in cosmos#21487 to wait for a partially written upgrade-info.json breaks out as soon as the file is *still* empty and keeps polling once it has content, which is the opposite of the intent. Break once the size is non-zero.
Contributor
|
PR author is not in the allowed authors list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
fileWatcher.CheckUpdatehandles the case whereupgrade-info.jsonhas been created but not yet written (#21086) by polling up to 10 × 2 ms for the write to land. The loop's exit condition is inverted:It breaks out as soon as the file is still empty, so the "wait for the write" path is effectively a single 2 ms retry, and a write that lands 3–20 ms later is missed until the next ticker interval. In the common case that only delays the upgrade by one poll interval; on a slow disk / loaded host the daemon can be killed on the next tick anyway, so this mostly matters for the guarantee the retry loop was meant to provide.
Changes
TestCheckUpdateWaitsForEmptyFileWrite: starts from an empty file, writes the plan 5 ms later from another goroutine, and assertsCheckUpdatepicks it up. Fails onmain(Should be true), passes with the fix.