Skip to content

Add Azure IPI resource garbage collection periodic - #83200

Open
hlipsig wants to merge 6 commits into
openshift:mainfrom
hlipsig:hlipsig/azure-ipi-deprovision-clean
Open

Add Azure IPI resource garbage collection periodic#83200
hlipsig wants to merge 6 commits into
openshift:mainfrom
hlipsig:hlipsig/azure-ipi-deprovision-clean

Conversation

@hlipsig

@hlipsig hlipsig commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add periodic-ipi-deprovision-azure job to clean up leaked Azure IPI cluster resources, matching the existing AWS and GCP GC patterns
  • Add core-services/ipi-deprovision/azure.sh script that authenticates via cluster-secrets-azure4, discovers stale CI resource groups (ci-op-* older than 6 hours), runs openshift-install destroy cluster in parallel, and force-deletes any remaining resource groups
  • Add azure-cli to the ci_ipi-deprovision_latest container image (already has AWS CLI and GCP SDK)

Test plan

  • Verify the ipi-deprovision container image builds successfully with azure-cli added
  • Rehearse periodic-ipi-deprovision-azure job to validate script execution
  • Confirm the 6-hour TTL avoids interfering with active test runs (longest Azure jobs ~5h)
  • Verify Slack alerting to #ops-testplatform on failure

🤖 Generated with Claude Code

Summary by CodeRabbit

This PR adds periodic Azure IPI cluster garbage collection to OpenShift CI. The new job finds ci-op-* Azure resource groups older than six hours, destroys clusters in parallel, and force-deletes remaining resource groups.

The ci_ipi-deprovision_latest image now includes GPG-verified azure-cli packages. The Azure cleanup runs as a non-root user with HOME=/tmp, authenticates with cluster-secrets-azure4, and reports cleanup failures for Slack alerting.

Add periodic-ipi-deprovision-azure to clean up leaked Azure IPI
cluster resources, matching the existing AWS and GCP GC patterns.
Uses a 6-hour TTL to avoid disrupting active tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • ci-operator/jobs/infra-build-farm-periodics.yaml is excluded by !ci-operator/jobs/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 270c8650-6a22-4a6a-8f30-52be7a2ae425

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The image now installs Azure CLI with repository signature checks. The new azure.sh script authenticates with Azure, finds expired CI resource groups, destroys matching clusters concurrently, and force-deletes resources when installer cleanup fails.

Changes

Azure cluster deprovisioning

Layer / File(s) Summary
Azure runtime and cluster discovery
clusters/app.ci/ipi-deprovision/ipi-deprovision-bc.yaml, core-services/ipi-deprovision/azure.sh
The image installs GPG-verified Google Cloud and Azure CLI packages. The script authenticates with a service principal, selects the subscription, queries Azure resource groups, filters expired CI resources, and prepares installer metadata.
Concurrent cluster cleanup
core-services/ipi-deprovision/azure.sh
The script runs bounded, timed cluster destruction jobs and records success or failure markers.
Fallback deletion and reporting
core-services/ipi-deprovision/azure.sh
If installer cleanup fails, the script starts asynchronous resource-group deletion. It reports warnings and failures and exits nonzero when failures remain.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant azure_sh
  participant AzureCLI
  participant AzureResourceManager
  participant openshift_install
  azure_sh->>AzureCLI: Authenticate and select subscription
  azure_sh->>AzureResourceManager: Query paginated resource groups
  AzureResourceManager-->>azure_sh: Return expired CI resource groups
  azure_sh->>openshift_install: Destroy clusters concurrently
  openshift_install-->>azure_sh: Return cleanup status
  azure_sh->>AzureCLI: Delete resource groups after failures
  azure_sh-->>azure_sh: Report warnings and failures
Loading

Possibly related PRs

