Skip to content

Commit 805b90a

Browse files
committed
image: T7818: avoid error when skipping config migration
Fix "No such file or directory" error triggered during image upgrade when user opts not to migrate config. GRUB cmdline migration incorrectly attempts to access non-existent config in new image path.
1 parent 4778f24 commit 805b90a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/op_mode/image_installer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,11 +1135,12 @@ def add_image(image_path: str, vrf: str = None, username: str = '',
11351135
if set_as_default:
11361136
grub.set_default(image_name, root_dir)
11371137

1138-
cmdline_options = get_cli_kernel_options(
1139-
f'{target_config_dir}/config.boot')
1140-
grub_util.update_kernel_cmdline_options(' '.join(cmdline_options),
1141-
root_dir=root_dir,
1142-
version=image_name)
1138+
if Path(f'{target_config_dir}/config.boot').exists():
1139+
cmdline_options = get_cli_kernel_options(
1140+
f'{target_config_dir}/config.boot')
1141+
grub_util.update_kernel_cmdline_options(' '.join(cmdline_options),
1142+
root_dir=root_dir,
1143+
version=image_name)
11431144

11441145
except OSError as e:
11451146
# if no space error, remove image dir and cleanup

0 commit comments

Comments
 (0)