-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[hostcfgd] Enable/disable the container service only when the feature state was changed. #5689
Conversation
the 'AutoRestart' field of swss/snmp container, snmp container will be stopped and started. Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR title is a bit lengthy yet does not accurately describe the change being made. It instead describes one side effect of the change. The title, which will subsequently become the commit message, should summarize the actual change being made. "[hostcfgd] Fix the SNMP container stopped and started if 'AutoRestart' state of snmp/swss was changed" does not summarize the change; SNMP/SwSS should not be mentioned in the title -- it can be mentioned in the description. The actual change here is to invoke systemd commands only if the feature state has changed from its previous state, and not if other data in the FEATURE table has changed. Please try to condense what I wrote above down into a succinct and brief title.
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
retest vsimage please |
… state was changed. (#5689) **- Why I did it** If we ran the CLI commands `sudo config feature autorestart snmp disabled/enabled` or `sudo config feature autorestart swss disabled/enabled`, then SNMP container will be stopped and started. This behavior was not expected since we updated the `auto_restart` field not update `state` field in `FEATURE` table. The reason behind this issue is that either `state` field or `auto_restart` field was updated, the function `update_feature_state(...)` will be invoked which then starts snmp.timer service. The snmp.timer service will first stop snmp.service and later start snmp.service. In order to solve this issue, the function `update_feature_state(...)` will be only invoked if `state` field in `FEATURE` table was updated. **- How I did it** When the demon `hostcfgd` was activated, all the values of `state` field in `FEATURE` table of each container will be cached. Each time the function `feature_state_handler(...)` is invoked, it will determine whether the `state` field of a container was changed or not. If it was changed, function `update_feature_state(...)` will be invoked and the cached value will also be updated. Otherwise, nothing will be done. **- How to verify it** We can run the CLI commands `sudo config feature autorestart snmp disabled/enabled` or `sudo config feature autorestart swss disabled/enabled` to check whether SNMP container is stopped and started. We also can run the CLI commands `sudo config feature state snmp disabled/enabled` or `sudo config feature state swss disabled/enabled` to check whether the container is stopped and restarted. Signed-off-by: Yong Zhao <yozhao@microsoft.com>
… state was changed. (sonic-net#5689) **- Why I did it** If we ran the CLI commands `sudo config feature autorestart snmp disabled/enabled` or `sudo config feature autorestart swss disabled/enabled`, then SNMP container will be stopped and started. This behavior was not expected since we updated the `auto_restart` field not update `state` field in `FEATURE` table. The reason behind this issue is that either `state` field or `auto_restart` field was updated, the function `update_feature_state(...)` will be invoked which then starts snmp.timer service. The snmp.timer service will first stop snmp.service and later start snmp.service. In order to solve this issue, the function `update_feature_state(...)` will be only invoked if `state` field in `FEATURE` table was updated. **- How I did it** When the demon `hostcfgd` was activated, all the values of `state` field in `FEATURE` table of each container will be cached. Each time the function `feature_state_handler(...)` is invoked, it will determine whether the `state` field of a container was changed or not. If it was changed, function `update_feature_state(...)` will be invoked and the cached value will also be updated. Otherwise, nothing will be done. **- How to verify it** We can run the CLI commands `sudo config feature autorestart snmp disabled/enabled` or `sudo config feature autorestart swss disabled/enabled` to check whether SNMP container is stopped and started. We also can run the CLI commands `sudo config feature state snmp disabled/enabled` or `sudo config feature state swss disabled/enabled` to check whether the container is stopped and restarted. Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Signed-off-by: Yong Zhao yozhao@microsoft.com
- Why I did it
If we ran the CLI commands
sudo config feature autorestart snmp disabled/enabled
orsudo config feature autorestart swss disabled/enabled
, then SNMP container will be stopped and started. This behavior was not expected since we updated theauto_restart
field not updatestate
field inFEATURE
table. The reason behind this issue is that eitherstate
field orauto_restart
field was updated, the functionupdate_feature_state(...)
will be invoked which then starts snmp.timer service.The snmp.timer service will first stop snmp.service and later start snmp.service.
In order to solve this issue, the function
update_feature_state(...)
will be only invoked ifstate
field inFEATURE
table wasupdated.
- How I did it
When the demon
hostcfgd
was activated, all the values ofstate
field inFEATURE
table of each container will becached. Each time the function
feature_state_handler(...)
is invoked, it will determine whether thestate
field of acontainer was changed or not. If it was changed, function
update_feature_state(...)
will be invoked and the cachedvalue will also be updated. Otherwise, nothing will be done.
- How to verify it
We can run the CLI commands
sudo config feature autorestart snmp disabled/enabled
orsudo config feature autorestart swss disabled/enabled
to check whether SNMP container is stopped and started. We also can run the CLI commandssudo config feature state snmp disabled/enabled
orsudo config feature state swss disabled/enabled
to check whether the container is stopped and restarted.- Which release branch to backport (provide reason below if selected)
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)