Skip to content

agent: backoff session when no remotes are available#2570

Merged
anshulpundir merged 1 commit into
moby:masterfrom
stevvooe:backoff-on-error
Mar 26, 2018
Merged

agent: backoff session when no remotes are available#2570
anshulpundir merged 1 commit into
moby:masterfrom
stevvooe:backoff-on-error

Conversation

@stevvooe
Copy link
Copy Markdown
Contributor

Signed-off-by: Stephen J Day stephen.day@docker.com

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 😄

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2018

Codecov Report

Merging #2570 into master will decrease coverage by 0.02%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master    #2570      +/-   ##
==========================================
- Coverage    61.4%   61.38%   -0.03%     
==========================================
  Files         134      134              
  Lines       21800    21803       +3     
==========================================
- Hits        13387    13384       -3     
- Misses       6968     6976       +8     
+ Partials     1445     1443       -2

Comment thread agent/session.go Outdated
// since we are returning without launching the session goroutine, we
// need to provide the delay that is guaranteed by calling this
// function.
time.Sleep(delay)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@cyli cyli Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would this possibly block here: https://github.com/docker/swarmkit/blob/master/agent/agent.go#L367, thus preventing any other events, such as shutdown or node update, etc. from happening, for up to 8 seconds every time?

Not sure if it would make sense instead to do the sleep/write the error to the channel in a goroutine instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this probably isn't a great fix. For this to be correct, we need a goroutine. Good catch!

Signed-off-by: Stephen J Day <stephen.day@docker.com>
@stevvooe
Copy link
Copy Markdown
Contributor Author

@anshulpundir @cyli Give that a look! It should now delay the send on the error channel to simulate that the delay from (*session).run.

Copy link
Copy Markdown
Contributor

@cyli cyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this @stevvooe!

Comment thread agent/session.go
// avoid blocking the main loop.
go func() {
time.Sleep(delay)
s.errs <- err
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, what happens if the context gets done in the mean time ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I guess this wouldn't have a listener anymore. Wondering if we should call s.sendError(err) instead, which selects between writing the error and the session closed channel being closed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing: this is a buffered channel. If someone is listening, they pick it up. If no one is listening, it goes into the buffer immediately and the channel then gets garbage collected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants