From fa6442998a124c700009ca940b7c798984519b09 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Fri, 20 Jun 2025 18:19:29 +0300 Subject: [PATCH 1/6] Save a list of observed images after workflow Signed-off-by: Timofei Larkin --- .github/workflows/pull-requests.yaml | 9 +++++++++ hack/list-images.sh | 8 ++++++++ packages/core/testing/Makefile | 7 +++++++ 3 files changed, 24 insertions(+) create mode 100644 hack/list-images.sh diff --git a/.github/workflows/pull-requests.yaml b/.github/workflows/pull-requests.yaml index 0e8f786e..9057978a 100644 --- a/.github/workflows/pull-requests.yaml +++ b/.github/workflows/pull-requests.yaml @@ -329,6 +329,15 @@ jobs: - name: Set sandbox ID run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV + - name: List images used + run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME list-images + + - name: Upload image list + uses: actions/upload-artifact@v4 + with: + name: image-list + path: images.txt + - name: Tear down sandbox run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete diff --git a/hack/list-images.sh b/hack/list-images.sh new file mode 100644 index 00000000..7ae4853a --- /dev/null +++ b/hack/list-images.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +rm ./hosttmp/images.txt + +for node in 11 12 13; do + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> ./hosttmp/images.txt + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> ./hosttmp/images.txt +done diff --git a/packages/core/testing/Makefile b/packages/core/testing/Makefile index 206ab765..e5101cd2 100755 --- a/packages/core/testing/Makefile +++ b/packages/core/testing/Makefile @@ -62,10 +62,17 @@ exec: ## Opens an interactive shell in the sandbox container. docker exec -ti "${SANDBOX_NAME}" bash apply: delete + mkdir -p /tmp/${SANDBOX_NAME} + chmod 777 /tmp/${SANDBOX_NAME} docker run \ -d --rm --name "${SANDBOX_NAME}" --privileged \ -e TALOSCONFIG=/workspace/talosconfig \ -e KUBECONFIG=/workspace/kubeconfig \ + -e SANDBOX_NAME=${SANDBOX_NAME} \ + -v /tmp/${SANDBOX_NAME}:/workspace/hosttmp \ "$$(yq .e2e.image values.yaml)" \ --timeout 30m docker cp "${ROOT_DIR}" "${SANDBOX_NAME}":/workspace + +list-images: + docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/list-images.sh' From 433bfe7b6ccb14baef3c1ad679eaea6f21a5dc28 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Tue, 24 Jun 2025 13:00:49 +0400 Subject: [PATCH 2/6] Save image list outside of sandbox Because the sandbox is torn down after successful tests Signed-off-by: Timofei Larkin --- packages/core/testing/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/testing/Makefile b/packages/core/testing/Makefile index e5101cd2..bce8ffda 100755 --- a/packages/core/testing/Makefile +++ b/packages/core/testing/Makefile @@ -69,7 +69,7 @@ apply: delete -e TALOSCONFIG=/workspace/talosconfig \ -e KUBECONFIG=/workspace/kubeconfig \ -e SANDBOX_NAME=${SANDBOX_NAME} \ - -v /tmp/${SANDBOX_NAME}:/workspace/hosttmp \ + -v /tmp:/workspace/hosttmp \ "$$(yq .e2e.image values.yaml)" \ --timeout 30m docker cp "${ROOT_DIR}" "${SANDBOX_NAME}":/workspace From 210f3c7b6b71cc5dd9343c8e7185dbbfd4ba3b4a Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Tue, 24 Jun 2025 13:02:22 +0400 Subject: [PATCH 3/6] Save images with unique filename Signed-off-by: Timofei Larkin --- hack/list-images.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hack/list-images.sh b/hack/list-images.sh index 7ae4853a..3a29300d 100644 --- a/hack/list-images.sh +++ b/hack/list-images.sh @@ -1,8 +1,6 @@ #!/bin/sh -rm ./hosttmp/images.txt - for node in 11 12 13; do - talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> ./hosttmp/images.txt - talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> ./hosttmp/images.txt + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> ./hosttmp/images-${SANDBOX_NAME}.txt + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> ./hosttmp/images-${SANDBOX_NAME}.txt done From 1f748d563fb63efdeecae4020e68e8ed16b8612c Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Thu, 3 Jul 2025 13:56:35 +0300 Subject: [PATCH 4/6] Copy contents of directory instead of directory Signed-off-by: Timofei Larkin --- packages/core/testing/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/testing/Makefile b/packages/core/testing/Makefile index bce8ffda..40906caf 100755 --- a/packages/core/testing/Makefile +++ b/packages/core/testing/Makefile @@ -72,7 +72,7 @@ apply: delete -v /tmp:/workspace/hosttmp \ "$$(yq .e2e.image values.yaml)" \ --timeout 30m - docker cp "${ROOT_DIR}" "${SANDBOX_NAME}":/workspace + docker cp "${ROOT_DIR}/." "${SANDBOX_NAME}":/workspace list-images: docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/list-images.sh' From f891d0bee65367995a4d2a4591e83d7161b110f9 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Tue, 24 Jun 2025 17:47:11 +0300 Subject: [PATCH 5/6] Add exec bit to script, sanitize image list Signed-off-by: Timofei Larkin --- hack/list-images.sh | 6 ++++-- packages/core/testing/Makefile | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) mode change 100644 => 100755 hack/list-images.sh diff --git a/hack/list-images.sh b/hack/list-images.sh old mode 100644 new mode 100755 index 3a29300d..efb772f9 --- a/hack/list-images.sh +++ b/hack/list-images.sh @@ -1,6 +1,8 @@ #!/bin/sh for node in 11 12 13; do - talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> ./hosttmp/images-${SANDBOX_NAME}.txt - talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> ./hosttmp/images-${SANDBOX_NAME}.txt + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> /workspace/images.tmp + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> /workspace/images.tmp done + +while read _ name sha _ ; do echo $sha $name ; done < /workspace/images.tmp | sort -u > /workspace/images.txt diff --git a/packages/core/testing/Makefile b/packages/core/testing/Makefile index 40906caf..ec3b0179 100755 --- a/packages/core/testing/Makefile +++ b/packages/core/testing/Makefile @@ -69,10 +69,10 @@ apply: delete -e TALOSCONFIG=/workspace/talosconfig \ -e KUBECONFIG=/workspace/kubeconfig \ -e SANDBOX_NAME=${SANDBOX_NAME} \ - -v /tmp:/workspace/hosttmp \ "$$(yq .e2e.image values.yaml)" \ --timeout 30m docker cp "${ROOT_DIR}/." "${SANDBOX_NAME}":/workspace list-images: docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/list-images.sh' + docker cp "${SANDBOX_NAME}":/workspace/images.txt ../../../images.txt From 8ec882ca5f9223272a160e7acde3b59494f78c77 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Thu, 3 Jul 2025 14:04:10 +0300 Subject: [PATCH 6/6] [dx] Refactor collect-images functionality Signed-off-by: Andrei Kvapil --- .github/workflows/pull-requests.yaml | 26 ++++++++++++++------------ hack/collect-images.sh | 8 ++++++++ hack/list-images.sh | 8 -------- packages/core/testing/Makefile | 9 +++++---- 4 files changed, 27 insertions(+), 24 deletions(-) create mode 100755 hack/collect-images.sh delete mode 100755 hack/list-images.sh diff --git a/.github/workflows/pull-requests.yaml b/.github/workflows/pull-requests.yaml index 9057978a..4e989f41 100644 --- a/.github/workflows/pull-requests.yaml +++ b/.github/workflows/pull-requests.yaml @@ -290,8 +290,8 @@ jobs: done echo "✅ The task completed successfully after $attempt attempts" - collect_report: - name: Collect report + collect_debug_information: + name: Collect debug information runs-on: [self-hosted] needs: [test_apps] if: ${{ always() }} @@ -313,10 +313,21 @@ jobs: name: cozyreport path: /tmp/${{ env.SANDBOX_NAME }}/_out/cozyreport.tgz + - name: Collect images list + run: | + cd /tmp/$SANDBOX_NAME + make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME collect-images + + - name: Upload image list + uses: actions/upload-artifact@v4 + with: + name: image-list + path: /tmp/${{ env.SANDBOX_NAME }}/_out/images.txt + cleanup: name: Tear down environment runs-on: [self-hosted] - needs: [collect_report] + needs: [collect_debug_information] if: ${{ always() && needs.test_apps.result == 'success' }} steps: @@ -329,15 +340,6 @@ jobs: - name: Set sandbox ID run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV - - name: List images used - run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME list-images - - - name: Upload image list - uses: actions/upload-artifact@v4 - with: - name: image-list - path: images.txt - - name: Tear down sandbox run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete diff --git a/hack/collect-images.sh b/hack/collect-images.sh new file mode 100755 index 00000000..817f1d06 --- /dev/null +++ b/hack/collect-images.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +for node in 11 12 13; do + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> images.tmp + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> images.tmp +done + +while read _ name sha _ ; do echo $sha $name ; done < images.tmp | sort -u > images.txt diff --git a/hack/list-images.sh b/hack/list-images.sh deleted file mode 100755 index efb772f9..00000000 --- a/hack/list-images.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -for node in 11 12 13; do - talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> /workspace/images.tmp - talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> /workspace/images.tmp -done - -while read _ name sha _ ; do echo $sha $name ; done < /workspace/images.tmp | sort -u > /workspace/images.txt diff --git a/packages/core/testing/Makefile b/packages/core/testing/Makefile index ec3b0179..f597d5ce 100755 --- a/packages/core/testing/Makefile +++ b/packages/core/testing/Makefile @@ -55,6 +55,11 @@ collect-report: ## Collect the test report from the sandbox. mkdir -p ../../../_out docker cp "${SANDBOX_NAME}:/workspace/cozyreport.tgz" ../../../_out/cozyreport.tgz +collect-images: ## Collect the list of images used in the sandbox. + docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/collect-images.sh' + mkdir -p ../../../_out + docker cp "${SANDBOX_NAME}":/workspace/images.txt ../../../_out/images.txt + delete: ## Remove sandbox from existing Kubernetes cluster. docker rm -f "${SANDBOX_NAME}" || true @@ -72,7 +77,3 @@ apply: delete "$$(yq .e2e.image values.yaml)" \ --timeout 30m docker cp "${ROOT_DIR}/." "${SANDBOX_NAME}":/workspace - -list-images: - docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/list-images.sh' - docker cp "${SANDBOX_NAME}":/workspace/images.txt ../../../images.txt