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 Traefik reload if Consul Catalog tags change #2389

Merged
merged 2 commits into from
Nov 13, 2017

Conversation

mmatur
Copy link
Member

@mmatur mmatur commented Nov 10, 2017

What does this PR do?

This PR fix Træfik's reload if Consul Catalog tags change

More

  • Added/updated tests

Fixes #2370

@trondhindenes Could you please try with my experimental image mmatur/traefik:fix-consul-tag-change

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

@mmatur 👍

Two suggestions.

if len(removedServiceKeys) > 0 || len(addedServiceKeys) > 0 {
return true
}
return hasNodeOrTagsChanged(current, previous)
Copy link
Contributor

@nmengin nmengin Nov 10, 2017

Choose a reason for hiding this comment

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

Can be merge in return len(removedServiceKeys) > 0 || len(addedServiceKeys) > 0 || hasNodeOrTagsChanged(current, previous)?


if len(removedServiceKeys) > 0 || len(removedServiceNodeKeys) > 0 || len(addedServiceKeys) > 0 || len(addedServiceNodeKeys) > 0 {
log.WithField("MissingServices", removedServiceKeys).WithField("DiscoveredServices", addedServiceKeys).Debug("Catalog Services change detected.")
if changed {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use directly the method in the if statement?

if hasChanged(current, flashback) {

Copy link
Contributor

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

LGTM 👏

@trondhindenes
Copy link

trondhindenes commented Nov 10, 2017

awesome @mmatur, thanks for looking at this so quickly!

I'm afraid we run Traefik straight on metal and don't have a Consul infra in our containers environment. Any chance you have a built binary for me to test? (I guess I could just extract it from your image, that's probably easier)

EDIT: Hm I guess its a minimal image without a shell in it. Not sure how I could extract the binary then....

@mmatur
Copy link
Member Author

mmatur commented Nov 10, 2017

@trondhindenes you can easily extract binary from the container

docker run -tid --name=traefik-experimental mmatur/traefik:fix-consul-tag-change
docker cp traefik-experimental:/traefik .

@trondhindenes
Copy link

thanks!

@trondhindenes
Copy link

Hm, the web ui is giving me a 404 with this build. Is that intended?

[web]
address = ":8080"

It redirects from root to /dashboard and then I get a 404 from there.

@trondhindenes
Copy link

trondhindenes commented Nov 10, 2017

Looking at live traefik logs while doing a deploy now I notice that Traefik is still not reloading its config when the service is flagged as "in maintenance using the consul maint command. Same as before: The Consul web ui is updated, clearly showing the correct state, but Traefik is not honoring maintenance mode.

Got me thinking, maybe this is the root cause of #2370? That Traefik doesn't watch for maintenance mode changes?

@mmatur
Copy link
Member Author

mmatur commented Nov 10, 2017

For the webui it is because I have not build the webui when I have build my docker image.
Traefik does not watch the maintenance mode. Could you please create an issue to request a feature.

@trondhindenes
Copy link

I'm also still seeing the behavior of Traefik not responding to changes in the service in general. I just tried rebooting a backend. Traefik updated its config when the node left, but not when it came back online (consul web ui shows that the consul db is up to date, and running consul watch -service=myservicename -type=service locally on the traefik node shows everything correct after the backend node has come back online.

@trondhindenes
Copy link

"Traefik does not watch the maintenance mode" - okay that explains a good deal. That should probably go into documentation in a very clear way, as it's a core feature of Consul.

@trondhindenes
Copy link

Which version do you want the debug log from? The one from this custom build? Can do. But in general it doesn't say much, you can just see that it does not reload configuration so it just sits there. But I'm happy to send it over if you confirm the version.

@mmatur
Copy link
Member Author

mmatur commented Nov 13, 2017

@trondhindenes Yes the log from the custom build. To have more verbose logs please add debug = true in your traefik toml configuration

Copy link
Member

@juliens juliens left a comment

Choose a reason for hiding this comment

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

LGTM

@trondhindenes
Copy link

Sure, will do - I'll send those over tomorrow morning. I saw this getting merge and the related issue was closed but just FYI: I'm still having issues with Consul not reloading config on changes. Should we track this in another issue? Tracking stuff in a merged PR seems a bit sub-optimal.

@mmatur
Copy link
Member Author

mmatur commented Nov 14, 2017

@trondhindenes Could you please create a new issue with last configuration and traefik debug log

@thereforsunrise
Copy link

Ah well I am still seeing this issue in 1.5.4 release as well.

@mmatur
Copy link
Member Author

mmatur commented Jun 8, 2018

Hi @zaargy,

Could you have a try with last Træfik version v1.6.3.
And if you encountered an issue could you please open new GitHub Issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants