Skip to content

Re-run acceptance CA cert; move condition to main task#217

Merged
praveenkumar merged 1 commit into
crc-org:mainfrom
danpawlik:retry-command
Feb 26, 2026
Merged

Re-run acceptance CA cert; move condition to main task#217
praveenkumar merged 1 commit into
crc-org:mainfrom
danpawlik:retry-command

Conversation

@danpawlik

@danpawlik danpawlik commented Feb 25, 2026

Copy link
Copy Markdown
Collaborator

It happens, that the command for accepting cert require to be executed
few times and until cron job is not created, something needs to accept
the cert.
Also move condition to main task, because the tasks should be only
executed when variable 'ca_cert_approver' is true.

Summary by CodeRabbit

  • Refactoring
    • Streamlined certificate approval to batch-process pending CSRs, reducing repetitive per-item operations and simplifying flow.
    • Added a configuration-driven guard to enable or disable the certificate approval step, giving deployments conditional control over when approvals run.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Replaces per-item CSR approval with a batched shell task that lists Pending CSRs and pipes their names to oc adm certificate approve via xargs, and applies cluster-cert-approver.yaml. The include of the accept task in main.yaml is now conditional on ca_cert_approver | bool.

Changes

Cohort / File(s) Summary
CSR Approval Task
ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml
Removed per-item conditional approval loop; added a single shell task that lists Pending CSRs and pipes names to oc adm certificate approve via xargs, run with retries/delay. Simplified manifest copy/apply flow for cluster-cert-approver.yaml.
Task include guard
ansible/roles/deploy-crc-cloud/tasks/main.yaml
Accept certificate include changed to run only when `ca_cert_approver

Sequence Diagram(s)

sequenceDiagram
    participant Ansible
    participant Shell
    participant OC_CLI as "oc CLI"
    participant KubeAPI as "Kubernetes API"

    Ansible->>Shell: run shell task to list Pending CSRs
    Shell->>OC_CLI: pass CSR names via xargs to approve
    OC_CLI->>KubeAPI: POST approvals for CSRs
    KubeAPI-->>OC_CLI: return approval responses
    OC_CLI-->>Shell: exit status
    alt non-zero exit (retryable)
        Shell-->>Ansible: failure
        Ansible->>Shell: retry after delay (up to N times)
    else zero exit
        Shell-->>Ansible: success
        Ansible->>OC_CLI: apply /tmp/cluster-cert-approver.yaml
        OC_CLI->>KubeAPI: create/apply resources
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • adrianriobo
  • praveenkumar

Poem

🐇 I nudged the pending CSRs in line,
Piped names through xargs, made approvals fine.
Three tries, ten seconds, then a cheerful apply,
A tiny hop, a certs-approved sky. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the two main changes: adding retry logic for CA certificate acceptance and moving the conditional guard from accept_cert.yaml to the main.yaml task include.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml`:
- Around line 22-24: The task currently uses an impossible retry condition
"until: false" which makes it always fail; change the task to register its
command result (e.g., add "register: accept_result") and replace "until: false"
with a check on that register such as "until: accept_result.rc == 0" (or a
specific stdout check like "until: "'approved' in accept_result.stdout" if you
expect text); ensure the task keeps "retries" and "delay" so it will retry until
the registered condition becomes true.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fba62c and f934ad5.

📒 Files selected for processing (1)
  • ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml

Comment thread ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml Outdated
@danpawlik danpawlik force-pushed the retry-command branch 3 times, most recently from abe0a58 to 03cfbed Compare February 25, 2026 17:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml`:
- Around line 2-9: The loop that runs the shell task which approves Pending CSRs
(the task starting "Re-run accept certificates in Pending state few times") will
stop on the first failure and skip further iterations; update the task to either
add "ignore_errors: true" and "changed_when: false" so all three iterations run
regardless of non-zero exit codes and approvals are treated idempotently, or
replace the loop-based retry with Ansible's retry idiom (use retries/delay/until
on the oc get/oc adm approve command) to implement true retry semantics.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 358278a and 03cfbed.

📒 Files selected for processing (1)
  • ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml

Comment thread ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml
@danpawlik danpawlik changed the title Re-run acceptance CA cert Re-run acceptance CA cert; move condition to main task Feb 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml`:
- Around line 3-6: The shell pipeline in the ansible task (ansible.builtin.shell
executing the oc/awk/xargs sequence) can hide failures; update the task to run
under /bin/bash and enable pipefail so any command in the pipeline failing
causes the task to fail: set executable to /bin/bash (executable: /bin/bash) and
prepend/ensure "set -o pipefail" (or "set -e -o pipefail") before the oc get csr
| awk ... | xargs ... command in the ansible.builtin.shell invocation so
pipeline failures are not silently ignored.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03cfbed and 3050619.

