mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Retry service updates on out of sequence errors
Code retrying service update operations when receiving "update out of sequence" errors was removed because of a misunderstanding, which has made tests flaky. This re-adds the "CmdRetryOutOfSequence" method, and uses it in TestSwarmPublishAdd to avoid flaky behavior. Signed-off-by: Drew Erny <drew.erny@docker.com>
This commit is contained in:
@@ -189,3 +189,25 @@ func (d *Daemon) CheckLeader(c *check.C) (interface{}, check.CommentInterface) {
|
||||
}
|
||||
return fmt.Errorf("no leader"), check.Commentf("could not find leader")
|
||||
}
|
||||
|
||||
// CmdRetryOutOfSequence tries the specified command against the current daemon
|
||||
// up to 10 times, retrying if it encounters an "update out of sequence" error.
|
||||
func (d *Daemon) CmdRetryOutOfSequence(args ...string) (string, error) {
|
||||
var (
|
||||
output string
|
||||
err error
|
||||
)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
output, err = d.Cmd(args...)
|
||||
// error, no error, whatever. if we don't have "update out of
|
||||
// sequence", we don't retry, we just return.
|
||||
if !strings.Contains(output, "update out of sequence") {
|
||||
return output, err
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise, once all of our attempts have been exhausted, just return
|
||||
// whatever the last values were.
|
||||
return output, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user