Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Dynamically update node inventory #1374

Conversation

nishanttotla
Copy link
Contributor

This PR makes the node inventory dynamic i.e. changes to node info are passed to the dispatcher. A ticker checks the node info periodically (currently every 20 seconds) and closes the session if changes are found, so that a new one can be created with an updated node description, and the same session id.

I'm trying to test this change thoroughly since it can likely cause race conditions in the main agent loop. The update period will likely have to be tuned to make sure that it doesn't interfere with the agent's backoff mechanism.

The underlying assumption is that node updates aren't super frequent.

Follow up to #1174 after it had to be reverted due to unstable behavior. #1230 was meant to fix some of that.

Fix #279

Signed-off-by: Nishant Totla nishanttotla@gmail.com

@codecov-io
Copy link

codecov-io commented Aug 15, 2016

Current coverage is 55.38% (diff: 41.50%)

Merging #1374 into master will increase coverage by 0.15%

@@             master      #1374   diff @@
==========================================
  Files            82         82          
  Lines         12856      12871    +15   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           7101       7129    +28   
+ Misses         4774       4772     -2   
+ Partials        981        970    -11   

Sunburst

Powered by Codecov. Last update c374ccb...26bdb37

@nishanttotla
Copy link
Contributor Author

It looks like docker info is unstable again, despite a previous fix. Investigating that, since it'll need fixing first. Making this PR WIP as a result.

@nishanttotla nishanttotla changed the title Dynamically update node inventory [WIP] Dynamically update node inventory Aug 16, 2016
@nishanttotla nishanttotla self-assigned this Aug 16, 2016
@nishanttotla nishanttotla changed the title [WIP] Dynamically update node inventory Dynamically update node inventory Aug 22, 2016
@nishanttotla
Copy link
Contributor Author

nishanttotla commented Aug 22, 2016

I confirmed that there are no issues on the Docker side as far as this PR is concerned, but it depends on #1426.

I'm currently running some more tests, and would appreciate if someone could also volunteer to test it out on their machine.

The one thing that might need tuning is

nodeUpdatePeriod = 20 * time.Second

Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
@nishanttotla nishanttotla force-pushed the dynamically-update-node-inventory-same-session branch 3 times, most recently from 3f8ae63 to e245073 Compare August 31, 2016 18:58
@nishanttotla
Copy link
Contributor Author

nishanttotla commented Aug 31, 2016

cc @aaronlehmann - I moved the node update code to a separate function, which can be reused both during node registration and update. The relevant changes are in dispatcher.go.

Please let me know if this is the correct way to do it. This PR works with that change.

// updateNode updates the description of a node and sets status to READY
// this is used during registration when a new node description is provided
// and during node updates when the node description changes
func (d *Dispatcher) updateNode(nodeID string, description *api.NodeDescription) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this return value for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, it's not needed. I copied some code from register() that was returning two values and didn't change it.

@nishanttotla nishanttotla force-pushed the dynamically-update-node-inventory-same-session branch from e245073 to 26bdb37 Compare August 31, 2016 20:04
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
@nishanttotla nishanttotla force-pushed the dynamically-update-node-inventory-same-session branch from 26bdb37 to 8fa5bcd Compare August 31, 2016 20:06
@aaronlehmann
Copy link
Collaborator

LGTM

@nishanttotla
Copy link
Contributor Author

In my testing (mostly with changing daemon labels), the behavior is fairly stable, barring the occasional error:

ERRO[0060] agent: updated node description unavailable   agent=&{client:0xc8202ecd20} error=Error response from daemon: Bad response from Docker engine module=node/agent

This is not surprising, since updating restarts the engine, and there's a brief period it's unavailable. It's not a problem though, since we just ignore when that happens and try again later (which is to say nothing bad happens when the engine is unavailable). I'm thinking that we could change the above error message to a warning perhaps if required, or else just keep it the way it is.

@stevvooe
Copy link
Contributor

stevvooe commented Sep 1, 2016

LGTM

@nishanttotla
Copy link
Contributor Author

Ping @docker/core-swarmkit-maintainers it would be great if someone could test this on their machine too. If there are no further concerns, we can merge it.

@ghost
Copy link

ghost commented Sep 6, 2016

@stevvooe You should merge this.

@stevvooe stevvooe merged commit 47e75e7 into moby:master Sep 6, 2016
@nishanttotla nishanttotla deleted the dynamically-update-node-inventory-same-session branch September 6, 2016 22:43
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node inventory: dynamic
5 participants