Skip to content

Split testing job into several - #1075

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
maintenance/granular-workflows
Jun 18, 2025
Merged

Split testing job into several#1075
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
maintenance/granular-workflows

Conversation

@lllamnyp

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

Copy link
Copy Markdown
Member

This patch separates the Test job of the PR workflow into several smaller jobs: 1) create a testing sandbox and deploy Talos, 2) install Cozystack and configure it, 3) install managed applications and run e2e tests. This lets developers shorten the feedback loop if tests are merely acting flaky and aren't really broken. It's not the right way, but it's 80/20.

Summary by CodeRabbit

  • New Features
    • Introduced a multi-stage workflow for environment preparation, Cozystack installation, application testing, and cleanup.
    • Added automated end-to-end scripts for provisioning Talos clusters and validating Cozystack installations.
    • Added new Makefile targets to streamline cluster preparation and Cozystack installation processes.
  • Bug Fixes
    • Removed obsolete annotation step in application testing to improve resource handling.
    • Added pre-checks and resource cleanup in application testing to enhance test reliability.
  • Chores
    • Improved workflow structure for enhanced setup and testing reliability.

@coderabbitai

coderabbitai Bot commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change refactors the pull request workflow by splitting a single test job into a multi-stage pipeline with explicit environment preparation, installation, testing, and cleanup phases. It introduces granular Makefile targets and new BATS scripts for end-to-end cluster and platform setup, integrating them into the CI process for improved modularity.

Changes

File(s) Change Summary
.github/workflows/pull-requests.yaml Replaces single test job with sequential jobs: prepare_env, install_cozystack, test_apps, and cleanup.
Makefile Adds a new prepare-env target for environment setup.
hack/e2e-prepare-cluster.bats, hack/e2e-install-cozystack.bats Adds BATS scripts for Talos cluster provisioning and Cozystack installation/validation.
packages/core/testing/Makefile Adds prepare-cluster and install-cozystack targets to run new BATS scripts in sandbox containers.
hack/e2e-apps.bats Adds pre-checks before resource creation and removes PVC annotation command in VM disk test flow.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant Sandbox
    participant QEMU VMs
    participant Talos Cluster
    participant Cozystack Installer

    GitHub Actions->>Sandbox: Run prepare_env (Makefile: prepare-env)
    Sandbox->>QEMU VMs: Provision Talos cluster (e2e-prepare-cluster.bats)
    QEMU VMs->>Talos Cluster: Boot and configure nodes
    GitHub Actions->>Sandbox: Run install_cozystack (Makefile: install-cozystack)
    Sandbox->>Cozystack Installer: Deploy and validate Cozystack (e2e-install-cozystack.bats)
    GitHub Actions->>Sandbox: Run test_apps
    GitHub Actions->>Sandbox: Run cleanup
Loading

Possibly related PRs

Suggested labels

ok-to-test

Suggested reviewers

  • klinch0

Poem

In the warren of CI, new tunnels appear,
Each job hops forward, with steps crystal clear.
From clusters prepared to stacks installed tight,
BATS scripts now test through the day and the night.
With Makefile magic and YAML anew,
This rabbit says, “Bravo! The pipeline just grew!” 🐇✨

✨ 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

🧹 Nitpick comments (4)
packages/core/testing/Makefile (1)

35-38: Consider extracting asset copying into a common target to reduce duplication.

The asset copying logic (lines 36-37) is duplicated in the test-cluster target (lines 44-45). Consider extracting this into a reusable pattern.

Create a common target for asset copying:

+.PHONY: copy-assets
+copy-assets:
+	docker cp ../../../_out/assets/cozystack-installer.yaml "${SANDBOX_NAME}":/workspace/_out/assets/cozystack-installer.yaml
+	docker cp ../../../_out/assets/nocloud-amd64.raw.xz "${SANDBOX_NAME}":/workspace/_out/assets/nocloud-amd64.raw.xz
+
+prepare-cluster: copy-assets
+	docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/cozytest.sh hack/e2e-prepare-cluster.bats'

-prepare-cluster:
-	docker cp ../../../_out/assets/cozystack-installer.yaml "${SANDBOX_NAME}":/workspace/_out/assets/cozystack-installer.yaml
-	docker cp ../../../_out/assets/nocloud-amd64.raw.xz "${SANDBOX_NAME}":/workspace/_out/assets/nocloud-amd64.raw.xz
-	docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/cozytest.sh hack/e2e-prepare-cluster.bats'
.github/workflows/pull-requests.yaml (1)

82-83: Consider extracting sandbox ID calculation to reduce duplication.

The sandbox ID calculation is repeated in all jobs. Consider using job outputs or artifacts to share this value.

You could modify the prepare_env job to output the sandbox ID and reference it in subsequent jobs:

  prepare_env:
    name: Prepare environment
    runs-on: [self-hosted]
    needs: build
+   outputs:
+     sandbox_name: ${{ steps.sandbox.outputs.name }}

    # Never run when the PR carries the "release" label.
    if: |
      !contains(github.event.pull_request.labels.*.name, 'release')

    steps:
      - name: Download installer
        uses: actions/download-artifact@v4
        with:
          name: cozystack-installer
          path: _out/assets/

      - name: Download Talos image
        uses: actions/download-artifact@v4
        with:
          name: talos-image
          path: _out/assets/

      - name: Set sandbox ID
+       id: sandbox
-       run: echo "SANDBOX_NAME=$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_RUN_NUMBER}" | sha256sum | cut -c1-6)" >> $GITHUB_ENV
+       run: |
+         SANDBOX_NAME=$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_RUN_NUMBER}" | sha256sum | cut -c1-6)
+         echo "SANDBOX_NAME=${SANDBOX_NAME}" >> $GITHUB_ENV
+         echo "name=${SANDBOX_NAME}" >> $GITHUB_OUTPUT

