sonic-net / sonic-buildimage

Scripts which perform an installable binary image build for SONiC
Other
734 stars 1.41k forks source link

snmp.service restarts automatically after disable autorestart via "config feature autorestart snmp disabled" #13280

Open CharlieChenEC opened 1 year ago

CharlieChenEC commented 1 year ago

Description

After issuing a command to disable the snmp autorestart through the CLI command "config feature autorestart snmp disabled", and ensures the request has taken effect by looking up syslog. If I execute the docker command to stop snmp container to emulate the abnormal termination of snmp container, the status of snmp.service is expected to change to inactive and keep in that state. However, it restarts automatically.

Steps to reproduce the issue:

  1. Execute "config feature autorestart snmp disabled"
  2. Wait until the message "hostcfgd: Auto-restart status of feature 'snmp' is changed from 'enabled' to 'disabled' ..." shows up in the syslog.
  3. Execute "docker stop snmp"
  4. Observe the snmp service state through 'systemctl status snmp'.

Describe the results you received:

At Step 4, the snmp service stops and is restarted immediately.

Describe the results you expected:

At Step 4, the snmp service should not be restarted.

Output of show version:

Version: master.0-948ce3fe0

Syslog:

Aug  7 13:32:47.395072 sonic INFO hostcfgd: Auto-restart status of feature 'snmp' is changed from 'enabled' to 'disabled' ...
Aug  7 13:32:47.395473 sonic INFO hostcfgd: Updating feature 'snmp' systemd config file related to auto-restart ...
Aug  7 13:32:47.395937 sonic INFO hostcfgd: Feautre 'snmp' systemd config file related to auto-restart is updated!
Aug  7 13:32:47.396006 sonic INFO hostcfgd: Reloading systemd configuration files ...
Aug  7 13:32:47.418597 sonic INFO systemd[1]: Reloading.
Aug  7 13:32:47.667014 sonic INFO hostcfgd: Systemd configuration files are reloaded!
...
Aug  7 13:40:44.938090 sonic DEBUG container: container_stop: BEGIN
Aug  7 13:40:44.938374 sonic DEBUG container: read_data: config:True feature:snmp fields:[('set_owner', 'local'), ('no_fallback_to_local', False), ('state', 'disabled')] val:['local', False, 'enabled']
Aug  7 13:40:44.938853 sonic DEBUG container: read_data: config:False feature:snmp fields:[('current_owner', 'none'), ('remote_state', 'none'), ('container_id', '')] val:['none', 'none', '']
Aug  7 13:40:44.939484 sonic DEBUG container: container_stop: snmp: set_owner:local current_owner:none remote_state:none docker_id:snmp
Aug  7 13:40:44.959379 sonic INFO container: docker cmd: stop for snmp
Aug  7 13:40:44.959729 sonic DEBUG container: container_stop: END
Aug  7 13:40:44.986055 sonic NOTICE root: Stopped snmp service...
Aug  7 13:40:44.989923 sonic INFO systemd[1]: snmp.service: Succeeded.
Aug  7 13:40:44.992879 sonic INFO systemd[1]: Starting SNMP container...
Aug  7 13:40:45.004259 sonic NOTICE root: Starting snmp service...
Aug  7 13:40:45.377593 sonic INFO snmp.sh[11608]: 0

Additional information you deem important (e.g. issue happens only occasionally):

neethajohn commented 1 year ago

@SuvarnaMeenakshi , can you help on this issue?

CharlieChenEC commented 5 months ago

The issue had been fixed on the latest image built from master branch on 2024/4/22. Close this issue. image

Here are the test logs.

admin@sonic:~$ show version

SONiC Software Version: SONiC.master.528795-f60ef62c7
SONiC OS Version: 12
Distribution: Debian 12.5
Kernel: 6.1.0-11-2-amd64
Build commit: f60ef62c7
Build date: Mon Apr 22 13:04:15 UTC 2024
Built by: AzDevOps@vmss-soni003IIT

Platform: x86_64-accton_as7816_64x-r0
HwSKU: Accton-AS7816-64X
ASIC: broadcom
ASIC Count: 1
Serial Number: 781654X1911006
Model Number: FP3ZZ7664022A
Hardware Revision: N/A
...
bgp             enabled
database        always_enabled
dhcp_relay      enabled
eventd          enabled
gnmi            enabled
lldp            enabled
macsec          enabled
mgmt-framework  enabled
mux             enabled
nat             enabled
pmon            enabled
radv            enabled
sflow           enabled
snmp            enabled
swss            enabled
syncd           enabled
teamd           enabled
root@sonic:~# config feature autorestart snmp disabled
root@sonic:~# show feature autorestart
Feature         AutoRestart
--------------  --------------
bgp             enabled
database        always_enabled
dhcp_relay      enabled
eventd          enabled
gnmi            enabled
lldp            enabled
macsec          enabled
mgmt-framework  enabled
mux             enabled
nat             enabled
pmon            enabled
radv            enabled
sflow           enabled
snmp            disabled
swss            enabled
syncd           enabled
teamd           enabled
root@sonic:~# grep snmp /var/log/syslog
...
Jan 26 21:55:00.452858 sonic INFO featured: Auto-restart status of feature 'snmp' is changed from 'enabled' to 'disabled' ...
Jan 26 21:55:00.453096 sonic INFO featured: Updating feature 'snmp' systemd config file related to auto-restart ...
Jan 26 21:55:00.453263 sonic INFO featured: Feature 'snmp' systemd config file related to auto-restart is updated!

