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

service definition file will be changed frequently #45

Closed
hco opened this issue Nov 11, 2014 · 16 comments
Closed

service definition file will be changed frequently #45

hco opened this issue Nov 11, 2014 · 16 comments

Comments

@hco
Copy link

hco commented Nov 11, 2014

Hi,

for some reason my service defintion files will be changed every few runs, even though nothing changes.

The following file sometimes looks like this:

{
  "service": {
    "port": 80,
    "name": "clientinterface",
    "id": "clientinterface",
    "tags": [

    ]
  }
}

and sometimes like this:

{
  "service": {
    "tags": [

    ],
    "port": 80,
    "name": "clientinterface",
    "id": "clientinterface"
  }
}

This will result in consul restarting every few runs :-(

@solarkennedy
Copy link
Contributor

That's kinda strange, we do hash sort on purpose so this Doesn't happen.

What is your puppet master situation, do you just have one, or multiple? And are they running the same version of ruby and everything?

@hco
Copy link
Author

hco commented Nov 11, 2014

Only one puppet master :-( Version 3.6.2

@EvanKrall
Copy link
Contributor

@solarkennedy Looks like the code is only sorting the first level in the hash?

@solarkennedy
Copy link
Contributor

Maybe we could do something like this?
https://gist.github.com/jaredcurtis/1895347

@hco
Copy link
Author

hco commented Nov 13, 2014

I would be willing to beta-test this. I'm out of office until monday, so it might be delayed until then :-)

Could you provide me with a patch, or do you want me to try implementing it on my own?

@solarkennedy
Copy link
Contributor

Its ok to be delayed. We've been ok this far.
Yes, please feel free to look at that gist and try to implements the necessary sorting and PR.

@jsok
Copy link
Contributor

jsok commented Nov 17, 2014

+1 for this issue. I'm still running Puppet 2.7 and Ruby 1.8.7 so Hash order is no longer guaranteed. This means consul gets restarted unnecessarily quite often.

I've got a working solution to this problem which is to exec a consul reload on any config file change... seems to play a bit nicer and reload is much lighter weight than a full restart.

@jsok jsok mentioned this issue Nov 17, 2014
@jsok
Copy link
Contributor

jsok commented Nov 17, 2014

Another alternative to the above gist is a custom function, see https://gist.github.com/falzm/8575549

@solarkennedy
Copy link
Contributor

If this can be done in erb, I would prefer it over the custom function.

@KrisBuytaert
Copy link

On a Puppet 3.7.2 and ruby 1.8.7 stack this is standard behaviour thus this is not idempodent :( And causes frequent restarts hence instabilities in the stack .

Another approach could be https://gist.github.com/halkeye/2287885

@solarkennedy
Copy link
Contributor

Ah! That is the one! I totally have used that one before. Please PR me or I'll do it myself eventually.
@hco how do you feel about doing it since you opened the issue?

@hco
Copy link
Author

hco commented Dec 12, 2014

@solarkennedy I just checked - their does not seem to be a license associated with it. Is that a problem for you?

@solarkennedy
Copy link
Contributor

@hco I've noted that you have asked on
https://gist.github.com/falzm/8575549

For now just take it an we'll do something different if it is not compatible.

@gozer
Copy link
Contributor

gozer commented Dec 16, 2014

I am seeing the exact same problem with the generated /etc/consul/config.json, and it's causing unnecessary service restarts. Willing guinea pig for patches here as well.

@solarkennedy
Copy link
Contributor

I've pushed a change to master that includes the recursive sorted json function to create the service file.

Try now.

@solarkennedy
Copy link
Contributor

@gozer I've also pushed b05ce2e which has the same treatment on config.json which should solve your problem. Try master.

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

No branches or pull requests

6 participants