From a9dbbafa570e0a80ae571bd26b4dbfe7edb452c3 Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Wed, 7 Aug 2024 12:02:20 +0200 Subject: [PATCH 1/9] Invoke openstack-image-manager without shell Signed-off-by: Martin Morgenstern --- osism/commands/manage.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/osism/commands/manage.py b/osism/commands/manage.py index 44c4a37f..1b115cc6 100644 --- a/osism/commands/manage.py +++ b/osism/commands/manage.py @@ -78,10 +78,15 @@ def take_action(self, parsed_args): with open(f"/tmp/clusterapi/k8s-{kubernetes_release}.yml", "w+") as fp: fp.write(result) - subprocess.call( - "/usr/local/bin/openstack-image-manager --images=/tmp/clusterapi --cloud admin --filter 'Kubernetes CAPI'", - shell=True, - ) + args = [ + "openstack-image-manager", + "--images=/tmp/clusterapi", + "--cloud", + "admin", + "--filter", + "Kubernetes CAPI", + ] + subprocess.call(args) class ImageOctavia(Command): From a4f5bf48124671e7b75df3b7e894fe9aee3e0c57 Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Wed, 7 Aug 2024 12:08:44 +0200 Subject: [PATCH 2/9] Fix hard-coded `--cloud` flag Signed-off-by: Martin Morgenstern --- osism/commands/manage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osism/commands/manage.py b/osism/commands/manage.py index 1b115cc6..a9fe3723 100644 --- a/osism/commands/manage.py +++ b/osism/commands/manage.py @@ -27,7 +27,7 @@ def get_parser(self, prog_name): default="https://swift.services.a.regiocloud.tech/swift/v1/AUTH_b182637428444b9aa302bb8d5a5a418c/openstack-k8s-capi-images/", ) parser.add_argument( - "--cloud", type=str, help="Cloud name in clouds.yaml", default="openstack" + "--cloud", type=str, help="Cloud name in clouds.yaml (will be overruled by OS_AUTH_URL envvar)", default="admin" ) parser.add_argument( "--filter", @@ -82,7 +82,7 @@ def take_action(self, parsed_args): "openstack-image-manager", "--images=/tmp/clusterapi", "--cloud", - "admin", + cloud, "--filter", "Kubernetes CAPI", ] From 8c91f7bc637ed61ec36afe75909f142dfb453ea6 Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Wed, 7 Aug 2024 12:14:16 +0200 Subject: [PATCH 3/9] Allow passing `--dry-run` flag to image manager Signed-off-by: Martin Morgenstern --- osism/commands/manage.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osism/commands/manage.py b/osism/commands/manage.py index a9fe3723..67d8680d 100644 --- a/osism/commands/manage.py +++ b/osism/commands/manage.py @@ -29,6 +29,11 @@ def get_parser(self, prog_name): parser.add_argument( "--cloud", type=str, help="Cloud name in clouds.yaml (will be overruled by OS_AUTH_URL envvar)", default="admin" ) + parser.add_argument( + "--dry-run", + action="store_true", + help="Do not perform any changes (--dry-run passed to openstack-image-manager)", + ) parser.add_argument( "--filter", type=str, @@ -86,6 +91,8 @@ def take_action(self, parsed_args): "--filter", "Kubernetes CAPI", ] + if parsed_args.dry_run: + args.append("--dry-run") subprocess.call(args) From 5c1c2cb7fd28c20a9deffd97255b4e3a0700e0d6 Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Wed, 7 Aug 2024 12:22:02 +0200 Subject: [PATCH 4/9] Allow passing a custom `--tag` to image manager Signed-off-by: Martin Morgenstern --- osism/commands/manage.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osism/commands/manage.py b/osism/commands/manage.py index 67d8680d..66774b8d 100644 --- a/osism/commands/manage.py +++ b/osism/commands/manage.py @@ -34,6 +34,12 @@ def get_parser(self, prog_name): action="store_true", help="Do not perform any changes (--dry-run passed to openstack-image-manager)", ) + parser.add_argument( + "--tag", + type=str, + help="Name of the tag used to identify managed images (use openstack-image-manager's default if unset)", + default=None, + ) parser.add_argument( "--filter", type=str, @@ -46,6 +52,7 @@ def take_action(self, parsed_args): base_url = parsed_args.base_url cloud = parsed_args.cloud filter = parsed_args.filter + tag = parsed_args.tag if filter: supported_cluterapi_k8s_images = [filter] @@ -91,6 +98,8 @@ def take_action(self, parsed_args): "--filter", "Kubernetes CAPI", ] + if tag is not None: + args.extend(["--tag", tag]) if parsed_args.dry_run: args.append("--dry-run") subprocess.call(args) From 11865bbefbb46a40319b6b424a9ba3b2f054187a Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Tue, 6 Aug 2024 10:16:04 +0200 Subject: [PATCH 5/9] Set hypervisor_type=qemu in CAPI images Signed-off-by: Martin Morgenstern --- osism/data/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/osism/data/__init__.py b/osism/data/__init__.py index 2bb4de47..8dcd6904 100644 --- a/osism/data/__init__.py +++ b/osism/data/__init__.py @@ -48,6 +48,7 @@ hw_rng_model: virtio hw_scsi_model: virtio-scsi hw_watchdog_action: reset + hypervisor_type: qemu os_distro: ubuntu replace_frequency: never uuid_validity: none From e53db3c493b3e07c969dfbd1c3cf83defd3e43ca Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Tue, 6 Aug 2024 10:16:41 +0200 Subject: [PATCH 6/9] Set hw_disk_bus=scsi in CAPI images * this is the recommendation in SCS * precondition for hw_scsi_model property Signed-off-by: Martin Morgenstern --- osism/data/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osism/data/__init__.py b/osism/data/__init__.py index 8dcd6904..0839254e 100644 --- a/osism/data/__init__.py +++ b/osism/data/__init__.py @@ -44,7 +44,7 @@ multi: false meta: architecture: x86_64 - hw_disk_bus: virtio + hw_disk_bus: scsi hw_rng_model: virtio hw_scsi_model: virtio-scsi hw_watchdog_action: reset From 2028134205299671b5b969f9a8cab0086a808719 Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Wed, 7 Aug 2024 12:29:11 +0200 Subject: [PATCH 7/9] Use SCS compliant CAPI image name Signed-off-by: Martin Morgenstern --- osism/commands/manage.py | 2 +- osism/data/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osism/commands/manage.py b/osism/commands/manage.py index 66774b8d..84d26fd9 100644 --- a/osism/commands/manage.py +++ b/osism/commands/manage.py @@ -96,7 +96,7 @@ def take_action(self, parsed_args): "--cloud", cloud, "--filter", - "Kubernetes CAPI", + "ubuntu-capi-image", ] if tag is not None: args.extend(["--tag", tag]) diff --git a/osism/data/__init__.py b/osism/data/__init__.py index 0839254e..c50db19f 100644 --- a/osism/data/__init__.py +++ b/osism/data/__init__.py @@ -32,7 +32,7 @@ TEMPLATE_IMAGE_CLUSTERAPI = """--- images: - - name: Kubernetes CAPI + - name: ubuntu-capi-image enable: true keep: true format: qcow2 From 254869861f4bf3b817d429962035dda9c9be31e3 Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Wed, 7 Aug 2024 13:23:07 +0200 Subject: [PATCH 8/9] Format code with black Signed-off-by: Martin Morgenstern --- osism/commands/manage.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osism/commands/manage.py b/osism/commands/manage.py index 84d26fd9..037ac456 100644 --- a/osism/commands/manage.py +++ b/osism/commands/manage.py @@ -27,7 +27,10 @@ def get_parser(self, prog_name): default="https://swift.services.a.regiocloud.tech/swift/v1/AUTH_b182637428444b9aa302bb8d5a5a418c/openstack-k8s-capi-images/", ) parser.add_argument( - "--cloud", type=str, help="Cloud name in clouds.yaml (will be overruled by OS_AUTH_URL envvar)", default="admin" + "--cloud", + type=str, + help="Cloud name in clouds.yaml (will be overruled by OS_AUTH_URL envvar)", + default="admin", ) parser.add_argument( "--dry-run", From fbb461352eabc88bc67f8be794d4495c50eafcc3 Mon Sep 17 00:00:00 2001 From: Martin Morgenstern Date: Wed, 7 Aug 2024 19:35:02 +0200 Subject: [PATCH 9/9] Version needs to be prefixed with `v` Signed-off-by: Martin Morgenstern --- osism/data/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osism/data/__init__.py b/osism/data/__init__.py index c50db19f..c34e3562 100644 --- a/osism/data/__init__.py +++ b/osism/data/__init__.py @@ -55,7 +55,7 @@ provided_until: none tags: [] versions: - - version: "{{ image_version }}" + - version: "v{{ image_version }}" url: "{{ image_url }}" checksum: "{{ image_checksum }}" build_date: {{ image_builddate }}