-
Notifications
You must be signed in to change notification settings - Fork 710
Fix issues for sonic_installer upgrade-docker and sonic_installer rollback-docker #2278
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
Changes from 2 commits
a3bbf46
58b1cec
b4a0720
d690b7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ def get_docker_tag_name(image): | |
|
||
|
||
def echo_and_log(msg, priority=LOG_NOTICE, fg=None): | ||
if priority >= LOG_ERR: | ||
if priority == LOG_ERR: | ||
# Print to stderr if priority is error | ||
click.secho(msg, fg=fg, err=True) | ||
else: | ||
|
@@ -647,7 +647,7 @@ def set_fips(image, enable_fips): | |
bootloader = get_bootloader() | ||
if not image: | ||
image = bootloader.get_next_image() | ||
if image not in bootloader.get_installed_images(): | ||
if image not in bootloader.get_installed_images(): | ||
echo_and_log('Error: Image does not exist', LOG_ERR) | ||
sys.exit(1) | ||
bootloader.set_fips(image, enable=enable_fips) | ||
|
@@ -743,7 +743,8 @@ def cleanup(): | |
"swss", | ||
"syncd", | ||
"teamd", | ||
"telemetry" | ||
"telemetry", | ||
"mgmt-framework" | ||
] | ||
|
||
# Upgrade docker image | ||
|
@@ -872,17 +873,17 @@ def upgrade_docker(container_name, url, cleanup_image, skip_check, tag, warm): | |
# this is image_id for image with "latest" tag | ||
image_id_latest = get_container_image_id(image_latest) | ||
|
||
for id in image_id_all: | ||
if id != image_id_latest: | ||
# Unless requested, the previoud docker image will be preserved | ||
if not cleanup_image and id == image_id_previous: | ||
continue | ||
run_command("docker rmi -f %s" % id) | ||
if cleanup_image: | ||
# Unless requested, the previoud docker image will be preserved | ||
for id in image_id_all: | ||
if id != image_id_latest and id == image_id_previous: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will fix |
||
run_command("docker rmi -f %s" % id) | ||
break | ||
|
||
exp_state = "reconciled" | ||
state = "" | ||
# post warm restart specific procssing for swss, bgp and teamd dockers, wait for reconciliation state. | ||
if warm_configured is True or warm: | ||
if warm_app_names and (warm_configured is True or warm): | ||
count = 0 | ||
for warm_app_name in warm_app_names: | ||
state = "" | ||
|
@@ -938,7 +939,8 @@ def rollback_docker(container_name): | |
version_tag = "" | ||
for id in image_id_all: | ||
if id != image_id_previous: | ||
version_tag = get_docker_tag_name(id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi qi, thanks for the suggestion. I would to rollback this change because I found the real issue is in sonic build system. Here is my analyze: During my previous manual test with a local image, I found However, I re-visit the logic today, and I found:
In theory, item#2 and item#3 shall get the same value of ${SONIC_IMAGE_VERSION}. But it doesn't. I got from build log:
As you can see, value of SONIC_IMAGE_VERSION is different in the same build. I suppose SONIC_IMAGE_VERSION value shall always be the same in the same build. The issue is probably related to the timestamp in the SONIC_IMAGE_VERSION. However, I found timestamp is not part of SONIC_IMAGE_VERSION in official image. So, maybe we can ignore this issue. |
||
version_tag = run_command("docker images --format '{{{{.ID}}}} {{{{.Tag}}}}' | grep {} | awk '{{print $2}}'".format(id)) | ||
break | ||
|
||
# make previous image as latest | ||
run_command("docker tag %s:%s %s:latest" % (image_name, version_tag, image_name)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make coverage easier, do you really need this change? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I will rollback line 942, I don't need this change any more.