Suggested reviewers: danilo-gemoli, psalajova

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding periodic garbage collection for Azure IPI resources.
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.
Stable And Deterministic Test Names ✅ Passed The complete PR diff contains only job/configuration and shell-script changes; no Ginkgo test declarations or dynamic test titles are present.
Test Structure And Quality ✅ Passed The pull request changes only a periodic job, YAML, and a shell script; the full diff adds no Ginkgo test code or It blocks to review.
Microshift Test Compatibility ✅ Passed The pull request changes only an Azure deprovisioning shell script; no new Ginkgo tests or test declarations were added, so MicroShift compatibility checks do not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The pull request adds only Azure deprovisioning shell logic; the changed commit contains no Ginkgo e2e tests or It/Describe/Context/When constructs to assess.
Topology-Aware Scheduling Compatibility ✅ Passed The PR adds CI job and image configuration only; its sole selector is amd64, with no HA-dependent affinity, replicas, topology spread, control-plane, worker, taint, or PDB constraints.
Ote Binary Stdout Contract ✅ Passed The PR changes only YAML and azure.sh. No OTE binary, Go suite setup, or openshift-tests integration is present; shell echo output is outside this contract.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The pull request changes only Azure deprovisioning shell/YAML files and adds no Ginkgo e2e tests or test declarations requiring IPv4 or external connectivity.
No-Weak-Crypto ✅ Passed PR-added Azure script, periodic job, and image definition contain no MD5, SHA-1, DES, RC4, Blowfish, ECB, or custom crypto; comparisons do not involve secrets or tokens.
Container-Privileges ✅ Passed The Azure job sets runAsNonRoot: true and runAsUser: 65534; the PR adds no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or allowPrivilegeEscalation:true setting.
No-Sensitive-Data-In-Logs ✅ Passed Azure credential extraction and az login run with tracing disabled; logs contain only subscription, CI resource-group, region, and cluster identifiers, not passwords, tokens, or API keys.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@openshift-ci

openshift-ci Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hlipsig
Once this PR has been reviewed and has the lgtm label, please assign jmguzik for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@clusters/app.ci/ipi-deprovision/ipi-deprovision-bc.yaml`:
- Around line 50-52: Update the package-installation command in the image build
to remove the --nogpg option and retain RPM signature verification. Ensure GPG
keys are imported for every configured repository, including the Google Cloud
SDK repository and the Azure CLI repository before dnf install runs.

In `@core-services/ipi-deprovision/azure.sh`:
- Around line 100-101: Update the marker-file searches in the deprovisioning
flow around the `clusters` loop and lines 124–133 to use `${logdir}` explicitly
as the `find` start path, including when `clusters` is empty. Ensure no command
falls back to searching the current working directory, while preserving the
existing filtering and processing behavior.
- Around line 114-117: Update the fallback deletion command in the azure
deprovisioning flow to wait until the resource group deletion completes before
removing ${workdir}/failure and creating ${workdir}/warning. Remove --no-wait
from az group delete, or poll for resource group removal and only update the
markers after confirmed completion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: e8565343-1514-45e9-9f3a-006c917315b0

📥 Commits

Reviewing files that changed from the base of the PR and between 572b8d0 and 8e3905f.

⛔ Files ignored due to path filters (1)
  • ci-operator/jobs/infra-build-farm-periodics.yaml is excluded by !ci-operator/jobs/**
📒 Files selected for processing (2)
  • clusters/app.ci/ipi-deprovision/ipi-deprovision-bc.yaml
  • core-services/ipi-deprovision/azure.sh

Comment thread clusters/app.ci/ipi-deprovision/ipi-deprovision-bc.yaml Outdated
Comment thread core-services/ipi-deprovision/azure.sh
Comment thread core-services/ipi-deprovision/azure.sh Outdated
hlipsig and others added 2 commits August 10, 2026 10:35
Remove --no-wait from the fallback az group delete so the script
only marks a resource group as cleaned up after deletion completes,
avoiding false success when async deletion fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use ${logdir} instead of ${clusters} for marker-file searches to
avoid searching cwd when no clusters are found. Enable GPG signature
verification for all repos by adding gpgcheck to the Google Cloud SDK
repo config, importing both GPG keys, and removing --nogpg from dnf.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core-services/ipi-deprovision/azure.sh`:
- Around line 124-130: Update the WARNINGS and FAILED find commands to search
only marker files with -type f and print each marker’s containing cluster
directory using %h instead of %H. Preserve the existing sorting and summary
behavior, and apply the same correction to both warning and failure collection.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f715a536-58e7-4593-bdc9-42ec30ecb94c

📥 Commits

Reviewing files that changed from the base of the PR and between 8e3905f and f863ea8.

