GHA - free disk space in mnt directory#34
Conversation
WalkthroughA new step was added to three GitHub Actions workflow files to address disk space exhaustion by freeing space in the Changes
Estimated code review effort1 (~3 minutes) Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
.github/workflows/rhoai-in-kind-with-cypress.yaml (1)
52-60: Same glob-failure risk as in other workflowReplicate the null-glob or
|| truesafeguard here; otherwise the Cypress workflow may still fail when/mntis empty.(See earlier comment for concrete patch.)
🧹 Nitpick comments (2)
.github/workflows/rhoai-in-kind-with-odh-tests-shiftleft.yaml (1)
34-34: Remove trailing whitespace to satisfy YAML-lintA trailing space on this line is flagged by the CI linter.
Delete the extra space to keep the workflow lint-clean.- python-version: '3.13'␠ + python-version: '3.13'.github/workflows/rhoai-in-kind-with-ods-ci.yaml (1)
34-90: Consider a reusable composite action to DRY the three identical cleanup stepsThree workflows now carry identical bash snippets.
Packaging this as a local composite action (e.g..github/actions/free-disk-space) would:• eliminate duplication
• ensure future tweaks propagate everywhere
• allow unit-testing in isolationNot a blocker, but worth considering.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/workflows/rhoai-in-kind-with-cypress.yaml(1 hunks).github/workflows/rhoai-in-kind-with-odh-tests-shiftleft.yaml(1 hunks).github/workflows/rhoai-in-kind-with-ods-ci.yaml(1 hunks)
🪛 YAMLlint (1.37.1)
.github/workflows/rhoai-in-kind-with-odh-tests-shiftleft.yaml
[error] 34-34: trailing spaces
(trailing-spaces)
.github/workflows/rhoai-in-kind-with-ods-ci.yaml
[error] 90-90: trailing spaces
(trailing-spaces)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/rhoai-in-kind-with-odh-tests-shiftleft.yaml
[error] 34-34: trailing spaces
(trailing-spaces)
.github/workflows/rhoai-in-kind-with-ods-ci.yaml
[error] 90-90: trailing spaces
(trailing-spaces)
|
|
||
| # https://github.com/jiridanek/rhoai-in-kind/issues/10 | ||
| # ERROR: very rarely, we end up with a full disk in mnt directory | ||
| - name: Free disk space and swapoff | ||
| run: | | ||
| df -h | ||
| sudo du -sh /mnt/* | ||
| sudo swapoff -a | ||
| sudo rm -rf /mnt/* | ||
| df -h | ||
|
|
There was a problem hiding this comment.
💡 Verification agent
❓ Verification inconclusive
Guard against empty /mnt/* glob to avoid sporadic job failures
GitHub runners execute run: scripts with bash -eo pipefail.
If /mnt is already empty, both
sudo du -sh /mnt/* and sudo rm -rf /mnt/* expand to a literal *, return exit code 1, and the step aborts – defeating the purpose of making the workflow more reliable.
- sudo du -sh /mnt/*
- sudo rm -rf /mnt/*
+ shopt -s nullglob
+ sudo du -sh /mnt/* || true # tolerate empty dir
+ sudo rm -rf /mnt/* || true
+ shopt -u nullglobAlternatively, wrap the commands in if [ -n "$(ls -A /mnt)" ]; then …; fi.
Guard against empty /mnt glob in GitHub Actions
Under the default bash -eo pipefail shell, an empty glob (/mnt/*) expands to the literal *, causing du or rm to fail and abort the step. You can prevent this by enabling nullglob (or wrapping in a conditional).
File: .github/workflows/rhoai-in-kind-with-odh-tests-shiftleft.yaml (around lines 34–44)
• Enable/disable nullglob and add || true to tolerate an empty directory:
- sudo du -sh /mnt/*
- sudo rm -rf /mnt/*
+ shopt -s nullglob
+ sudo du -sh /mnt/* || true # tolerate empty dir
+ sudo rm -rf /mnt/* || true
+ shopt -u nullglob• Alternatively, wrap in an if check:
run: |
df -h
if [ -n "$(ls -A /mnt)" ]; then
sudo du -sh /mnt/*
sudo rm -rf /mnt/*
fi
sudo swapoff -a
df -hThese changes ensure the cleanup step never fails when /mnt is empty.
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 34-34: trailing spaces
(trailing-spaces)
🤖 Prompt for AI Agents
In .github/workflows/rhoai-in-kind-with-odh-tests-shiftleft.yaml around lines 34
to 44, the use of the glob pattern /mnt/* can cause the step to fail if /mnt is
empty because the glob expands to a literal asterisk. To fix this, modify the
run script to either enable the nullglob shell option before using the glob or
wrap the du and rm commands inside a conditional that checks if /mnt is
non-empty. This prevents errors by ensuring the commands only run when there are
files to process.
| # https://github.com/jiridanek/rhoai-in-kind/issues/10 | ||
| # ERROR: very rarely, we end up with a full disk in mnt directory | ||
| - name: Free disk space and swapoff | ||
| run: | | ||
| df -h | ||
| sudo du -sh /mnt/* | ||
| sudo swapoff -a | ||
| sudo rm -rf /mnt/* | ||
| df -h | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Harden cleanup step & fix trailing whitespace
- Apply the null-glob /
|| truepattern to prevent empty-directory failures. - Line 90 contains trailing spaces – YAML-lint error; remove them.
- sudo du -sh /mnt/*
- sudo rm -rf /mnt/*
+ shopt -s nullglob
+ sudo du -sh /mnt/* || true
+ sudo rm -rf /mnt/* || true
+ shopt -u nullglobCommittable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 90-90: trailing spaces
(trailing-spaces)
🤖 Prompt for AI Agents
In .github/workflows/rhoai-in-kind-with-ods-ci.yaml around lines 81 to 90, the
cleanup step can fail if the /mnt directory is empty and line 90 has trailing
whitespace causing a YAML-lint error. Fix this by adding the null-glob or `||
true` pattern to the rm command to avoid errors when no files exist, and remove
any trailing spaces on line 90 to comply with YAML formatting rules.
| python-version: '3.13' | ||
|
|
||
| # https://github.com/jiridanek/rhoai-in-kind/issues/10 | ||
| # ERROR: very rarely, we end up with a full disk in mnt directory |
There was a problem hiding this comment.
| # ERROR: very rarely, we end up with a full disk in mnt directory | |
| # very rarely, GitHub Actions hosted runner begins with a completely full `/mnt` directory |
| python-version: '3.13' | ||
|
|
||
| # https://github.com/jiridanek/rhoai-in-kind/issues/10 | ||
| # ERROR: very rarely, we end up with a full disk in mnt directory |
There was a problem hiding this comment.
| # ERROR: very rarely, we end up with a full disk in mnt directory | |
| # very rarely, GitHub Actions hosted runner begins with a completely full `/mnt` directory |
| python-version: '3.13' | ||
|
|
||
| # https://github.com/jiridanek/rhoai-in-kind/issues/10 | ||
| # ERROR: very rarely, we end up with a full disk in mnt directory |
There was a problem hiding this comment.
| # ERROR: very rarely, we end up with a full disk in mnt directory | |
| # very rarely, GitHub Actions hosted runner begins with a completely full `/mnt` directory |
Fixes #10
Adding a new step in GHA to free disk space in mnt directory, because there were some rare errors with full disk usage.
Summary by CodeRabbit