root@sonic:~# docker stop snmp
snmp
root@sonic:~# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED         STATUS         PORTS     NAMES
f51ae1b81964   docker-platform-monitor:latest       "/usr/bin/docker_ini"   7 minutes ago   Up 7 minutes             pmon
7c484537180d   docker-sonic-mgmt-framework:latest   "/usr/local/bin/supe"   7 minutes ago   Up 7 minutes             mgmt-framework
eca0b53376c3   docker-lldp:latest                   "/usr/bin/docker-lld"   7 minutes ago   Up 7 minutes             lldp
603a0c9b3011   docker-sonic-gnmi:latest             "/usr/local/bin/supe"   7 minutes ago   Up 7 minutes             gnmi
753c26504757   docker-fpm-frr:latest                "/usr/bin/docker_ini"   8 minutes ago   Up 8 minutes             bgp
23e0494d952d   docker-router-advertiser:latest      "/usr/bin/docker-ini"   8 minutes ago   Up 8 minutes             radv
4291f710a93f   docker-syncd-brcm:latest             "/usr/local/bin/supe"   8 minutes ago   Up 8 minutes             syncd
e5dfdf5e7c16   docker-teamd:latest                  "/usr/local/bin/supe"   8 minutes ago   Up 8 minutes             teamd
5e010552894b   docker-orchagent:latest              "/usr/bin/docker-ini"   8 minutes ago   Up 8 minutes             swss
f846eff51d9a   docker-eventd:latest                 "/usr/local/bin/supe"   8 minutes ago   Up 8 minutes             eventd
020d9d01f8f9   docker-database:latest               "/usr/local/bin/dock"   8 minutes ago   Up 8 minutes             database
root@sonic:~# systemctl status snmp

 snmp.service - SNMP container
     Loaded: loaded (/lib/systemd/system/snmp.service; static)
    Drop-In: /etc/systemd/system/snmp.service.d
             auto_restart.conf
     Active: inactive (dead)

Jan 26 21:50:42 sonic container[9113]: container_wait: END -- transitioning to >
Jan 26 21:57:37 sonic container[9113]: docker cmd: wait for snmp
Jan 26 21:57:37 sonic container[12216]: container_stop: BEGIN
Jan 26 21:57:37 sonic container[12216]: read_data: config:True feature:snmp fie>
Jan 26 21:57:37 sonic container[12216]: read_data: config:False feature:snmp fi>
Jan 26 21:57:37 sonic container[12216]: container_stop: snmp: set_owner:local c>
Jan 26 21:57:37 sonic container[12216]: docker cmd: stop for snmp
Jan 26 21:57:37 sonic container[12216]: container_stop: END
Jan 26 21:57:37 sonic root[12251]: Stopped snmp service...
Jan 26 21:57:37 sonic systemd[1]: snmp.service: Deactivated successfully.

root@sonic:~# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED          STATUS          PORTS     NAMES
f51ae1b81964   docker-platform-monitor:latest       "/usr/bin/docker_ini…"   21 minutes ago   Up 21 minutes             pmon
7c484537180d   docker-sonic-mgmt-framework:latest   "/usr/local/bin/supe…"   21 minutes ago   Up 21 minutes             mgmt-framework
eca0b53376c3   docker-lldp:latest                   "/usr/bin/docker-lld…"   21 minutes ago   Up 21 minutes             lldp
603a0c9b3011   docker-sonic-gnmi:latest             "/usr/local/bin/supe…"   21 minutes ago   Up 21 minutes             gnmi
753c26504757   docker-fpm-frr:latest                "/usr/bin/docker_ini…"   22 minutes ago   Up 22 minutes             bgp
23e0494d952d   docker-router-advertiser:latest      "/usr/bin/docker-ini…"   22 minutes ago   Up 22 minutes             radv
4291f710a93f   docker-syncd-brcm:latest             "/usr/local/bin/supe…"   22 minutes ago   Up 22 minutes             syncd
e5dfdf5e7c16   docker-teamd:latest                  "/usr/local/bin/supe…"   22 minutes ago   Up 22 minutes             teamd
5e010552894b   docker-orchagent:latest              "/usr/bin/docker-ini…"   22 minutes ago   Up 22 minutes             swss
f846eff51d9a   docker-eventd:latest                 "/usr/local/bin/supe…"   22 minutes ago   Up 22 minutes             eventd
020d9d01f8f9   docker-database:latest               "/usr/local/bin/dock…"   22 minutes ago   Up 22 minutes             database