Skip to content

Commit a857e83

Browse files
committed
[Bug Fix] docker_image_ctl.j2: remove the logic that recreates database containers on VS platform
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md ** Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it To support the emulation of VS chassis, we need to remove the existing critical service containers before transforming the HwSKU of the VS device. A previous PR [#18512](sonic-net/sonic-buildimage#18512) introduced a change to the docker_image_ctl.j2 that forces VS images to recreate database containers every time the OS is cold started while the behaviors of other containers(swss/bgp/teamd/syncd) remained unchanged. As a consequence, when the VS device is rebooted without proper human intervention, the database containers will be recreated while the other services will reuse existing containers. That can cause the swss/bgp/syncd containers to become invalid if the database containers get recreated with a different container ID, because swss/bgp/syncd containers are configured to use the database containers as the underlying networking stack. By further investigation, we have found that it is not necessary to recreate the database containers in /usr/bin/database.sh to perform HwSKU transformation. So, we should remove this logic. ##### Work item tracking - Microsoft ADO **(number only)**: 30454307 #### How I did it Remove the code that removes existing database containers in /usr/bin/database.sh #### How to verify it * Build VS image and install it on a KVM sonic-vs * Reboot the sonic-vs multiple times and check if all the containers are started successfully every time. <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) The original change was introduced into 202205 branch so we need to backport this fix. - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [X] 202205 - [ ] 202211 - [ ] 202305 - [x] 202405 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [X] 20220532.72 #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> docker_image_ctl.j2: change to not remove existing database containers on VS platform <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. -->
1 parent 06c3f7d commit a857e83

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

files/build_templates/docker_image_ctl.j2

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -475,33 +475,28 @@ start() {
475475

476476
DOCKERCHECK=`docker inspect --type container ${DOCKERNAME} 2>/dev/null`
477477
if [ "$?" -eq "0" ]; then
478-
{%- if docker_container_name == "database" and sonic_asic_platform == "vs" %}
479-
echo "Removing existing ${DOCKERNAME} container"
480-
docker rm -f ${DOCKERNAME}
478+
{%- if docker_container_name == "database" %}
479+
DOCKERMOUNT=""
481480
{%- else %}
481+
DOCKERMOUNT=`getMountPoint "$DOCKERCHECK"`
482+
{%- endif %}
483+
if [ x"$DOCKERMOUNT" == x"$MOUNTPATH" ]; then
484+
CONTAINER_EXISTS="yes"
485+
preStartAction
482486
{%- if docker_container_name == "database" %}
483-
DOCKERMOUNT=""
487+
echo "Starting existing ${DOCKERNAME} container"
488+
docker start ${DOCKERNAME}
484489
{%- else %}
485-
DOCKERMOUNT=`getMountPoint "$DOCKERCHECK"`
490+
echo "Starting existing ${DOCKERNAME} container with HWSKU $HWSKU"
491+
/usr/local/bin/container start ${DOCKERNAME}
486492
{%- endif %}
487-
if [ x"$DOCKERMOUNT" == x"$MOUNTPATH" ]; then
488-
CONTAINER_EXISTS="yes"
489-
preStartAction
490-
{%- if docker_container_name == "database" %}
491-
echo "Starting existing ${DOCKERNAME} container"
492-
docker start ${DOCKERNAME}
493-
{%- else %}
494-
echo "Starting existing ${DOCKERNAME} container with HWSKU $HWSKU"
495-
/usr/local/bin/container start ${DOCKERNAME}
496-
{%- endif %}
497-
postStartAction
498-
exit $?
499-
fi
493+
postStartAction
494+
exit $?
495+
fi
500496

501-
# docker created with a different HWSKU, remove and recreate
502-
echo "Removing obsolete ${DOCKERNAME} container with HWSKU $DOCKERMOUNT"
503-
docker rm -f ${DOCKERNAME}
504-
{%- endif %}
497+
# docker created with a different HWSKU, remove and recreate
498+
echo "Removing obsolete ${DOCKERNAME} container with HWSKU $DOCKERMOUNT"
499+
docker rm -f ${DOCKERNAME}
505500
fi
506501

507502
{%- if docker_container_name == "database" %}

0 commit comments

Comments
 (0)