Then in subsequent jobs:

  install_cozystack:
    name: Install Cozystack
    runs-on: [self-hosted]
    needs: prepare_env

    # Never run when the PR carries the "release" label.
    if: |
      !contains(github.event.pull_request.labels.*.name, 'release')

    steps:
-     - name: Set sandbox ID
-       run: echo "SANDBOX_NAME=$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_RUN_NUMBER}" | sha256sum | cut -c1-6)" >> $GITHUB_ENV

      - name: Install Cozystack
-       run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME install-cozystack
+       run: make -C packages/core/testing SANDBOX_NAME=${{ needs.prepare_env.outputs.sandbox_name }} install-cozystack

Also applies to: 98-99, 114-115, 130-131

hack/e2e-prepare-cluster.bats (2)

29-30: Improve error handling in VM cleanup.

The current approach could fail silently if PID files don't exist.

-@test "Clean previous VMs" {
- kill $(cat srv1/qemu.pid srv2/qemu.pid srv3/qemu.pid 2>/dev/null) 2>/dev/null || true
- rm -rf srv1 srv2 srv3
-}
+@test "Clean previous VMs" {
+  for i in 1 2 3; do
+    if [ -f "srv${i}/qemu.pid" ]; then
+      pid=$(cat "srv${i}/qemu.pid")
+      if kill -0 "$pid" 2>/dev/null; then
+        kill "$pid" || true
+      fi
+    fi
+  done
+  rm -rf srv1 srv2 srv3
+}

223-224: Consider verifying bootstrap success more thoroughly.

The bootstrap command uses a short timeout which might not be sufficient in all environments.

