From d392f6351f3fd7ee971ba9b1ef80cf772eca6326 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Mon, 12 Jun 2023 16:24:36 +0200 Subject: [PATCH 1/2] Override nettest and submariner-metrics-proxy To ensure that we're testing with the latest image, as available in the local repository, we need to override all users of the nettest image. Currently subctl exposes two components for that: submariner-nettest and submariner-metrics-proxy. This patch adds support for multiple components per image; since the project already preloads the nettest image, this results in the correct image override arguments being given to subctl. Signed-off-by: Stephen Kitt --- scripts/shared/lib/deploy_operator | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/shared/lib/deploy_operator b/scripts/shared/lib/deploy_operator index a56e6873f..e9852e2b3 100644 --- a/scripts/shared/lib/deploy_operator +++ b/scripts/shared/lib/deploy_operator @@ -18,6 +18,7 @@ component_by_image['submariner-operator']=submariner-operator component_by_image['submariner-route-agent']=submariner-routeagent component_by_image['lighthouse-agent']=submariner-lighthouse-agent component_by_image['lighthouse-coredns']=submariner-lighthouse-coredns +component_by_image['nettest']='submariner-nettest submariner-metrics-proxy' ### Functions ### @@ -66,9 +67,11 @@ function subctl_install_subm() { [[ "$AIR_GAPPED" = true ]] && extra_flags+=(--repository "${SUBM_IMAGE_REPO}" --version "${SUBM_IMAGE_TAG}") for image in ${PRELOAD_IMAGES}; do - local image_key="${component_by_image[$image]}" - [[ -n "${image_key}" ]] || continue - extra_flags+=(--image-override "${image_key}=${SUBM_IMAGE_REPO}/${image}:${SUBM_IMAGE_TAG}") + local image_keys="${component_by_image[$image]}" + [[ -n "${image_keys}" ]] || continue + for image_key in $image_keys; do + extra_flags+=(--image-override "${image_key}=${SUBM_IMAGE_REPO}/${image}:${SUBM_IMAGE_TAG}") + done done fi From ec9cc48494f216d583c1369d309be691a77604a5 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Wed, 17 May 2023 17:45:37 +0200 Subject: [PATCH 2/2] Check deployed images against built images After deployment, if any images were built, check that they were used in the deployment. Signed-off-by: Stephen Kitt --- scripts/shared/deploy.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/shared/deploy.sh b/scripts/shared/deploy.sh index c37f84e4a..600f75ed5 100755 --- a/scripts/shared/deploy.sh +++ b/scripts/shared/deploy.sh @@ -130,6 +130,25 @@ fi run_if_defined post_deploy +# Check that the deployed images match those we built (if any) +image_mismatch=false +for image in package/.image.*; do + expected="$(docker image inspect "$(cat "$image")" | jq -r '.[0].RepoDigests[0]')" + image="${image#package/.image.}" + for deployed in $(kubectl get pods -A -o json | jq -r '.items[].status.containerStatuses[].imageID' | grep "$image"); do + if [ "$deployed" != "$expected" ]; then + printf "Image %s is deployed with %s, expected %s\n" "$image" "$deployed" "$expected" + image_mismatch=true + else + printf "Successfully checked image %s, deployed with %s\n" "$image" "$deployed" + fi + done +done +if [ "$image_mismatch" = true ]; then + kubectl get pods -A -o json + exit 1 +fi + # Print installed versions for manual validation of CI subctl show versions print_clusters_message