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

Fix old services not getting removed from consul on update #1668

Merged
merged 7 commits into from
Sep 1, 2016

Conversation

schmichael
Copy link
Member

Fixes #1661

I'm not terribly happy with the thoroughness of my tests, so feel free to suggest improvements there.

Also includes a tiny unrelated change I made while meandering through the code base:

  • Remove unused embedded lock on ExecContext 53d7dfb

@@ -174,6 +174,8 @@ func NewSyncer(consulConfig *config.ConsulConfig, shutdownCh chan struct{}, logg
trackedChecks: make(map[consulCheckID]*consul.AgentCheckRegistration),
checkRunners: make(map[consulCheckID]*CheckRunner),
periodicCallbacks: make(map[string]types.PeriodicCallback),
// default noop implementation of addrFinder
addrFinder: func(string) (string, int) { return "", 0 },
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if this is a safe or wise thing to do.

@schmichael schmichael changed the title Fix old services not getting removed from consul on update WIP - Fix old services not getting removed from consul on update Aug 30, 2016
Instead just remove all associated services on shutdown.
@schmichael schmichael changed the title WIP - Fix old services not getting removed from consul on update Fix old services not getting removed from consul on update Aug 31, 2016
}

found := 0
for _, s := range cs.flattenedServices() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use reflect.DeepEquals here to check whether the agentServices are what we expect them to be? The assertion logic would be simpler.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, good call. Right now I'm just asserting the internal syncer state. I'll add comparisons of internal state against queryAgentServices too to make sure everything is consistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sadly queryAgent and fllatenedServices use different types, so I couldn't just DeepEquals.

Added the checks manually because they're important.

@@ -355,7 +376,12 @@ func (c *Syncer) Shutdown() error {
}

// De-register all the services from Consul
for serviceID := range c.trackedServices {
services, err := c.queryAgentServices()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change the comment above:

// De-register all services registered by this syncer from Consul

@dadgar
Copy link
Contributor

dadgar commented Sep 1, 2016

LGTM

@schmichael schmichael merged commit 5f04e2a into master Sep 1, 2016
@schmichael schmichael deleted the b-fix-consul-updates branch September 1, 2016 00:17
schmichael added a commit that referenced this pull request Sep 1, 2016
schmichael added a commit that referenced this pull request Oct 20, 2016
@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 Apr 17, 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

3 participants