📒 Files selected for processing (2)
  • clusters/app.ci/ipi-deprovision/ipi-deprovision-bc.yaml
  • core-services/ipi-deprovision/azure.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • clusters/app.ci/ipi-deprovision/ipi-deprovision-bc.yaml

Comment thread core-services/ipi-deprovision/azure.sh Outdated
Add securityContext with runAsNonRoot and runAsUser 65534 (nobody).
None of the tools (az, openshift-install, jq) require root, and
HOME=/tmp ensures config writes go to world-writable paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hlipsig

hlipsig commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

/pj-rehearse

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

@hlipsig: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

@hlipsig

hlipsig commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

/pj-rehearse periodic-ipi-deprovision-azure

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

@hlipsig: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

@hlipsig

hlipsig commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

/retest

The warning and failure marker find commands used %H (starting-point
directory) instead of %h (containing directory), causing basename to
always print the logdir name rather than individual cluster IDs. Also
add -type f to restrict matches to regular files only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@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.

🧹 Nitpick comments (1)
core-services/ipi-deprovision/azure.sh (1)

127-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Quote WARNINGS in the here-string.

Line 127 expands WARNINGS without quotes. Use <<< "$WARNINGS" to prevent unintended shell expansion and resolve ShellCheck SC2086.

Proposed fix
-  xargs --max-args 1 basename <<< $WARNINGS
+  xargs --max-args 1 basename <<< "$WARNINGS"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@core-services/ipi-deprovision/azure.sh` at line 127, Update the here-string
in the warning-processing command around basename to quote the WARNINGS
expansion, using the existing WARNINGS variable while preventing unintended
shell expansion and satisfying ShellCheck SC2086.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@core-services/ipi-deprovision/azure.sh`:
- Line 127: Update the here-string in the warning-processing command around
basename to quote the WARNINGS expansion, using the existing WARNINGS variable
while preventing unintended shell expansion and satisfying ShellCheck SC2086.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 523edb18-254a-4f11-8bb3-6e17a4a1beea

📥 Commits

Reviewing files that changed from the base of the PR and between f863ea8 and 2e35dd9.

⛔ Files ignored due to path filters (1)
  • ci-operator/jobs/infra-build-farm-periodics.yaml is excluded by !ci-operator/jobs/**
📒 Files selected for processing (1)
  • core-services/ipi-deprovision/azure.sh

This job requires real Azure credentials and resources, so it cannot
be meaningfully rehearsed in PR context. Marking it as non-rehearsable
prevents the rehearsal system from failing on missing build history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-merge-bot openshift-merge-bot Bot added the rehearsals-ack Signifies that rehearsal jobs have been acknowledged label Aug 11, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

[REHEARSALNOTIFIER]
@hlipsig: no rehearsable tests are affected by this change

Note: If this PR includes changes to step registry files (ci-operator/step-registry/) and you expected jobs to be found, try rebasing your PR onto the base branch. This helps pj-rehearse accurately detect changes when the base branch has moved forward.

Interacting with pj-rehearse

Comment: /pj-rehearse to run up to 5 rehearsals
Comment: /pj-rehearse skip to opt-out of rehearsals
Comment: /pj-rehearse {test-name}, with each test separated by a space, to run one or more specific rehearsals
Comment: /pj-rehearse more to run up to 10 rehearsals
Comment: /pj-rehearse max to run up to 25 rehearsals
Comment: /pj-rehearse auto-ack to run up to 5 rehearsals, and add the rehearsals-ack label on success
Comment: /pj-rehearse list to get an up-to-date list of affected jobs
Comment: /pj-rehearse abort to abort all active rehearsals
Comment: /pj-rehearse network-access-allowed to allow rehearsals of tests that have the restrict_network_access field set to false. This must be executed by an openshift org member who is not the PR author

Once you are satisfied with the results of the rehearsals, comment: /pj-rehearse ack to unblock merge. When the rehearsals-ack label is present on your PR, merge will no longer be blocked by rehearsals.
If you would like the rehearsals-ack label removed, comment: /pj-rehearse reject to re-block merging.

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@hlipsig: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/rehearse/periodic-ipi-deprovision-azure 1e89d88 link unknown /pj-rehearse periodic-ipi-deprovision-azure

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rehearsals-ack Signifies that rehearsal jobs have been acknowledged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant