Skip to content

Commit

Permalink
[hostcfgd] Configure service auto-restart in hostcfgd.
Browse files Browse the repository at this point in the history
Before this change, a process runnning inside every SONiC
container dealt with FEATURE table 'auto_restart' field and
depending on the value decided wether a container has to be
killed or not. If killed service auto restart mechanism
restarts the container. This change moves the logic from
container to the host daemon - hostcfgd.

* hostcfgd refactoring - move feature handling in another class.
* override systemd service Restart= setting from hostcfgd.
* remove code that deals with FEATURE table from supervisor-proc-exit-listener.
* remove default systemd Restart=always.

Signed-off-by: Stepan Blyshchak <[email protected]>
  • Loading branch information
stepanblyschak committed Oct 26, 2020
1 parent 5486f87 commit e729226
Show file tree
Hide file tree
Showing 45 changed files with 172 additions and 178 deletions.
2 changes: 1 addition & 1 deletion dockers/docker-database/supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ logfile_backups=2
nodaemon=true

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name database
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=50

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name dhcp_relay
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=50

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-fpm-gobgp/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ logfile_backups=2
nodaemon=true

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-fpm-quagga/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ logfile_backups=2
nodaemon=true

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-lldp/supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=25

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name lldp
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-nat/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=25

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name nat
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-orchagent/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=100

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name swss
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=100

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name pmon
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=25

[eventlistener:supervisor-proc-exit-script]
command=/usr/bin/supervisor-proc-exit-listener --container-name radv
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-sflow/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=25

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name sflow
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-snmp/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=50

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name snmp
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-sonic-restapi/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=25

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name restapi
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=false
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-sonic-telemetry/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=50

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name telemetry
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=false
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-teamd/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ events=PROCESS_STATE
buffer_size=50

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name teamd
command=/usr/bin/supervisor-proc-exit-listener
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/dhcp_relay.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{ docker_container_name }}.sh start
ExecStart=/usr/bin/{{ docker_container_name }}.sh wait
ExecStop=/usr/bin/{{ docker_container_name }}.sh stop
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/nat.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/per_namespace/bgp.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ExecStartPre=/usr/local/bin/{{docker_container_name}}.sh start{% if multi_instan
ExecStart=/usr/local/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
ExecStop=/usr/local/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}

Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/per_namespace/database.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ User=root
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
ExecStart=/usr/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
ExecStop=/usr/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/per_namespace/lldp.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
ExecStart=/usr/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
ExecStop=/usr/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/per_namespace/swss.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Environment=sonic_asic_platform={{ sonic_asic_platform }}
ExecStartPre=/usr/local/bin/swss.sh start{% if multi_instance == 'true' %} %i{% endif %}
ExecStart=/usr/local/bin/swss.sh wait{% if multi_instance == 'true' %} %i{% endif %}
ExecStop=/usr/local/bin/swss.sh stop{% if multi_instance == 'true' %} %i{% endif %}
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/per_namespace/teamd.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
ExecStart=/usr/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
ExecStop=/usr/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/pmon.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/radv.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/local/bin/{{ docker_container_name }}.sh start
ExecStart=/usr/local/bin/{{ docker_container_name }}.sh wait
ExecStop=/usr/local/bin/{{ docker_container_name }}.sh stop
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/restapi.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/sflow.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/share_image/database.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ User=root
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start chassisdb
ExecStart=/usr/bin/{{docker_container_name}}.sh wait chassisdb
ExecStop=/usr/bin/{{docker_container_name}}.sh stop chassisdb
Restart=always
RestartSec=30

[Install]
Expand Down
1 change: 0 additions & 1 deletion files/build_templates/snmp.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ StartLimitBurst=3
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

1 change: 0 additions & 1 deletion files/build_templates/telemetry.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

Loading

0 comments on commit e729226

Please sign in to comment.