Skip to content
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] Restart container if auto_restart field in CONFIG_DB is enabled or always_enabled #10620

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yozhao101
Copy link
Contributor

@yozhao101 yozhao101 commented Apr 20, 2022

Signed-off-by: Yong Zhao yozhao@microsoft.com

Why I did it

This PR aims to enable a container to be auto-restarted if auto_restart field in FEATURE table is set to enabled or always_enabled.

This issue only occurred in master image. When the command show feature status is issued to check the auto_restart status of database, it is enabled. However, the systemd configuration file of database shows the Restart=no. Please see the following result:

      admin@str-s6000-on-5:~$ show feature status
      Feature State AutoRestart SetOwner
      -------------- --------------- -------------- ----------
      acms enabled disabled local
      bgp enabled disabled local
      database always_enabled always_enabled local
      dhcp_relay enabled disabled kube
      lldp enabled disabled kube
      macsec disabled enabled
      mgmt-framework enabled enabled
      mux always_disabled disabled local
      nat disabled enabled
      pmon enabled disabled kube
      radv enabled disabled kube
      restapi enabled disabled local
      sflow disabled enabled
      snmp enabled disabled kube
      swss enabled disabled local
      syncd enabled disabled local
      teamd enabled disabled local
      telemetry enabled disabled kube

      admin@str-s6000-on-5:~$ sudo systemctl cat database.service
      # /lib/systemd/system/database.service
      [Unit]
      Description=Database container
      Wants=database-chassis.service
      After=database-chassis.service
      Requires=docker.service
      After=docker.service
      After=rc-local.service
      StartLimitIntervalSec=1200
      StartLimitBurst=3
      
      [Service]
      User=root
      ExecStartPre=/usr/bin/database.sh start
      ExecStart=/usr/bin/database.sh wait
      ExecStop=/usr/bin/database.sh stop
      RestartSec=30
            
      [Install]
      WantedBy=multi-user.target

 # /etc/systemd/system/database.service.d/auto_restart.conf
      [Service]
      Restart=no

How I did it

This PR determines whether the keyword enabled appears in auto_restart field or not.

How to verify it

This PR is tested on the DuT str-s6000-on-5.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

…s set to be

`enabled` or `always_enabled`.

Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant