diff --git a/tests/integration/test_calico.py b/tests/integration/test_calico.py index 4dbbaaf..bed0053 100644 --- a/tests/integration/test_calico.py +++ b/tests/integration/test_calico.py @@ -14,13 +14,11 @@ def get_image_platform(): arch = platform.machine() - match arch: - case "x86_64": - return "amd64" - case "aarch64": - return "arm64" - case _: - raise Exception(f"Unsupported cpu platform: {arch}") + if arch == "x86_64": + return "amd64" + elif arch == "aarch64": + return "arm64" + raise Exception(f"Unsupported cpu platform: {arch}") IMG_PLATFORM = get_image_platform() @@ -45,7 +43,8 @@ def get_image_platform(): def get_installation_spec(registry, repo): return f""" # This section includes base Calico installation configuration. -# For more information, see: https://docs.tigera.io/calico/latest/reference/installation/api#operator.tigera.io/v1.Installation +# For more information, see: +# https://docs.tigera.io/calico/latest/reference/installation/api#operator.tigera.io/v1.Installation apiVersion: operator.tigera.io/v1 kind: Installation metadata: @@ -92,7 +91,6 @@ def get_imageset_spec(operator_version, calico_version): "calico-kube-controllers", "calico-csi", "calico-apiserver", - "calico-ctl", "calico-pod2daemon-flexvol", "calico-key-cert-provisioner", "calico-node-driver-registrar", @@ -105,11 +103,14 @@ def get_imageset_spec(operator_version, calico_version): image, version, IMG_PLATFORM ) sha256_digest = get_image_sha256_digest(rock.image) - prefix = rock.image.split("/")[1] + + # We're supposed to pass the original image names and new hashes. + orig_image = image.replace("calico-tigera-", "tigera/") + orig_image = orig_image.replace("calico-", "calico/") spec["spec"]["images"].append( { - "image": f"{prefix}/{image}", + "image": orig_image, "digest": sha256_digest, } ) diff --git a/tests/sanity/test_calico.py b/tests/sanity/test_calico.py index 5036a26..38a1d4a 100644 --- a/tests/sanity/test_calico.py +++ b/tests/sanity/test_calico.py @@ -11,13 +11,11 @@ def get_image_platform(): arch = platform.machine() - match arch: - case "x86_64": - return "amd64" - case "aarch64": - return "arm64" - case _: - raise Exception(f"Unsupported cpu platform: {arch}") + if arch == "x86_64": + return "amd64" + elif arch == "aarch64": + return "arm64" + raise Exception(f"Unsupported cpu platform: {arch}") IMG_PLATFORM = get_image_platform() diff --git a/tigera-operator/v1.34.0/fix_image_component_handling.patch b/tigera-operator/v1.34.0/fix_image_component_handling.patch deleted file mode 100644 index 0e81b1c..0000000 --- a/tigera-operator/v1.34.0/fix_image_component_handling.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 2e4c26edd41894a3ec0a05418233800e4a3fdf80 Mon Sep 17 00:00:00 2001 -From: Lucian Petrut -Date: Thu, 12 Sep 2024 12:03:48 +0000 -Subject: [PATCH] Fix image component handling, honoring Installation spec - -components.GetReference currently ignores the image prefix and path -specified in the "Installation" spec. - -It makes a copy of the image component, appends the configured image -path and prefix but then it uses the original component image when -looping over the image set. - -The fix is trivial, we just have to use the modified image string. ---- - pkg/components/references.go | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/pkg/components/references.go b/pkg/components/references.go -index bcf6cb95..68be249b 100644 ---- a/pkg/components/references.go -+++ b/pkg/components/references.go -@@ -85,12 +85,12 @@ func GetReference(c Component, registry, imagePath, imagePrefix string, is *oper - } - - for _, img := range is.Spec.Images { -- if img.Image == c.Image { -+ if img.Image == image { - return fmt.Sprintf("%s%s@%s", registry, image, img.Digest), nil - } - } - -- return "", fmt.Errorf("ImageSet did not contain image %s", c.Image) -+ return "", fmt.Errorf("ImageSet did not contain image %s", image) - } - - func ReplaceImagePath(image, imagePath string) string { --- -2.39.2 (Apple Git-143) diff --git a/tigera-operator/v1.34.0/fix_imageset_checks.patch b/tigera-operator/v1.34.0/fix_imageset_checks.patch deleted file mode 100644 index 245d86a..0000000 --- a/tigera-operator/v1.34.0/fix_imageset_checks.patch +++ /dev/null @@ -1,30 +0,0 @@ -From d358aa98f1c82171af5afe815909a6d8ade0168a Mon Sep 17 00:00:00 2001 -From: Lucian Petrut -Date: Thu, 12 Sep 2024 13:58:24 +0000 -Subject: [PATCH] quick hack: disable image set check - -Calico currently checks if the image set that it received matches -the upstream images, which prevents us from using custom images. - -This quick hack will just ignore unknown images. However, we should -use the Installation spec to parse the images, just like GetReference -does. ---- - pkg/controller/utils/imageset/imageset.go | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/pkg/controller/utils/imageset/imageset.go b/pkg/controller/utils/imageset/imageset.go -index a825ddb9..b21aa693 100644 ---- a/pkg/controller/utils/imageset/imageset.go -+++ b/pkg/controller/utils/imageset/imageset.go -@@ -122,7 +122,7 @@ func ValidateImageSet(is *operator.ImageSet) error { - } - } - -- if len(unknownImages) == 0 && len(invalidDigests) == 0 { -+ if len(invalidDigests) == 0 { - return nil - } - --- -2.43.0 diff --git a/tigera-operator/v1.34.0/rockcraft.yaml b/tigera-operator/v1.34.0/rockcraft.yaml index 91ad1be..00bb67b 100644 --- a/tigera-operator/v1.34.0/rockcraft.yaml +++ b/tigera-operator/v1.34.0/rockcraft.yaml @@ -38,8 +38,6 @@ parts: - PACKAGE_NAME: github.com/tigera/operator override-build: | export EMAIL=root@localhost - git am --ignore-whitespace $CRAFT_PROJECT_DIR/fix_image_component_handling.patch - git am --ignore-whitespace $CRAFT_PROJECT_DIR/fix_imageset_checks.patch LDFLAGS="-X ${PACKAGE_NAME}/version.VERSION=${GIT_VERSION} -s -w"