Skip to content

test(e2e): silence helm-template render in install-cozystack trace - #2615

Merged
myasnikovdaniil merged 3 commits into
mainfrom
fix/e2e-install-trace-verbosity
May 21, 2026
Merged

myasnikovdaniil merged 3 commits into
mainfrom
fix/e2e-install-trace-verbosity

Conversation

@myasnikovdaniil

@myasnikovdaniil myasnikovdaniil commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Trims the Install Cozystack into sandbox CI step from ~40k log lines back down to a normal size.

The Pre-pull platform images bats test was capturing each rendered chart into a shell variable so a render failure would trip set -e:

kubeovn_manifests=$(helm template packages/system/kubeovn)
linstor_manifests=$(helm template packages/system/linstor)
printf '%s\n%s\n' "$kubeovn_manifests" "$linstor_manifests" | yq ... | hack/e2e-prepull-images.sh

hack/cozytest.sh runs every bats test under set -x, and bash expands captured command output into the trace as + var=<entire stdout>. The kubeovn and linstor renders are several thousand lines each, and the printf line re-expands both variables, so the same YAML was being dumped to the log three times.

This PR stages each render to a tmp file instead:

helm template packages/system/kubeovn > "$kubeovn_yaml"
helm template packages/system/linstor > "$linstor_yaml"
cat "$kubeovn_yaml" "$linstor_yaml" | yq ... | hack/e2e-prepull-images.sh

The original safety property is preserved — helm template ... > file is a simple command whose exit code still triggers set -e on failure, exactly like var=$(helm template ...) did. The trace now shows the command line, not its rendered output.

Release note

NONE

Summary by CodeRabbit

  • Tests
    • Improved image pre-pull test to render charts into temporary files, consolidate results, and feed them deterministically into the image pre-pull check.
    • Made failure handling more reliable so rendering or parsing errors now cause the test to fail predictably.

Review Change Stack

The pre-pull test captured each rendered chart into a shell variable
(`kubeovn_manifests=$(helm template ...)`) so a render failure would
trip `set -e` (bats has no `pipefail`, so piping helm into yq would mask
a helm failure with yq's exit code).

cozytest.sh runs every bats test under `set -x`, and bash expands
captured command output into the trace as `+ var=<entire stdout>`.
Two full helm renders (kubeovn + linstor) plus a `printf` re-expansion
were ballooning the install step to ~40k log lines per CI run.

Stage each render to a tmp file instead. The same exit-code semantics
apply (a failed `helm template ... > file` still trips `set -e`), but
the trace now only shows the commands themselves, not the rendered YAML.

Assisted-By: Claude <[email protected]>
Signed-off-by: Myasnikov Daniil <[email protected]>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses excessive CI log output caused by bash variable expansion during the 'Install Cozystack' e2e test. By switching from capturing large helm template outputs in variables to using temporary files, the PR prevents thousands of lines of YAML from being dumped into the CI trace while preserving necessary error-handling behaviors.

Highlights

  • CI Log Optimization: Refactored the image pre-pull logic in the e2e test suite to write helm templates to temporary files instead of shell variables, significantly reducing CI log verbosity.
  • Error Handling Preservation: Maintained the existing safety property where render failures trigger 'set -e' by ensuring helm commands are executed independently before processing.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment Gemini (@gemini-code-assist) Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions github-actions Bot added area/testing Issues or PRs related to testing (e2e, bats, unit tests) size/S This PR changes 10-29 lines, ignoring generated files labels May 12, 2026
@coderabbitai

coderabbitai Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 75a3ff5e-b1f8-4827-b0d2-a7338c468ef6

📥 Commits

Reviewing files that changed from the base of the PR and between 5ddcb0d and 39d46f2.

📒 Files selected for processing (1)
  • hack/e2e-install-cozystack.bats

📝 Walkthrough

Walkthrough

Writes each helm template render to separate temp files, runs yq -N over both to create a combined images list file, passes that file to hack/e2e-prepull-images.sh via stdin redirection, and deletes the temps in the "Pre-pull platform images" e2e test.

Changes

E2E Image Pre-pull Test

Layer / File(s) Summary
Render charts to temp files and feed yq
hack/e2e-install-cozystack.bats
Replaces capturing helm template outputs in shell variables and printf concatenation with writing each render to mktemp files, running yq -N over both temp files to produce a consolidated images list, supplying that list to hack/e2e-prepull-images.sh via stdin redirection, and removing temp files afterward.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I'm a rabbit in the CI glen, with a temp file in my paw,
Helm drops its manifests, I tuck them in a maw,
yq reads both pages, the prepull takes a sip,
Temps vanish like carrots — hop, tidy, and quick! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(e2e): silence helm-template render in install-cozystack trace' directly addresses the main change: refactoring how helm template renders are handled to reduce CI log volume by avoiding expansion of large shell variables in trace output.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/e2e-install-trace-verbosity

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot Bot added the area/ci Issues or PRs related to CI workflows, GitHub Actions, automation label May 12, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the image pre-pulling logic in the E2E installation script to use temporary files instead of variable captures. This change prevents CI logs from ballooning when tracing is enabled and ensures that Helm template failures are correctly caught. Feedback suggests further improving the script by using a trap for file cleanup, optimizing the yq call by passing files directly, and addressing potential exit code masking in the shell pipeline.

Comment thread hack/e2e-install-cozystack.bats Outdated
Comment on lines +27 to +36
local kubeovn_yaml linstor_yaml
kubeovn_yaml=$(mktemp)
linstor_yaml=$(mktemp)
helm template packages/system/kubeovn > "$kubeovn_yaml"
helm template packages/system/linstor > "$linstor_yaml"
cat "$kubeovn_yaml" "$linstor_yaml" | yq -N '
(..|select(has("containers"))|.containers[]|.image),
(..|select(has("initContainers"))|.initContainers[]|.image)
' | hack/e2e-prepull-images.sh
rm -f "$kubeovn_yaml" "$linstor_yaml"

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.

medium

This refactoring improves the code in several ways:

  1. Cleanup: Using a trap ensures that temporary files are removed even if the test fails (each Bats test runs in its own subshell).
  2. Optimization: Passing files directly to yq avoids an unnecessary cat process.
  3. Correctness: Note that while helm template failures are now caught by set -e, the yq command is still in a pipeline where its exit code is masked because Bats does not enable pipefail by default. If yq fails and produces no output, the prepull script will exit with 0, and the test will pass without actually pre-pulling images. Consider adding set -o pipefail if you want to ensure yq errors also trigger a test failure.
  local kubeovn_yaml linstor_yaml
  kubeovn_yaml=$(mktemp)
  linstor_yaml=$(mktemp)
  trap 'rm -f "$kubeovn_yaml" "$linstor_yaml"' EXIT
  helm template packages/system/kubeovn > "$kubeovn_yaml"
  helm template packages/system/linstor > "$linstor_yaml"
  yq -N '
      (..|select(has("containers"))|.containers[]|.image),
      (..|select(has("initContainers"))|.initContainers[]|.image)
    ' "$kubeovn_yaml" "$linstor_yaml" | hack/e2e-prepull-images.sh

myasnikovdaniil and others added 2 commits May 20, 2026 16:41
The previous form staged each helm-template render to a tmp file so a
render failure would trip `set -e` outside the pipe. That avoided the
`var=$(...)` trace-bloat trap, but yq still ran inside a pipe with
pipefail off, so a yq failure (bad expression, schema drift) would be
masked by the prepull script's exit code and the test would pass while
silently pre-pulling nothing.

Replace the tmp-file dance with a brace group + `set -o pipefail`:
helm-template output flows through the pipe, never expanded into the
`set -x` trace (verified under `hack/cozytest.sh`: 5 command lines, no
YAML), and pipefail now surfaces a failure at any stage. Drops the
mktemp/rm scaffolding and the `cat` subprocess.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Myasnikov Daniil <[email protected]>
The prior commit added `set -o pipefail` to catch yq failures in the
prepull pipeline. CI failed at runtime: hack/cozytest.sh has a
`#!/bin/sh` shebang, /bin/sh is dash on Ubuntu CI, and dash rejects
`set -o pipefail` ("Illegal option").

Drop the pipe entirely. Each step is now its own command with stdin/
stdout redirection — set -e catches failures at the helm-template, yq,
or prepull stage without needing pipefail and without `var=$(...)`
captures that would balloon the `set -x` trace with rendered YAML.
Verified under dash in Ubuntu 24.04 by running cozytest.sh against the
test.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Myasnikov Daniil <[email protected]>

@Arsolitt Arsolitt (Arsolitt) 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.

LGTM — trace-bloat fix is correct and the file-staging approach is the right choice given the dash/pipefail constraint inside the e2e sandbox.

Business context: The "Install Cozystack into sandbox" CI step was emitting ~40k log lines because var=$(helm template ...) captures were expanded into the set -x trace under cozytest.sh. This PR keeps the same set-e safety property while keeping the rendered YAML out of the trace.

Verified

  • The bloat reproduces as described. hack/cozytest.sh runs each test under set -eu -x (hack/cozytest.sh:36) with PS4='+ ', and the trace reader iterates line-by-line, so a multi-line trace line lands in the log as one timestamped output line per content line. Three expansions per render (two captures + one printf re-expansion) match the reported magnitude.
  • The pipefail rationale is correct. The e2e sandbox image is ubuntu:22.04 (packages/core/testing/images/e2e-sandbox/Dockerfile:1) and make install-cozystack invokes cozytest.sh via docker exec ... sh -c (packages/core/testing/Makefile:37) — dash on 22.04 (0.5.11) has no set -o pipefail.
  • Safety property preserved: each of helm template > file, yq ... > file, and prepull < file is a standalone command, so set -e aborts on any failure without depending on pipefail.
  • Output semantics equivalent. yq -N '<expr>' file1 file2 processes both files and emits images one per line; hack/e2e-prepull-images.sh sorts/uniqs and tolerates either order.

@myasnikovdaniil
myasnikovdaniil merged commit e3a737a into main May 21, 2026
10 checks passed
@myasnikovdaniil
myasnikovdaniil deleted the fix/e2e-install-trace-verbosity branch May 21, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci Issues or PRs related to CI workflows, GitHub Actions, automation area/testing Issues or PRs related to testing (e2e, bats, unit tests) size/S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants