-
Notifications
You must be signed in to change notification settings - Fork 118
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 agent not restarting when needed #77
Fix agent not restarting when needed #77
Conversation
@edusperoni |
I think reason why service is not restarted - because there is single ID with 2 modules agent/init.sls
agent/conf.sls
Output:
|
@edusperoni can you please be more specific at what circumstances you have problem when agent is not restarted? I have installed bunch of VMs with this formula before your PR and without ID splitting which I described above (which is actually have no effect at all as I found after testing) and I never have issue that I need to restart agent once more after single formula run. But all my VMs are Debian, may be it's something RedHat specific.
but it's running with right config generated from template. Speaking of apache-formula, as I can see they using module states because they want both restart and reload and this two 'hooks' possibly best way to achieve this. |
All my machines are also Debian. I'll spin one up tomorrow at work and post the results. The ID splitting is probably a better solution to this. Try purging the zabbix agent and running it. When you install the package, it already starts and enables the daemon with the base configuration. Salt then edits the config and updates the file. When checking the service state, salt says the service is already running and enabled and doesn't restart the service. Any change after the first one triggers the restart. I found myself actually having to call |
That is exactly how I'm running test. I'm testing on Debian 9,
Unfortunately I misled you, according to my new tests ID splitting have no effect. My agent is always restarted, and my server is always |
I'm using version_repo 3.4 Also, are you absolutely sure it's running with the correct config? The default config is enough to get the agent running and answering requests, but if you add, say a custom parameter or set the Server directive to any server other than the Zabbix Server, it should throw an error when querying the agent. |
I'm sure agent running correct config, by default Server parameter is 127.0.0.1 and there is on server at 127.0.0.1 which agent can connect.
As you can see agent successfully restated with correct config.
But I'm started to use this formula when I was at salt 2016.11 and also have no issues with restart. |
Here's my test:
And this is the agent log:
And the versions:
top file:
agent log after a manual restart:
That last error is correct, since the agent will auto register based on hostmetada. |
That's odd... Also you don't need
is enough, although I tested with |
Regular salt, here's the show_highstate:
|
Why there is nothing like:
Which actually have
requisite. |
That's actually my bad. I accidentally left it out:
|
I can't see any problem here, but there is must be a reason. I have no problems with restart, I think all other people who use this formula are not have this problem too, otherwise the problem would have been noticed long ago. |
@edusperoni hi again, can you please test this update https://github.com/hatifnatt/zabbix-formula/tree/separate_id_for_service in your environment? There is separate id for service.running state and some other changes. |
Well, this is weird, It's working on my test machine even without separate IDs. I've since upgraded to 2018.3, but when I had this problem for a while, probably since at least 2017.7, and it was only with this formula. When I opened this request, I was at 2017.7.4. I couldn't find anything on the changelogs regarding the service. I'll try running the formula on another machine to confirm. |
spoke too son, it failed on the other machine |
Thanks for information! I'm (unfortunately =) ) still on 2017.7.4 and as a mentioned before, I never have this issue with or without separate ID's. May be now when you have machine where formula not fully functional and where it's running fine you can find the cause? |
Ok, this may be a bug with salt. Please try this: Run the formula/install zabbix agent Does the service restart? If I just purge the agent without disabling it, it restarts normally, but if I disable it first (and on first install), it doesn't restart on it's own |
Yes I can confirm, if service disabled before purge, and then installed again via formula, restart is not preformed. Fortunately I have clean machine where zabbix-agent have never installed. So I also can confirm that on first install service is not restarted. All my previous test done on machines where zabbix-agent have been already installed before and then removed without disabling. Thank you for your time! I think this problem can be considered as bug in Salt but I never faced with it before. |
After further investigation, zabbix does not enable it's services, but starts them. That's what's causing this issue. I've opened an Issue in the salt repo |
This breaks if Salt is using the new module.run syntax instead of the deprecated version. Edit: |
On the first run, when the service is already started by the package installation, the formula fails to restart the agent saying that agent is already running and enabled.
This approach is similar to what apache-formula uses and it forces the agent to be restarted whenever the config changes.
https://github.com/saltstack-formulas/apache-formula/blob/master/apache/init.sls#L38