Skip to content

Commit 0d53b7a

Browse files
[sonic_installer] don't print errors when installing an image not supporting app ext (sonic-net#1719)
FIXES: sonic-net#8149 #### What I did Don't print errors if installing app.ext incompatible image. #### How I did it Check for docker.sh existance and take an assumption that if it exists then it is app.ext compatible. #### How to verify it From master image install 202012 image and verify no errors in logs.
1 parent 394e2fb commit 0d53b7a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

sonic_installer/main.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
SYSLOG_IDENTIFIER = "sonic-installer"
2424
LOG_ERR = logger.Logger.LOG_PRIORITY_ERROR
25+
LOG_WARN = logger.Logger.LOG_PRIORITY_WARNING
2526
LOG_NOTICE = logger.Logger.LOG_PRIORITY_NOTICE
2627

2728
# Global Config object
@@ -332,6 +333,7 @@ def migrate_sonic_packages(bootloader, binary_image_version):
332333
echo_and_log("Error: SONiC package migration cannot proceed due to missing docker folder", LOG_ERR, fg="red")
333334
return
334335

336+
docker_started = False
335337
with bootloader.get_rootfs_path(new_image_dir) as new_image_squashfs_path:
336338
try:
337339
mount_squash_fs(new_image_squashfs_path, new_image_mount)
@@ -342,22 +344,25 @@ def migrate_sonic_packages(bootloader, binary_image_version):
342344
mount_bind(new_image_docker_dir, new_image_docker_mount)
343345
mount_procfs_chroot(new_image_mount)
344346
mount_sysfs_chroot(new_image_mount)
347+
# Assume if docker.sh script exists we are installing Application Extension compatible image.
348+
if not os.path.exists(os.path.join(new_image_mount, os.path.relpath(DOCKER_CTL_SCRIPT, os.path.abspath(os.sep)))):
349+
echo_and_log("Warning: SONiC Application Extension is not supported in this image", LOG_WARN, fg="yellow")
350+
return
345351
run_command_or_raise(["chroot", new_image_mount, DOCKER_CTL_SCRIPT, "start"])
352+
docker_started = True
346353
run_command_or_raise(["cp", packages_path, os.path.join(new_image_mount, tmp_dir, packages_file)])
347354
run_command_or_raise(["touch", os.path.join(new_image_mount, "tmp", DOCKERD_SOCK)])
348355
run_command_or_raise(["mount", "--bind",
349356
os.path.join(VAR_RUN_PATH, DOCKERD_SOCK),
350357
os.path.join(new_image_mount, "tmp", DOCKERD_SOCK)])
351358
run_command_or_raise(["chroot", new_image_mount, "sh", "-c", "command -v {}".format(SONIC_PACKAGE_MANAGER)])
352-
except SonicRuntimeException as err:
353-
echo_and_log("Warning: SONiC Application Extension is not supported in this image: {}".format(err), LOG_ERR, fg="red")
354-
else:
355359
run_command_or_raise(["chroot", new_image_mount, SONIC_PACKAGE_MANAGER, "migrate",
356360
os.path.join("/", tmp_dir, packages_file),
357361
"--dockerd-socket", os.path.join("/", tmp_dir, DOCKERD_SOCK),
358362
"-y"])
359363
finally:
360-
run_command_or_raise(["chroot", new_image_mount, DOCKER_CTL_SCRIPT, "stop"], raise_exception=False)
364+
if docker_started:
365+
run_command_or_raise(["chroot", new_image_mount, DOCKER_CTL_SCRIPT, "stop"], raise_exception=False)
361366
umount(new_image_mount, recursive=True, read_only=False, remove_dir=False, raise_exception=False)
362367
umount(new_image_mount, raise_exception=False)
363368

0 commit comments

Comments
 (0)