Skip to content

Save a list of observed images after workflow - #1089

Merged
Andrei Kvapil (kvaps) merged 6 commits into
mainfrom
feat/list-images-used
Jul 3, 2025
Merged

Save a list of observed images after workflow#1089
Andrei Kvapil (kvaps) merged 6 commits into
mainfrom
feat/list-images-used

Conversation

@lllamnyp

@lllamnyp Timofei Larkin (lllamnyp) commented Jun 20, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added a process to list images used in the environment before deletion during cleanup operations.
  • Chores
    • Enhanced environment cleanup workflow with improved visibility into used images.
    • Introduced a shared writable directory between host and container for better file management during testing.

@coderabbitai

coderabbitai Bot commented Jun 20, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

Andrei Kvapil (@kvaps) has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 529d7a3 and 8ec882c.

📒 Files selected for processing (3)
  • .github/workflows/pull-requests.yaml (2 hunks)
  • hack/collect-images.sh (1 hunks)
  • packages/core/testing/Makefile (1 hunks)

"""

Walkthrough

This change adds new steps to the GitHub Actions cleanup job to list and upload container images used by sandbox nodes before teardown. It introduces a shell script that collects image information from nodes, modifies the Makefile to support running this script inside the sandbox container, and adds a new Makefile target for listing images.

Changes

File(s) Change Summary
.github/workflows/pull-requests.yaml Adds "List images used" and "Upload image list" steps in cleanup job after setting sandbox ID, before sandbox teardown.
hack/list-images.sh New script that collects image lists from nodes via talosctl commands and outputs a sorted unique list.
packages/core/testing/Makefile Adds list-images target; modifies apply target to create/mount shared directory, set env var, and adjust docker cp path.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant Makefile
    participant Sandbox Container
    participant list-images.sh

    GitHub Actions->>Makefile: make list-images SANDBOX_NAME
    Makefile->>Sandbox Container: Run hack/list-images.sh (mounted /workspace/hosttmp)
    Sandbox Container->>list-images.sh: Execute script to gather images
    list-images.sh->>Sandbox Container: Write images.txt in shared directory
    Sandbox Container->>Makefile: Script completes
    GitHub Actions->>Makefile: make delete SANDBOX_NAME
    Makefile->>Sandbox Container: Tear down sandbox environment
Loading

Possibly related PRs

Suggested labels

enhancement, lgtm

Suggested reviewers

  • kvaps

Poem

🐇 In sandbox fields where images hide,
I hop and gather, far and wide.
A list I make, before I clean,
To keep our warren tidy and keen.
With scripts and steps, the job’s in sight—
A rabbit’s work done just right! 🌿✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
packages/core/testing/Makefile (1)

52-60: Clean up mount directory on delete and tighten permissions

Avoid leaving behind stale directories and overly permissive modes. Remove /tmp/${SANDBOX_NAME} in the delete target and change the mount folder’s permissions from 777 to 700:

 delete: ## Remove sandbox from existing Kubernetes cluster.
-	docker rm -f "${SANDBOX_NAME}" || true
+	docker rm -f "${SANDBOX_NAME}" || true
+	rm -rf /tmp/${SANDBOX_NAME} || true

 apply: delete
-	mkdir -p /tmp/${SANDBOX_NAME}
-	chmod 777 /tmp/${SANDBOX_NAME}
+	mkdir -p /tmp/${SANDBOX_NAME}
+	chmod 700 /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)" \
 		sleep infinity
🧹 Nitpick comments (2)
hack/list-images.sh (1)

5-8: Improve readability with node headers and quote variables

Prepend a header for each node’s images block and quote the IP expansions to guard against unexpected splitting or globbing.

-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
+for node in 11 12 13; do
+  echo "=== Images for node 192.168.123.${node} ===" >> ./hosttmp/images.txt
+  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
packages/core/testing/Makefile (1)

70-72: Document the new list-images target

Add a help docstring so it appears in make help:

-list-images:
+list-images: ## List Talos node images into shared `/workspace/hosttmp`
 	docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/list-images.sh'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a8530a and c493071.

📒 Files selected for processing (3)
  • .github/workflows/pull-requests.yaml (1 hunks)
  • hack/list-images.sh (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/pull-requests.yaml

157-157: shellcheck reported issue in this script: SC2086:info:1:44: Double quote to prevent globbing and word splitting

(shellcheck)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (1)
.github/workflows/pull-requests.yaml (1)

156-160: ```shell
#!/bin/bash

Extract the relevant section from the workflow to verify current configuration

sed -n '140,180p' .github/workflows/pull-requests.yaml


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread .github/workflows/pull-requests.yaml Outdated
Comment thread hack/list-images.sh Outdated
Comment on lines +1 to +4
#!/bin/sh

rm ./hosttmp/images.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add strict mode and safe file removal

Enable pipefail and exit-on-error/undefined, and switch to rm -f so the script doesn’t error if images.txt is missing. Also ensure the hosttmp directory exists.

-#!/bin/sh
+#!/bin/sh
+set -euo pipefail

-mkdir -p ./hosttmp
-rm ./hosttmp/images.txt
+mkdir -p ./hosttmp
+rm -f ./hosttmp/images.txt

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In hack/list-images.sh at lines 1 to 4, add strict mode by enabling 'set -euo
pipefail' at the top of the script to ensure it exits on errors or undefined
variables and fails on pipeline errors. Change the 'rm ./hosttmp/images.txt'
command to 'rm -f ./hosttmp/images.txt' to avoid errors if the file does not
exist. Before removing the file, add a check or command to ensure the 'hosttmp'
directory exists to prevent errors related to missing directories.

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make artifact apploaded to the github releases as images.list
Prefer using docker cp instead of -v, as it is not working with remote docker daemon

Comment thread hack/list-images.sh
Comment on lines +3 to +6
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
done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
done
for node in 11 12 13; do
talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls | awk '{print $2}' >> ./hosttmp/images-${SANDBOX_NAME}.txt.tmp
talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls | awk '{print $2}' >> ./hosttmp/images-${SANDBOX_NAME}.txt.tmp
done
sort -u ./hosttmp/images-${SANDBOX_NAME}.txt.tmp > ./hosttmp/images-${SANDBOX_NAME}.txt
rm -f ./hosttmp/images-${SANDBOX_NAME}.txt.tmp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/pull-requests.yaml (1)

195-197: Quote the variable to satisfy shell-lint & avoid edge-case word-splitting

ShellCheck (see previous lints) still complains about SC2086 here.
Although $SANDBOX_NAME is unlikely to contain spaces, quoting is free and silences the linter.

-        run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME list-images
+        run: make -C packages/core/testing SANDBOX_NAME="$SANDBOX_NAME" list-images
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa71b78 and e3614b5.

📒 Files selected for processing (3)
  • .github/workflows/pull-requests.yaml (1 hunks)
  • hack/list-images.sh (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • hack/list-images.sh
  • packages/core/testing/Makefile
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/pull-requests.yaml

[error] 203-203: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (1)
.github/workflows/pull-requests.yaml (1)

198-203: Artifact may be empty – path & resiliency need adjustment

  1. images.txt is referenced relative to the job’s work-dir, but list-images
    executes inside the sandbox container via Make. Unless that target explicitly copies
    the file back to ${{ github.workspace }}, the upload will silently create an empty artifact.
    Typical location would be /tmp/$SANDBOX_NAME/images.txt.

  2. The upload step should run regardless of earlier failures so that we don’t lose diagnostics.

  3. Line 203 has trailing whitespace ‑ YAML-lint error.

Proposed patch:

-      - name: Upload image list
-        uses: actions/upload-artifact@v4
-        with:
-          name: image-list
-          path: images.txt
+      - name: Upload image list
+        if: always()
+        uses: actions/upload-artifact@v4
+        with:
+          name: image-list
+          path: /tmp/$SANDBOX_NAME/images.txt

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/pull-requests.yaml (1)

195-197: Quote the $SANDBOX_NAME variable to satisfy ShellCheck SC2086

Previous Action Lint feedback (SC2086) is still applicable.
The un-quoted variable can expand to multiple words and break make.

-        run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME list-images
+        run: make -C packages/core/testing SANDBOX_NAME="$SANDBOX_NAME" list-images
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3614b5 and d1e61aa.

📒 Files selected for processing (3)
  • .github/workflows/pull-requests.yaml (1 hunks)
  • hack/list-images.sh (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • hack/list-images.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/testing/Makefile
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/pull-requests.yaml

[error] 203-203: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (1)
.github/workflows/pull-requests.yaml (1)

198-203: ```bash
#!/bin/bash
set -e

echo "== Workflow snippet around the upload step (lines 150–250) =="
sed -n '150,250p' .github/workflows/pull-requests.yaml

echo -e "\n== Steps referencing 'list-images' in the workflow =="
grep -R "list-images" -n .github/workflows/pull-requests.yaml

echo -e "\n== References to 'images.txt' across the repo =="
grep -R "images.txt" -n .


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread hack/list-images.sh Outdated
Timofei Larkin (lllamnyp) and others added 5 commits July 3, 2025 13:54
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Because the sandbox is torn down after successful tests

Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
@kvaps
Andrei Kvapil (kvaps) force-pushed the feat/list-images-used branch 2 times, most recently from 09ddf7c to d59ec5b Compare July 3, 2025 11:05
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kvaps
Andrei Kvapil (kvaps) merged commit d2126b6 into main Jul 3, 2025
@kvaps
Andrei Kvapil (kvaps) deleted the feat/list-images-used branch July 3, 2025 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants