Skip to content

agent: return error when failing to apply network key#2593

Merged
dperny merged 1 commit into
moby:masterfrom
stevvooe:return-error-failed-network-key
Aug 1, 2018
Merged

agent: return error when failing to apply network key#2593
dperny merged 1 commit into
moby:masterfrom
stevvooe:return-error-failed-network-key

Conversation

@stevvooe
Copy link
Copy Markdown
Contributor

@stevvooe stevvooe commented Apr 4, 2018

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

Closes #2592

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

codecov Bot commented Apr 5, 2018

Codecov Report

Merging #2593 into master will increase coverage by 0.5%.
The diff coverage is 0%.

@@            Coverage Diff            @@
##           master    #2593     +/-   ##
=========================================
+ Coverage   61.51%   62.01%   +0.5%     
=========================================
  Files         134      134             
  Lines       21761    21761             
=========================================
+ Hits        13386    13495    +109     
+ Misses       6933     6815    -118     
- Partials     1442     1451      +9

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 to return an error rather than a panic.

Comment thread agent/agent.go
a.keys = message.NetworkBootstrapKeys
if err := a.config.Executor.SetNetworkBootstrapKeys(a.keys); err != nil {
panic(fmt.Errorf("configuring network key failed"))
return errors.Wrap(err, "configuring network key failed")
Copy link
Copy Markdown
Contributor

@cyli cyli Apr 10, 2018

Choose a reason for hiding this comment

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

Unrelated to this fix, but this logic seems a little odd:

	for _, key := range message.NetworkBootstrapKeys {
		same := false
		for _, agentKey := range a.keys {
			if agentKey.LamportTime == key.LamportTime {
				same = true
			}
		}
		if !same {
			a.keys = message.NetworkBootstrapKeys
			if err := a.config.Executor.SetNetworkBootstrapKeys(a.keys); err != nil {
				return errors.Wrap(err, "configuring network key failed")
			}
		}
	}

It looks like we are looping over each bootstrap key, and for each key that is different, we set the agent keys to the bootstrap keys - so if multiple keys are different, we'd set the same set of keys multiple times.

This seems like an idempotent action, so it's probably not an issue, but it does give the executor more changes to fail.

Happy to change this in a different PR, though.

Copy link
Copy Markdown
Contributor

@cyli cyli Apr 10, 2018

Choose a reason for hiding this comment

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

Is setting the network bootstrap keys an expensive or prone-to-failure operation? Can we just set it every time without checking for whether it's different or the same? cc @abhi

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.

From slack conversation - we're not sure whether it's expensive.

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

ping @dperny @anshulpundir PTAL (should be an easy merge)

@dperny
Copy link
Copy Markdown
Collaborator

dperny commented Aug 1, 2018

LGTM. the end result of this is just that instead of panicking, an error will be logged.

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.

4 participants