sonic-buildimage/files/build_templates
Stephen Sun 7308d2eb97 [Mellanox] Stop pmon ahead of syncd (#3505)
Issue Overview
shutdown flow

For any shutdown flow, which means all dockers are stopped in order, pmon docker stops after syncd docker has stopped, causing pmon docker fail to release sx_core resources and leaving sx_core in a bad state. The related logs are like the following:

INFO syncd.sh[23597]: modprobe: FATAL: Module sx_core is in use.
INFO syncd.sh[23597]: Unloading sx_core[FAILED]
INFO syncd.sh[23597]: rmmod: ERROR: Module sx_core is in use
config reload & service swss.restart
In the flows like "config reload" and "service swss restart", the failure cause further consequences:

sx_core initialization error with error message like "sx_core: create EMAD sdq 0 failed. err: -16"
syncd fails to execute the create switch api with error message "syncd_main: Runtime error: :- processEvent: failed to execute api: create, key: SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000, status: SAI_STATUS_FAILURE"
swss fails to call SAI API "SAI_SWITCH_ATTR_INIT_SWITCH", which causes orchagent to restart. This will introduce an extra 1 or 2 minutes for the system to be available, failing related test cases.
reboot, warm-reboot & fast-reboot
In the reboot flows including "reboot", "fast-reboot" and "warm-reboot" this failure doesn't have further negative effects since the system has already rebooted. In addition, "warm-reboot" requires the system to be shutdown as soon as possible to meet the GR time restriction of both BGP and LACP. "fast-reboot" also requires to meet the GR time restriction of BGP which is longer than LACP. In this sense, any unnecessary steps should be avoided. It's better to keep those flows untouched.

summary
To summarize, we have to come up with a way to ensure:

shutdown pmon docker ahead of syncd for "config reload" or "service swss restart" flow;
don't shutdown pmon docker ahead of syncd for "fast-reboot" or "warm-reboot" flow in order to save time.
for "reboot" flow, either order is acceptable.
Solution
To solve the issue, pmon shoud be stopped ahead of syncd stopped for all flows except for the warm-reboot.

- How I did it

To stop pmon ahead of syncd stopped. This is done in /usr/local/bin/syncd.sh::stop() and for all shutdown sequence.
Now pmon stops ahead of syncd so there must be a way in which pmon can start after syncd started. Another point that should be taken consideration is that pmon starting should be deferred so that services which have the logic of graceful restart in fast-reboot and warm-reboot have sufficient CPU cycles to meet their deadline.
This is done by add "syncd.service" as "After" to pmon.service and startin /usr/local/bin/syncd.sh::wait()
To start pmon automatically after syncd started.
2019-09-27 10:15:46 +02:00
..
bgp.service.j2 [services] Services which start containers now use 'docker wait' instead of 'docker attach' (#2661) 2019-03-08 10:59:41 -08:00
buffers_config.j2 [qos]: Map tc 1, 2, 5, and 6 back to pg 0 (#2650) 2019-03-08 02:23:32 -08:00
database.service.j2 create multiple Redis DB instances based on CONFIG at /etc/sonic/database_config.json (#2182) 2019-08-28 11:15:10 -07:00
dhcp_relay.service.j2 [services] Restart SwSS service upon unexpected critical process exit (#2845) 2019-05-01 08:02:38 -07:00
docker_image_ctl.j2 [SNMP] management VRF SNMP support (#2608) 2019-09-18 17:26:45 -07:00
lldp.service.j2 [services] Services which start containers now use 'docker wait' instead of 'docker attach' (#2661) 2019-03-08 10:59:41 -08:00
organization_extensions.sh Framework to plugin Organization specific scripts during ONIE Image build (#951) 2017-09-19 16:23:31 -07:00
pmon.service.j2 [Mellanox] Stop pmon ahead of syncd (#3505) 2019-09-27 10:15:46 +02:00
qos_config.j2 [Qos] use dot1p to tc mapping for backend switches (#3422) 2019-09-13 11:28:25 -07:00
radv.service.j2 [radv service] radv service should be a cold only dependent of swss (#3348) 2019-08-16 12:08:46 -07:00
sflow.service.j2 [sflow]: Build infrastructure changes to support sflow docker and utilities (#3251) 2019-09-14 20:27:09 -07:00
snmp.service.j2 [services] Restart SwSS service upon unexpected critical process exit (#2845) 2019-05-01 08:02:38 -07:00
snmp.timer Enable sairedis counter thread in 3 minutes after SONiC was started (#1805) 2018-06-22 19:53:51 -07:00
sonic_debian_extension.j2 [build] install new platform api on host (#3282) 2019-09-25 11:00:24 -07:00
swss.service.j2 [submodule] update sonic-linux-kernel (#2985) 2019-06-18 10:00:16 -07:00
syncd.service.j2 [submodule] update sonic-linux-kernel (#2985) 2019-06-18 10:00:16 -07:00
teamd.service.j2 [service dependent] describe non-warm-reboot dependency outside systemd (#3311) 2019-08-08 15:45:17 -07:00
telemetry.service.j2 [telemetry]: change the service dependency from swss to database (#3072) 2019-06-24 12:36:16 -07:00
updategraph.service.j2 [mellanox]: Upgraded hw-management V.2.0.0160. (#2643) 2019-03-06 18:51:46 -08:00