Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Enable tag drift 03 #1187

Merged
merged 13 commits into from
Sep 11, 2015
Merged

Enable tag drift 03 #1187

merged 13 commits into from
Sep 11, 2015

Conversation

sfncook
Copy link

@sfncook sfncook commented Aug 20, 2015

This is just another attempt to add the 'tag drift' feature in. Issue #1102 Originally I had this config item for the entire Consul agent. This iteration makes it a service-level config so individual services can be configured to allow tag drift.

"tag drift" = Disabling the anti-entropy sync agent behavior so that external agents can modify a service's tags. Useful for interactions like Redis and Redis Sentinel.

@sfncook
Copy link
Author

sfncook commented Aug 20, 2015

Travis tests failing. Investigating now.

@@ -379,6 +379,12 @@ func (l *localState) setSyncState() error {
}

// If our definition is different, we need to update it
if existing.EnableTagDrift {
l.logger.Printf("[DEBUG] Tag drift enabled.")
existing.Tags = service.Tags
Copy link
Contributor

Choose a reason for hiding this comment

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

At first I was a little weirded out that the local service is changing right here, but you have the lock and I'm not sure doing it elsewhere would be any cleaner. This looks ok.

Copy link
Member

Choose a reason for hiding this comment

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

This does seem a bit odd though. I think it might be better to have an equality checker function rather than leaning on reflect.DeepEqual here. The current logic will also become problematic when switching to an in-memory state store (which is on our short-term roadmap), since the service is a pointer and you are actually swapping out part of the data here. Having an equality check function would also make this easier to test.

Copy link
Author

Choose a reason for hiding this comment

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

@ryanuber That makes sense, but I believe it's a little out of scope for this particular pull request. I would be happy to contribute independent of this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ryanuber don't we require that the local data changes to match the server if drift is enabled so that we don't sync back to the old tags if the service definition changes for some other reason? Also, this is the localState which just has maps vs. memdb. Want to make sure I understand your concern before we pull the trigger on this one.

Copy link
Member

Choose a reason for hiding this comment

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

@slackpad if we are doing a DeepEqual, then you are right, the definitions have to be perfectly equivalent. What I was suggesting was having like a ServiceEquals(s1, s2 *structs.NodeService, drift bool) bool kind of function, which would just skip the tag check if drift is enabled.

You're right about the local state, my bad.

One other thing though - If we are modifying the local agent state then we aren't enabling drift, we are instead flipping it so that the remote state always wins, unless I'm missing something else here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ryanuber I don't think I explained myself very well re-reading what I wrote :-)

I was thinking that it's important we do the copy here because if DeepEqual detects a change after that (a real change we want to sync), we want the tags from the server going back up to the catalog, not the local ones as if we had the compare function. I think if we didn't copy then we'd revert the drifted tags once the service changes for any other reason.

@slackpad
Copy link
Contributor

@sfncook the basic logic looks ok to me - can you please add a unit test that exercises the new functionality?

@sfncook
Copy link
Author

sfncook commented Sep 10, 2015

@slackpad @ryanuber - Thanks for the review, guys.

@slackpad - I have added a couple test cases in TestAgentAntiEntropy_EnableTagDrift. But perhaps you can see in this conversation that the Travis failing with errors that don't appear to be related to my updates. I'm not sure why they are failing - they seems to be complaining that an interface is being used. (in code that I did not modify) Perhaps you guys have seen these errors before? Known issue?

Travis errors:
command/maint_test.go:48: not enough arguments in call to a1.agent.EnableServiceMaintenance
command/maint_test.go:53: not enough arguments in call to a1.agent.EnableNodeMaintenance

@slackpad
Copy link
Contributor

@sfncook can you please update the docs along with this change?

@@ -379,6 +379,12 @@ func (l *localState) setSyncState() error {
}

// If our definition is different, we need to update it
if existing.EnableTagDrift {
l.logger.Printf("[DEBUG] Tag drift enabled.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should blow away these debug prints.

@slackpad
Copy link
Contributor

@sfncook - looking good! I noted a few small things but I think this is almost ready to go.

@sfncook
Copy link
Author

sfncook commented Sep 11, 2015

@slackpad - Thanks so much for the thoughtful and thorough review! I will make these updates tomorrow.

@sfncook
Copy link
Author

sfncook commented Sep 11, 2015

@slackpad I just pushed updates in response to your comments. (thank again) Note that the title of this pull request and branch still refer to the old config item name "EnableTagDrift", though the code has been updated per your request.

@sfncook
Copy link
Author

sfncook commented Sep 11, 2015

Hang on just another day. I'd like to add a reference to the anti-entropy.html page in the docs.

@sfncook
Copy link
Author

sfncook commented Sep 11, 2015

Okay, all done.

@@ -73,6 +74,25 @@ from `1`.

Note: there is more information about [checks here](/docs/agent/checks.html).

The `enableTagOverride` can optionally specified to disable the antientropy feature for
Copy link
Contributor

Choose a reason for hiding this comment

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

can optionally be specified
anti-entropy

@slackpad
Copy link
Contributor

Super tiny nits in the doc and then I think we can :shipit:.

@sfncook
Copy link
Author

sfncook commented Sep 11, 2015

@slackpad Awesome, just pushed those changes. Thanks.

@slackpad
Copy link
Contributor

Sweet - thanks for putting this together! It'll go out with Consul 0.6.

slackpad added a commit that referenced this pull request Sep 11, 2015
@slackpad slackpad merged commit 2f9ebdb into hashicorp:master Sep 11, 2015
@sfncook
Copy link
Author

sfncook commented Sep 11, 2015

Woo! Thanks for the feedback. What's a general ETA on 0.6?

@slackpad
Copy link
Contributor

np - It's hard to say right now but we are pushing for this month.

@sfncook
Copy link
Author

sfncook commented Sep 11, 2015

Perfect

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.

3 participants