📒 Files selected for processing (2)
  • ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml
  • ansible/roles/deploy-crc-cloud/tasks/main.yaml

Comment thread ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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)
ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml (1)

3-7: ⚠️ Potential issue | 🟠 Major

pipefail is not guaranteed under the default shell, so retries can silently do nothing.

At Line 4, set -o pipefail may fail under /bin/sh (common default), and with Line 11 ignore_errors: true, all loop iterations can be swallowed without effective CSR approval.

🔧 Proposed fix
-- name: Re-run accept certificates in Pending state few times
-  ansible.builtin.shell: >
-    set -o pipefail;
+  ansible.builtin.shell: |
+    set -o pipefail
     oc get csr --no-headers |
     awk '/Pending/ {print $1}' |
     xargs --no-run-if-empty oc adm certificate approve
+  args:
+    executable: /bin/bash
   loop: "{{ range(1, 4) | list }}"
   loop_control:
     pause: 10

Also applies to: 11-11

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml` around lines 3 - 7,
The shell task using "set -o pipefail" can silently no-op under /bin/sh and
combined with ignore_errors: true will swallow failures; update the
ansible.builtin.shell task in accept_cert.yaml to run under bash by adding
executable: /bin/bash (or change the command to a bash -c wrapper) so set -o
pipefail is honored, and remove or tighten the ignore_errors setting (or add a
proper failure check after the oc adm certificate approve pipeline) to ensure
failed approvals are detected and cause the task to fail.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml`:
- Around line 23-25: The retry exit condition is currently checking for any
non-1 return code which will stop retries on unexpected failures; change the
until condition that references the registered result (_cert_approver) from
"until: _cert_approver.rc != 1" to a success check "until: _cert_approver.rc ==
0" so the task keeps retrying until the command actually succeeds; update the
until line that pairs with "register: _cert_approver" (and leave retries: 60
as-is unless you want to adjust the retry count).

---

Duplicate comments:
In `@ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml`:
- Around line 3-7: The shell task using "set -o pipefail" can silently no-op
under /bin/sh and combined with ignore_errors: true will swallow failures;
update the ansible.builtin.shell task in accept_cert.yaml to run under bash by
adding executable: /bin/bash (or change the command to a bash -c wrapper) so set
-o pipefail is honored, and remove or tighten the ignore_errors setting (or add
a proper failure check after the oc adm certificate approve pipeline) to ensure
failed approvals are detected and cause the task to fail.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3050619 and 4a5b8cf.

📒 Files selected for processing (2)
  • ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml
  • ansible/roles/deploy-crc-cloud/tasks/main.yaml

Comment thread ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml
It happens, that the command for accepting cert require to be executed
few times and until cron job is not created, something needs to accept
the cert.
Also move condition to main task, because the tasks should be only
executed when variable 'ca_cert_approver' is true.

Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
@praveenkumar praveenkumar merged commit 7db2fd7 into crc-org:main Feb 26, 2026
4 checks passed
@danpawlik danpawlik deleted the retry-command branch February 26, 2026 10:10
rdoproject pushed a commit to rdo-infra/review.rdoproject.org-config that referenced this pull request Feb 26, 2026
It happens, that the command for accepting cert require to be executed
few times and until cron job is not created, something needs to accept
the cert.
Also move condition to main task, because the tasks should be only
executed when variable 'ca_cert_approver' is true.

Same patch was applied in crc-cloud project [1]

[1] crc-org/crc-cloud#217

Change-Id: Ie3126002f655703d5863ea770ba84e0ba92b2acf
Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
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