Add verification after bootstrap:

 @test "Bootstrap Talos cluster" {
   # Bootstrap etcd on the first node
   timeout 10 sh -ec 'until talosctl bootstrap -n 192.168.123.11 -e 192.168.123.11; do sleep 1; done'
+
+  # Verify bootstrap was successful
+  if ! talosctl health -n 192.168.123.11 -e 192.168.123.11 --wait-timeout 30s; then
+    echo "Bootstrap verification failed" >&2
+    exit 1
+  fi
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6498000 and 87f5f83.

📒 Files selected for processing (5)
  • .github/workflows/pull-requests.yaml (2 hunks)
  • Makefile (1 hunks)
  • hack/e2e-install-cozystack.bats (1 hunks)
  • hack/e2e-prepare-cluster.bats (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build
  • GitHub Check: pre-commit
🔇 Additional comments (3)
Makefile (1)

52-54: LGTM! Target follows existing patterns.

The new prepare-env target is well-structured and follows the established pattern in the Makefile.

packages/core/testing/Makefile (1)

40-41: LGTM! Clean and focused target.

The install-cozystack target follows the established pattern for running BATS tests.

hack/e2e-install-cozystack.bats (1)

29-31: Verify fail function availability or use standard exit.

The fail function might not be available in all BATS versions.

#!/bin/bash
# Check if the fail function is used elsewhere in BATS tests
rg -A 2 'fail\s*"' hack/*.bats

Comment on lines +132 to +157
- name: E2E Apps
run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete

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.

⚠️ Potential issue

Fix incorrect step name in cleanup job.

The step name should reflect its actual purpose.

-      - name: E2E Apps
+      - name: Cleanup sandbox
         run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: E2E Apps
run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete
- name: Cleanup sandbox
run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete
🤖 Prompt for AI Agents
In .github/workflows/pull-requests.yaml at lines 132 to 133, the step name "E2E
Apps" does not accurately describe the cleanup action being performed. Rename
the step to a name that clearly reflects its purpose, such as "Cleanup Sandbox"
or "Delete Sandbox," to improve clarity and maintainability of the workflow.

Comment on lines +145 to +149
ingress_ip=$(kubectl get svc root-ingress-controller -n tenant-root -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
if ! curl -sS -k "https://${ingress_ip}" -H 'Host: grafana.example.org' --max-time 30 | grep -q Found; then
echo "Failed to access Grafana via ingress at ${ingress_ip}" >&2
exit 1
fi

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.

⚠️ Potential issue

Improve error handling for Grafana verification.

The current approach could miss curl failures.

-  if ! curl -sS -k "https://${ingress_ip}" -H 'Host: grafana.example.org' --max-time 30 | grep -q Found; then
-    echo "Failed to access Grafana via ingress at ${ingress_ip}" >&2
-    exit 1
-  fi
+  response=$(curl -sS -k "https://${ingress_ip}" -H 'Host: grafana.example.org' --max-time 30 -w '\n%{http_code}' 2>&1) || {
+    echo "Curl failed to access Grafana via ingress at ${ingress_ip}: $?" >&2
+    exit 1
+  }
+  
+  if ! echo "$response" | grep -q Found; then
+    echo "Failed to access Grafana via ingress at ${ingress_ip}" >&2
+    echo "Response: $response" >&2
+    exit 1
+  fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ingress_ip=$(kubectl get svc root-ingress-controller -n tenant-root -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
if ! curl -sS -k "https://${ingress_ip}" -H 'Host: grafana.example.org' --max-time 30 | grep -q Found; then
echo "Failed to access Grafana via ingress at ${ingress_ip}" >&2
exit 1
fi
ingress_ip=$(kubectl get svc root-ingress-controller -n tenant-root -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
response=$(curl -sS -k "https://${ingress_ip}" -H 'Host: grafana.example.org' --max-time 30 -w '\n%{http_code}' 2>&1) || {
echo "Curl failed to access Grafana via ingress at ${ingress_ip}: $?" >&2
exit 1
}
if ! echo "$response" | grep -q Found; then
echo "Failed to access Grafana via ingress at ${ingress_ip}" >&2
echo "Response: $response" >&2
exit 1
fi
🤖 Prompt for AI Agents
In hack/e2e-install-cozystack.bats around lines 145 to 149, the current code
does not properly handle curl command failures which may cause false positives.
Modify the script to check the exit status of the curl command explicitly before
grepping for the expected content. If curl fails or the expected content is not
found, print the error message and exit with status 1 to ensure robust error
handling.

@lllamnyp
Timofei Larkin (lllamnyp) force-pushed the maintenance/granular-workflows branch from 87f5f83 to 11776d6 Compare June 17, 2025 08:59

@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

♻️ Duplicate comments (5)
.github/workflows/pull-requests.yaml (5)

103-108: Duplicate checkout configuration.

This checkout block is repeated from earlier jobs. Consider abstracting it via a reusable workflow or template to reduce boilerplate.


109-111: Duplicate sandbox ID setup.

Repeated SANDBOX_NAME echo logic should be centralized into a composite action or a workflow-level step for maintainability.


125-133: Repeated steps in test_apps.

The checkout and SANDBOX_NAME setup are identical to other jobs. DRY by using a composite action or a shared job template.


147-155: DRY duty: Cleanup setup duplication.

The checkout and SANDBOX_NAME steps in the cleanup job mirror earlier jobs. Abstract these into a shared action or job template to avoid repetition.


156-157: Fix incorrect step name in cleanup job.

The step E2E Apps actually deletes the sandbox. Rename to Cleanup sandbox or Delete sandbox to accurately reflect its function.

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

59-67: Inconsistent job naming convention.

The job key prepare_env uses snake_case, while Makefile targets and other jobs lean towards kebab-case (e.g., install-cozystack). Consider renaming the job key to prepare-env for consistency.


69-74: DRY duty: Duplicate checkout steps.

The checkout block here is identical in every job. Extracting it into a reusable workflow/composite action or a YAML anchor can reduce duplication and maintenance overhead.


87-89: DRY duty: Sandbox ID generation duplication.

The SANDBOX_NAME computation is repeated in multiple jobs. Encapsulate this in a composite action or set it once as a workflow output to centralize the logic.


93-101: Job naming consistency.

The job key install_cozystack uses snake_case, whereas the Makefile target is install-cozystack. Align the job key to install-cozystack to match your naming convention.


115-123: test_apps job naming.

Similar to other jobs, the key test_apps uses snake_case. For consistency with targets (test-apps), consider renaming it to test-apps.


134-136: Step name clarity.

- name: E2E Apps is vague. Rename to Test managed applications to clearly describe the step’s purpose.


137-145: Cleanup job naming consistency.

The job key cleanup is minimal; consider renaming it to cleanup-environment or destroy-sandbox for self-documenting clarity.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 87f5f83 and 11776d6.

📒 Files selected for processing (5)
  • .github/workflows/pull-requests.yaml (3 hunks)
  • Makefile (1 hunks)
  • hack/e2e-install-cozystack.bats (1 hunks)
  • hack/e2e-prepare-cluster.bats (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • Makefile
  • packages/core/testing/Makefile
  • hack/e2e-prepare-cluster.bats
  • hack/e2e-install-cozystack.bats
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (2)
.github/workflows/pull-requests.yaml (2)

112-114: Validate Makefile path and target.

Confirm that packages/core/testing contains the install-cozystack target and that the path hasn't changed. Example check:

rg -n 'install-cozystack' -n packages/core/testing/Makefile

90-92: Verify prepare-env target existence.

Ensure the root Makefile has a prepare-env target and that it orchestrates the cluster setup correctly. You can run:

rg -n '^prepare-env:' Makefile

@lllamnyp
Timofei Larkin (lllamnyp) force-pushed the maintenance/granular-workflows branch from 11776d6 to a13254d Compare June 17, 2025 09:37

@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: 5

♻️ Duplicate comments (1)
hack/e2e-install-cozystack.bats (1)

145-149: Improve error handling when probing Grafana ingress
(This repeats the earlier feedback on the same lines.)
The current check ignores curl’s exit status; a TLS/connection error yields a false “pass”.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 11776d6 and a13254d.

📒 Files selected for processing (5)
  • .github/workflows/pull-requests.yaml (3 hunks)
  • Makefile (1 hunks)
  • hack/e2e-install-cozystack.bats (1 hunks)
  • hack/e2e-prepare-cluster.bats (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • Makefile
  • packages/core/testing/Makefile
  • .github/workflows/pull-requests.yaml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (1)
hack/e2e-prepare-cluster.bats (1)

55-66: Netmask mismatch may break connectivity

The VMs are configured with /26 addresses whereas the bridge is on /24.
This places the nodes in a different broadcast domain from the host gateway (192.168.123.1/24) and can lead to ARP/route surprises.

Consider using the same /24 everywhere, or—if /26 is required—give the bridge an address inside that /26 and add an explicit route instead of relying on L2 discovery.

Comment on lines +118 to +120
@test "Wait until Talos API port 50000 is reachable on all machines" {
timeout 60 sh -ec 'until nc -nz 192.168.123.11 50000 && nc -nz 192.168.123.12 50000 && nc -nz 192.168.123.13 50000; do sleep 1; done'
}

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

60 s may be too short for Talos boot

Talos often needs >60 s to bring up its API, especially on freshly-provisioned disks.
Increasing the timeout to 180 s (or making it configurable) will reduce flakiness.

🤖 Prompt for AI Agents
In hack/e2e-prepare-cluster.bats around lines 118 to 120, the timeout for
waiting until Talos API port 50000 is reachable on all machines is set to 60
seconds, which may be too short and cause flakiness. Increase the timeout value
from 60 to 180 seconds or make the timeout configurable to allow more time for
Talos to fully boot and bring up its API.

Comment on lines +28 to +31
@test "Clean previous VMs" {
kill $(cat srv1/qemu.pid srv2/qemu.pid srv3/qemu.pid 2>/dev/null) 2>/dev/null || true
rm -rf srv1 srv2 srv3
}

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

Avoid invoking kill with an empty PID list

When no *.pid files exist (first run or already cleaned up) cat expands to an empty string, so kill is called without arguments and prints usage/help.
It exits with a non-zero status which, under set -e (used by Bats internally), would abort the test.

- kill $(cat srv1/qemu.pid srv2/qemu.pid srv3/qemu.pid 2>/dev/null) 2>/dev/null || true
+find srv{1..3} -name qemu.pid -exec cat {} + 2>/dev/null | \
+  xargs -r kill 2>/dev/null || true
🤖 Prompt for AI Agents
In hack/e2e-prepare-cluster.bats around lines 28 to 31, the kill command is
called with potentially empty PID input, causing it to fail and abort the test
under set -e. Modify the script to first check if the PID files exist and
contain PIDs before calling kill, ensuring kill is only invoked with valid
non-empty PID arguments to prevent errors.

Comment on lines +223 to +228
timeout 10 sh -ec 'until talosctl bootstrap -n 192.168.123.11 -e 192.168.123.11; do sleep 1; done'

# Wait until etcd is healthy
timeout 180 sh -ec 'until talosctl etcd members -n 192.168.123.11,192.168.123.12,192.168.123.13 -e 192.168.123.10 >/dev/null 2>&1; do sleep 1; done'
timeout 60 sh -ec 'while talosctl etcd members -n 192.168.123.11,192.168.123.12,192.168.123.13 -e 192.168.123.10 2>&1 | grep -q "rpc error"; do sleep 1; done'

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.

⚠️ Potential issue

timeout 10 is insufficient for etcd bootstrap

The first talosctl bootstrap frequently takes tens of seconds; a hard 10-second cut-off will yield false negatives.

-timeout 10 sh -ec 'until talosctl bootstrap ...
+timeout 120 sh -ec 'until talosctl bootstrap ...
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
timeout 10 sh -ec 'until talosctl bootstrap -n 192.168.123.11 -e 192.168.123.11; do sleep 1; done'
# Wait until etcd is healthy
timeout 180 sh -ec 'until talosctl etcd members -n 192.168.123.11,192.168.123.12,192.168.123.13 -e 192.168.123.10 >/dev/null 2>&1; do sleep 1; done'
timeout 60 sh -ec 'while talosctl etcd members -n 192.168.123.11,192.168.123.12,192.168.123.13 -e 192.168.123.10 2>&1 | grep -q "rpc error"; do sleep 1; done'
timeout 120 sh -ec 'until talosctl bootstrap -n 192.168.123.11 -e 192.168.123.11; do sleep 1; done'
# Wait until etcd is healthy
timeout 180 sh -ec 'until talosctl etcd members -n 192.168.123.11,192.168.123.12,192.168.123.13 -e 192.168.123.10 >/dev/null 2>&1; do sleep 1; done'
timeout 60 sh -ec 'while talosctl etcd members -n 192.168.123.11,192.168.123.12,192.168.123.13 -e 192.168.123.10 2>&1 | grep -q "rpc error"; do sleep 1; done'
🤖 Prompt for AI Agents
In hack/e2e-prepare-cluster.bats around lines 223 to 228, the timeout for the
talosctl bootstrap command is set to 10 seconds, which is too short and causes
false negatives. Increase the timeout value to a longer duration, such as 60
seconds or more, to allow enough time for the bootstrap process to complete
successfully before timing out.

Comment on lines +103 to +112
@test "Boot QEMU VMs" {
for i in 1 2 3; do
qemu-system-x86_64 -machine type=pc,accel=kvm -cpu host -smp 8 -m 24576 \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:5${i} \
-netdev tap,id=net0,ifname=cozy-srv${i},script=no,downscript=no \
-drive file=srv${i}/system.img,if=virtio,format=raw \
-drive file=srv${i}/seed.img,if=virtio,format=raw \
-drive file=srv${i}/data.img,if=virtio,format=raw \
-display none -daemonize -pidfile srv${i}/qemu.pid
done

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.

⚠️ Potential issue

Resource demand is unrealistic for CI runners

Spawning three QEMU VMs each with 8 vCPUs and 24 GiB RAM (total ≈ 72 GiB RAM / 24 vCPU) will exhaust most hosted runners and even many self-hosted workers, causing the job to be OOM-killed.

-    qemu-system-x86_64 -machine type=pc,accel=kvm -cpu host -smp 8 -m 24576 \
+    # Use modest defaults suitable for CI
+    qemu-system-x86_64 -machine type=pc,accel=kvm -cpu host -smp 2 -m 4096 \

Tune the numbers—or make them configurable via environment variables—to fit typical CI hardware.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@test "Boot QEMU VMs" {
for i in 1 2 3; do
qemu-system-x86_64 -machine type=pc,accel=kvm -cpu host -smp 8 -m 24576 \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:5${i} \
-netdev tap,id=net0,ifname=cozy-srv${i},script=no,downscript=no \
-drive file=srv${i}/system.img,if=virtio,format=raw \
-drive file=srv${i}/seed.img,if=virtio,format=raw \
-drive file=srv${i}/data.img,if=virtio,format=raw \
-display none -daemonize -pidfile srv${i}/qemu.pid
done
@test "Boot QEMU VMs" {
for i in 1 2 3; do
# Use modest defaults suitable for CI
qemu-system-x86_64 -machine type=pc,accel=kvm -cpu host -smp 2 -m 4096 \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:5${i} \
-netdev tap,id=net0,ifname=cozy-srv${i},script=no,downscript=no \
-drive file=srv${i}/system.img,if=virtio,format=raw \
-drive file=srv${i}/seed.img,if=virtio,format=raw \
-drive file=srv${i}/data.img,if=virtio,format=raw \
-display none -daemonize -pidfile srv${i}/qemu.pid
done
}
🤖 Prompt for AI Agents
In hack/e2e-prepare-cluster.bats around lines 103 to 112, the test spawns three
QEMU VMs each with 8 vCPUs and 24 GiB RAM, which is too resource-intensive for
typical CI runners. Modify the script to reduce the number of vCPUs and RAM per
VM to more reasonable defaults, or better, make these values configurable
through environment variables so they can be adjusted based on the CI
environment's capacity.

Comment on lines +20 to +21
kubectl wait deployment/cozystack -n cozy-system --timeout=1m --for=condition=Available

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

Give the installer more breathing room

kubectl wait … --timeout=1m is tight for an image pull + pod start on a fresh cluster.
Bumping to 5 min (or parameterising) will avoid avoidable failures.

🤖 Prompt for AI Agents
In hack/e2e-install-cozystack.bats around lines 20 to 21, the kubectl wait
command uses a 1 minute timeout which is too short for image pulling and pod
startup on a fresh cluster. Increase the --timeout value to 5 minutes or make it
configurable via a parameter to give the installer more time and prevent
unnecessary failures.

@lllamnyp
Timofei Larkin (lllamnyp) force-pushed the maintenance/granular-workflows branch from a13254d to 146c4aa Compare June 17, 2025 10:57

@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: 1

♻️ Duplicate comments (1)
.github/workflows/pull-requests.yaml (1)

156-157: Fix incorrect step name in cleanup job
The step E2E Apps actually deletes resources. Rename it to Cleanup sandbox or Delete environment for accuracy.

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

90-92: Clarify step naming to avoid confusion
The Prepare environment step name is identical to the job name. Rename the step to something like Run prepare-env Makefile target to distinguish the action in the logs.


87-92: Extract sandbox ID calculation into a reusable action or job output
Lines 87–92 duplicate the logic for computing and exporting SANDBOX_NAME. To DRY up the workflow, consider moving this into a composite action or computing it once in prepare_env and passing it via jobs.prepare_env.outputs.


93-113: Consolidate repetitive setup steps
The install_cozystack job (lines 93–113) repeats the checkout and sandbox‐ID setup from prepare_env. You could streamline this by using needs.prepare_env.outputs.SANDBOX_NAME and defining a reusable workflow or composite action for checkout + env setup.


134-136: Align step name with action
In test_apps, the step is named E2E Apps but runs make test-apps. For clarity, rename it to Run test-apps Makefile target or E2E application tests.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a13254d and 146c4aa.

📒 Files selected for processing (6)
  • .github/workflows/pull-requests.yaml (3 hunks)
  • Makefile (1 hunks)
  • hack/e2e-apps.bats (0 hunks)
  • hack/e2e-install-cozystack.bats (1 hunks)
  • hack/e2e-prepare-cluster.bats (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
💤 Files with no reviewable changes (1)
  • hack/e2e-apps.bats
🚧 Files skipped from review as they are similar to previous changes (4)
  • Makefile
  • packages/core/testing/Makefile
  • hack/e2e-prepare-cluster.bats
  • hack/e2e-install-cozystack.bats
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build

Comment on lines +137 to +145
cleanup:
name: Tear down environment
runs-on: [self-hosted]
needs: test_apps

# Never run when the PR carries the "release" label.
if: |
!contains(github.event.pull_request.labels.*.name, 'release')

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.

⚠️ Potential issue

Ensure teardown runs on failures
Currently cleanup only runs if test_apps succeeds, which can leak sandboxes on failures. Wrap the condition with always() to guarantee execution:

-  needs: test_apps
-  if: |
-    !contains(github.event.pull_request.labels.*.name, 'release')
+  needs: test_apps
+  if: ${{ always() && !contains(github.event.pull_request.labels.*.name, 'release') }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cleanup:
name: Tear down environment
runs-on: [self-hosted]
needs: test_apps
# Never run when the PR carries the "release" label.
if: |
!contains(github.event.pull_request.labels.*.name, 'release')
cleanup:
name: Tear down environment
runs-on: [self-hosted]
needs: test_apps
# Never run when the PR carries the "release" label.
if: ${{ always() && !contains(github.event.pull_request.labels.*.name, 'release') }}
🤖 Prompt for AI Agents
In .github/workflows/pull-requests.yaml around lines 137 to 145, the cleanup job
only runs if the test_apps job succeeds, which can cause resource leaks on
failures. Modify the condition to wrap it with always() so that the cleanup step
runs regardless of the test_apps job outcome, ensuring teardown always executes
even on failures.

@lllamnyp
Timofei Larkin (lllamnyp) force-pushed the maintenance/granular-workflows branch from 146c4aa to de99474 Compare June 17, 2025 11:45

@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

♻️ Duplicate comments (4)
hack/e2e-prepare-cluster.bats (4)

29-30: Still risks kill with an empty PID list – previous feedback unaddressed
Invoking kill $(cat …) when no PID files exist expands to an empty argument list, causing kill to exit with usage and — under Bats’ set -e semantics — terminate the test early.

- kill $(cat srv1/qemu.pid srv2/qemu.pid srv3/qemu.pid 2>/dev/null) 2>/dev/null || true
+find srv{1..3} -name qemu.pid -exec cat {} + 2>/dev/null | \
+  xargs -r kill 2>/dev/null || true

105-111: QEMU sizing will OOM typical CI runners
Spawning 3 VMs with -smp 8 -m 24576 (≈ 72 GiB RAM / 24 vCPU total) is far beyond what GitHub-hosted or most self-hosted runners provide, and will be killed by the kernel. Make vCPU/RAM configurable via env vars, defaulting to something modest (e.g. 2 vCPU / 4 GiB).

-    qemu-system-x86_64 -machine type=pc,accel=kvm -cpu host -smp 8 -m 24576 \
+    qemu-system-x86_64 -machine type=pc,accel=kvm -cpu host \
+      -smp "${QEMU_VCPUS:-2}" -m "${QEMU_RAM_MB:-4096}" \

118-120: 60 s is too short for Talos API to come up – expect flaky failures
Talos frequently needs > 60 s on fresh images. Prior review suggested 180 s or making it tunable; please adjust.

-timeout 60 sh -ec 'until nc -nz 192.168.123.11 50000 && nc -nz 192.168.123.12 50000 && nc -nz 192.168.123.13 50000; do sleep 1; done'
+timeout "${TALOS_API_TIMEOUT:-180}" sh -ec 'until nc -nz 192.168.123.11 50000 && nc -nz 192.168.123.12 50000 && nc -nz 192.168.123.13 50000; do sleep 1; done'

223-224: timeout 10 for talosctl bootstrap is almost guaranteed to fail
Real-world bootstrap regularly takes tens of seconds. Increase to ≥ 60 s or parameterise.

-timeout 10 sh -ec 'until talosctl bootstrap -n 192.168.123.11 -e 192.168.123.11; do sleep 1; done'
+timeout "${TALOS_BOOTSTRAP_TIMEOUT:-120}" sh -ec 'until talosctl bootstrap -n 192.168.123.11 -e 192.168.123.11; do sleep 1; done'
🧹 Nitpick comments (1)
hack/e2e-prepare-cluster.bats (1)

201-205: Secrets file may be stale between runs
Keeping secrets.yaml on disk and re-using it across consecutive CI invocations risks mismatching cluster secrets after a failed/aborted run. Consider generating it every time (or at least wiping it during “Clean previous VMs”).

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 146c4aa and de99474.

📒 Files selected for processing (6)
  • .github/workflows/pull-requests.yaml (3 hunks)
  • Makefile (1 hunks)
  • hack/e2e-apps.bats (8 hunks)
  • hack/e2e-install-cozystack.bats (1 hunks)
  • hack/e2e-prepare-cluster.bats (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • Makefile
  • hack/e2e-apps.bats
  • hack/e2e-install-cozystack.bats
  • .github/workflows/pull-requests.yaml
  • packages/core/testing/Makefile
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build

@lllamnyp
Timofei Larkin (lllamnyp) force-pushed the maintenance/granular-workflows branch 2 times, most recently from 9ab82bd to 211f054 Compare June 17, 2025 14:34
@coderabbitai

coderabbitai Bot commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/cozystack/cozystack/issues/comments/2979411996","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.2 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- walkthrough_start -->\n\n## Walkthrough\n\nThis change refactors the pull request workflow by splitting a single test job into a multi-stage pipeline with explicit environment preparation, installation, testing, and cleanup phases. It introduces granular Makefile targets and new BATS scripts for end-to-end cluster and platform setup, integrating them into the CI process for improved modularity.\n\n## Changes\n\n| File(s)                                               | Change Summary                                                                                           |\n|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| .github/workflows/pull-requests.yaml                  | Replaces single test job with sequential jobs: prepare_env, install_cozystack, test_apps, and cleanup.   |\n| Makefile                                              | Adds a new `prepare-env` target for environment setup.                                                   |\n| hack/e2e-prepare-cluster.bats, hack/e2e-install-cozystack.bats | Adds BATS scripts for Talos cluster provisioning and Cozystack installation/validation.                   |\n| packages/core/testing/Makefile                        | Adds `prepare-cluster` and `install-cozystack` targets to run new BATS scripts in sandbox containers.    |\n| hack/e2e-apps.bats                                    | Adds pre-checks before resource creation and removes PVC annotation command in VM disk test flow.        |\n\n## Sequence Diagram(s)\n\n```mermaid\nsequenceDiagram\n    participant GitHub Actions\n    participant Sandbox\n    participant QEMU VMs\n    participant Talos Cluster\n    participant Cozystack Installer\n\n    GitHub Actions->>Sandbox: Run prepare_env (Makefile: prepare-env)\n    Sandbox->>QEMU VMs: Provision Talos cluster (e2e-prepare-cluster.bats)\n    QEMU VMs->>Talos Cluster: Boot and configure nodes\n    GitHub Actions->>Sandbox: Run install_cozystack (Makefile: install-cozystack)\n    Sandbox->>Cozystack Installer: Deploy and validate Cozystack (e2e-install-cozystack.bats)\n    GitHub Actions->>Sandbox: Run test_apps\n    GitHub Actions->>Sandbox: Run cleanup\n```\n\n## Possibly related PRs\n\n- cozystack/cozystack#1048: Adds new test cases for VM Disk, VM Instance, VM, and databases in `hack/e2e-apps.bats`, complementing the pre-check enhancements here.  \n- cozystack/cozystack#982: Modularizes end-to-end testing with BATS scripts and Makefile targets, related to the testing infrastructure changes in this PR.  \n- cozystack/cozystack#750: Refactors GitHub Actions workflow into multiple jobs, related at the workflow file level but not overlapping job definitions.\n\n## Suggested labels\n\n`ok-to-test`\n\n## Suggested reviewers\n\n- klinch0\n\n## Poem\n\n> In the warren of CI, new tunnels appear,  \n> Each job hops forward, with steps crystal clear.  \n> From clusters prepared to stacks installed tight,  \n> BATS scripts now test through the day and the night.  \n> With Makefile magic and YAML anew,  \n> This rabbit says, “Bravo! The pipeline just grew!” 🐇✨\n\n<!-- walkthrough_end -->\n<!-- internal state start -->\n\n\n<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbG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2ftvsCBbv0BUcQBhZLt8cUcR5oDoQDAoc7DXsCAKd9DoRK1K3Ls7BEcaeQwbsegehoAeiQdDtLsqDoQGgCBPs9CicegCAkekfwegcegYdTs7DkdWdgf4c9CudwemeSf4ddA7A9DweHtrufAq0IdLsDCscehEcCBLvKdK1TuscqAMdJeUcNuXuSfNu4CttIodtKXdu0D+LidpRAA= -->\n\n<!-- internal state end -->\n<!-- finishing_touch_checkbox_start -->\n\n<details open=\"true\">\n<summary>✨ Finishing Touches</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> 📝 Generate Docstrings\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n<!-- tips_start -->\n\n---\n\nThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n<details>\n<summary>🪧 Tips</summary>\n\n### Chat\n\nThere are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=cozystack/cozystack&utm_content=1075):\n\n- Review comments: Directly reply to a review comment made by CodeRabbit. Example:\n  - `I pushed a fix in commit <commit_id>, please review it.`\n  - `Explain this complex logic.`\n  - `Open a follow-up GitHub issue for this discussion.`\n- 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:\n  - `@coderabbitai explain this code block.`\n  -\t`@coderabbitai modularize this function.`\n- 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:\n  - `@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.`\n  - `@coderabbitai read src/utils.ts and explain its main purpose.`\n  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`\n  - `@coderabbitai help me debug CodeRabbit configuration file.`\n\n### Support\n\nNeed help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.\n\nNote: 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.\n\n### CodeRabbit Commands (Invoked using PR comments)\n\n- `@coderabbitai pause` to pause the reviews on a PR.\n- `@coderabbitai resume` to resume the paused reviews.\n- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.\n- `@coderabbitai full review` to do a full review from scratch and review all the files again.\n- `@coderabbitai summary` to regenerate the summary of the PR.\n- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.\n- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.\n- `@coderabbitai resolve` resolve all the CodeRabbit review comments.\n- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.\n- `@coderabbitai help` to get help.\n\n### Other keywords and placeholders\n\n- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.\n- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.\n- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.\n\n### CodeRabbit Configuration File (`.coderabbit.yaml`)\n\n- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.\n- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.\n- 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`\n\n### Documentation and Community\n\n- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.\n- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.\n- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.\n\n</details>\n\n<!-- tips_end -->"},"request":{"retryCount":3,"retries":3,"retryAfter":16}},"cause":{}}

@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

♻️ Duplicate comments (4)
hack/e2e-prepare-cluster.bats (4)

29-30: Still risks aborting the run when no PID files exist
Earlier feedback pointed out that invoking kill $(cat …) with an empty expansion causes kill to exit 1 under set -e, aborting the test. The exact line is unchanged, so the issue persists.


103-111: Per-VM 8 vCPU / 24 GiB exceeds most CI runners
Spawning three VMs with -smp 8 -m 24576 (≈ 72 GiB RAM, 24 vCPU in total) will OOM-kill or throttle on typical GitHub/self-hosted runners. Please down-size or make values overridable (e.g. VM_CPUS, VM_RAM).


118-120: 60 s Talos-API probe is still too aggressive
Talos frequently needs > 60 s to bring up port 50000 on fresh disks. Previous review suggested 180 s or a configurable timeout; unchanged here.


223-223: 10-second bootstrap timeout causes false negatives
talosctl bootstrap often exceeds 10 s; prior comment recommended ≥ 120 s.

🧹 Nitpick comments (3)
hack/e2e-prepare-cluster.bats (1)

94-101: Add teardown for tap devices / bridge
The script creates tap interfaces and a bridge but never removes them. Subsequent CI jobs on the same runner can fail with “device exists”. Consider a final Bats test (or a trap) that deletes cozy-srv* and cozy-br0.

+@test "Cleanup networking" {
+  for i in 1 2 3; do
+    ip link del cozy-srv${i} 2>/dev/null || true
+  done
+  ip link del cozy-br0 2>/dev/null || true
+}
hack/e2e-apps.bats (2)

8-9: Consider extracting a helper for “create-if-absent” pattern
The kubectl get … || kubectl create -f - <<EOF idiom is duplicated in every test. A small shell helper (e.g. ensure_resource()) would reduce noise and make future maintenance easier.


119-120: Alias dv may not exist on minimal kubectl installs
kubectl wait dv … relies on the short-name dv for datavolumes.cdi.kubevirt.io. Short-names are cluster-registered and can be absent. Using the fully-qualified kind avoids portability issues:

-  kubectl -n tenant-test wait dv vm-disk-$name --timeout=150s --for=condition=ready
+  kubectl -n tenant-test wait datavolume.cdi.kubevirt.io/v1alpha1 vm-disk-$name --timeout=150s --for=condition=ready
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ab82bd and 211f054.

📒 Files selected for processing (6)
  • .github/workflows/pull-requests.yaml (3 hunks)
  • Makefile (1 hunks)
  • hack/e2e-apps.bats (9 hunks)
  • hack/e2e-install-cozystack.bats (1 hunks)
  • hack/e2e-prepare-cluster.bats (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • Makefile
  • packages/core/testing/Makefile
  • .github/workflows/pull-requests.yaml
  • hack/e2e-install-cozystack.bats
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build

This patch separates the Test job of the PR workflow into several
smaller jobs: 1) create a testing sandbox and deploy Talos, 2) install
Cozystack and configure it, 3) install managed applications and run e2e
tests. This lets developers shorten the feedback loop if tests are
merely acting flaky and aren't really broken. It's not the right way,
but it's 80/20.

Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
@lllamnyp
Timofei Larkin (lllamnyp) force-pushed the maintenance/granular-workflows branch from 211f054 to 746641e Compare June 17, 2025 15:47

@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

🧹 Nitpick comments (2)
hack/e2e-apps.bats (2)

8-9: Silence noisy existence-check output

kubectl get prints the full resource when it succeeds, which clutters CI logs and makes troubleshooting harder. Redirect the output to /dev/null (and stderr as well) while still relying on the exit-code for the existence check.

-kubectl -n tenant-root get tenants.apps.cozystack.io test ||
+kubectl -n tenant-root get tenants.apps.cozystack.io test >/dev/null 2>&1 ||

Apply the same redirection for every other kubectl … get … || kubectl create … pair shown in the listed lines.

Also applies to: 29-30, 102-103, 126-127, 171-172, 219-220, 270-271, 316-317


118-120: Timeouts are unbalanced: DataVolume waits 150 s, HelmRelease only 5 s

hr vm-disk-$name often takes longer than 5 s before the DV starts; occasional flakes are still observed.
Consider raising the HelmRelease wait to match the new DV timeout (e.g. 60 s) or polling until both are ready in a single loop to avoid false negatives.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ab82bd and 746641e.

📒 Files selected for processing (6)
  • .github/workflows/pull-requests.yaml (3 hunks)
  • Makefile (1 hunks)
  • hack/e2e-apps.bats (9 hunks)
  • hack/e2e-install-cozystack.bats (1 hunks)
  • hack/e2e-prepare-cluster.bats (1 hunks)
  • packages/core/testing/Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/core/testing/Makefile
  • Makefile
  • .github/workflows/pull-requests.yaml
  • hack/e2e-install-cozystack.bats
  • hack/e2e-prepare-cluster.bats
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build

Comment thread hack/e2e-apps.bats
Comment on lines +97 to 98
kubectl -n tenant-test delete kuberneteses.apps.cozystack.io test
}

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

Ensure resources are fully removed before the next test step

Immediate deletion commands return as soon as the request is accepted, not when the resource is actually gone.
If the subsequent test (or Bats teardown) re-creates the same name, a race condition is possible and has bitten us in previous runs.

-kubectl -n tenant-test delete kuberneteses.apps.cozystack.io test
+kubectl -n tenant-test delete kuberneteses.apps.cozystack.io test --wait=true --timeout=2m

Repeating the --wait=true --timeout=<...> (or a kubectl wait --for=delete …) for every delete in the lines above will make the script safer and more deterministic.

Also applies to: 165-166, 213-214, 265-266, 311-312

🤖 Prompt for AI Agents
In hack/e2e-apps.bats around lines 97 to 98, the kubectl delete command does not
wait for the resource to be fully removed, risking race conditions in subsequent
test steps. Modify the delete commands to include the --wait=true and
--timeout=<duration> flags or use kubectl wait --for=delete to ensure the
resource is completely deleted before proceeding. Apply the same fix to the
delete commands at lines 165-166, 213-214, 265-266, and 311-312 for consistent
and reliable test execution.

Comment thread hack/e2e-apps.bats
Comment on lines +347 to +352
timeout 180 sh -ec "until kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '8123 9000'; do sleep 10; done"
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-0 --timeout=120s --for=jsonpath='{.status.replicas}'=1
timeout 80 sh -ec "until kubectl -n tenant-test get endpoints chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
timeout 100 sh -ec "until kubectl -n tenant-test get svc chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.spec.ports[0].port}' | grep -q '9000 8123 9009'; do sleep 10; done"
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.replicas}'=2
timeout 100 sh -ec "until kubectl -n tenant-test get svc chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.spec.ports[*].port}' | grep -q '9000 8123 9009'; do sleep 10; done"
timeout 80 sh -ec "until kubectl -n tenant-test get sts chi-clickhouse-$name-clickhouse-0-1 ; do sleep 10; done"
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.replicas}'=1

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.

⚠️ Potential issue

Fragile ClickHouse readiness checks

  1. grep -q '8123 9000' assumes the ports appear in that exact order with a single space separator.
    Different JSONPath output or extra spaces break the test.

  2. Waiting for jsonpath='{.status.replicas}'=1 only guarantees the StatefulSet desires one replica, not that it is running or ready. Use readyReplicas.

-timeout 180 sh -ec "until kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '8123 9000'; do sleep 10; done"
+timeout 180 sh -ec "until kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '8123' && kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '9000'; do sleep 10; done"
@@
-kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-0 --timeout=120s --for=jsonpath='{.status.replicas}'=1
+kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-0 --timeout=120s --for=jsonpath='{.status.readyReplicas}'=1
@@
-kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.replicas}'=1
+kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.readyReplicas}'=1

These tweaks make the check order-insensitive and validate that the pods are actually up.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
timeout 180 sh -ec "until kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '8123 9000'; do sleep 10; done"
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-0 --timeout=120s --for=jsonpath='{.status.replicas}'=1
timeout 80 sh -ec "until kubectl -n tenant-test get endpoints chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
timeout 100 sh -ec "until kubectl -n tenant-test get svc chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.spec.ports[0].port}' | grep -q '9000 8123 9009'; do sleep 10; done"
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.replicas}'=2
timeout 100 sh -ec "until kubectl -n tenant-test get svc chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.spec.ports[*].port}' | grep -q '9000 8123 9009'; do sleep 10; done"
timeout 80 sh -ec "until kubectl -n tenant-test get sts chi-clickhouse-$name-clickhouse-0-1 ; do sleep 10; done"
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.replicas}'=1
timeout 180 sh -ec "until kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '8123' && kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '9000'; do sleep 10; done"
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-0 --timeout=120s --for=jsonpath='{.status.readyReplicas}'=1
timeout 80 sh -ec "until kubectl -n tenant-test get endpoints chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
timeout 100 sh -ec "until kubectl -n tenant-test get svc chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.spec.ports[*].port}' | grep -q '9000 8123 9009'; do sleep 10; done"
timeout 80 sh -ec "until kubectl -n tenant-test get sts chi-clickhouse-$name-clickhouse-0-1 ; do sleep 10; done"
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.readyReplicas}'=1
🤖 Prompt for AI Agents
In hack/e2e-apps.bats around lines 347 to 352, the readiness checks for
ClickHouse services are fragile because they rely on exact port order and
spacing in grep and only check desired replicas instead of ready replicas. To
fix this, modify the grep commands to be order-insensitive by matching ports
individually or using a regex that allows any order and spacing. Also, replace
the wait condition from checking jsonpath='{.status.replicas}'=1 to
jsonpath='{.status.readyReplicas}'=1 to ensure the StatefulSet pods are actually
running and ready.

@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

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