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

Hash fields used in task service IDs #3632

Merged
merged 2 commits into from
Dec 8, 2017

Conversation

schmichael
Copy link
Member

Fixes #3620

Previously we concatenated tags into task service IDs. This could break
deregistration of tag names that contained double //s like some Fabio
tags.

This change breaks service ID backward compatibility so on upgrade all
users services and checks will be removed and re-added with new IDs.

This change has the side effect of including all service fields in the
ID's hash, so we no longer have to track PortLabel and AddressMode
changes independently.

@jippi
Copy link
Contributor

jippi commented Dec 8, 2017

What format have they changed from and to?

@@ -1,6 +1,9 @@
## 0.7.1 (Unreleased)

__BACKWARDS INCOMPATIBILITIES:__
* client: The format of service IDs in Consul has changed. If you rely upon
Nomad's service IDs (*not* service names; those are stable), you will need
to update your code. [GH-3632]
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra space after period. We should say that relying on the ID is not advisable as it is liable to change

CHANGELOG.md Outdated
@@ -57,6 +60,7 @@ BUG FIXES:
explicitly [GH-3520]
* cli: Fix passing Consul address via flags [GH-3504]
* cli: Fix panic when running `keyring` commands [GH-3509]
* client: Fix advertising services with complex tags [GH-3632]
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be more specific than complex. It is tags that require URL escaping

// Unknown Nomad managed service; kill
if err := c.client.ServiceDeregister(id); err != nil {
if isOldNomadService(id) {
// Don't hard-fail on old entries. See #3620
Copy link
Contributor

Choose a reason for hiding this comment

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

And this is how cruft is born 😢

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think the optimal solution is soft-failing on all deregistration calls, logging only the first failure per-id, and then logging if it ever succeeds... I guess that would only take a map of IDs to track... should I add that and drop isOldNomadService entirely?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I wasn't asking for an action on this one. I think it is just unfortunate we will have to maintain this behavior for a while!

// Make sure Port and Address are stable since
// PortLabel and AddressMode aren't included in the
// service ID.
if locals.Port == remotes.Port && locals.Address == remotes.Address {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice that it has become simpler 👍

parts[4] = service.Name
copy(parts[5:], service.Tags)
return strings.Join(parts, "-")
h := sha1.New()
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm why not keep the hash as a method on Service and have return nomadTaskPrefix + service.Hash()

Copy link
Member

Choose a reason for hiding this comment

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

+1 on this. No reason to maintain all the old fields in the hash, all we care about is that this creates a unique id for the service.

@schmichael
Copy link
Member Author

What format have they changed from and to?
-- @jippi

The format is intentionally not documented outside of code because it is not something users should have to be aware of or rely on. That being said the old and new formats are here in the code:

https://github.com/hashicorp/nomad/pull/3632/files#diff-8612d5e61f84976db572b3f38eb380c0L1015

Fixes #3620

Previously we concatenated tags into task service IDs. This could break
deregistration of tag names that contained double //s like some Fabio
tags.

This change breaks service ID backward compatibility so on upgrade all
users services and checks will be removed and re-added with new IDs.

This change has the side effect of including all service fields in the
ID's hash, so we no longer have to track PortLabel and AddressMode
changes independently.
@schmichael
Copy link
Member Author

Addressed issues and am merging into the parent branch f-3380-custom-ports, so I don't shoot myself in the foot by rebasing the intermediary branch (again)

@schmichael schmichael merged commit a512a8c into f-3380-custom-ports Dec 8, 2017
@schmichael schmichael deleted the b-3620-consul-tags branch December 8, 2017 19:58
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants