Skip to content

Skip cacerts distribution for clusters without product claims#106

Open
sridhargaddam wants to merge 3 commits into
stolostron:mainfrom
sridhargaddam:check-product-claims
Open

Skip cacerts distribution for clusters without product claims#106
sridhargaddam wants to merge 3 commits into
stolostron:mainfrom
sridhargaddam:check-product-claims

Conversation

@sridhargaddam

Copy link
Copy Markdown
Contributor

The operator installation code skips clusters that are
missing their product claim, but ensureCertificatesCreated
and ensureCacertsDistributed were still processing them.
This PR avoids creating certs and cacerts ManifestWorks
for clusters without the product claims.

Comment thread pkg/hub/mesh/controller.go Outdated
@mkolesnik

Copy link
Copy Markdown
Contributor

Just a note: this won't be needed if we proceed with #115

@sridhargaddam

Copy link
Copy Markdown
Contributor Author

Just a note: this won't be needed if we proceed with #115

Since its still a draft and we have not yet finalized on the approach, let me update the current PR with your suggestion.

Comment thread pkg/hub/mesh/controller.go

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

Small comment otherwise LGTM

Comment thread test/integration/controller_test.go Outdated
@sridhargaddam sridhargaddam force-pushed the check-product-claims branch from e049013 to 4861877 Compare June 11, 2026 10:44
@sridhargaddam sridhargaddam requested a review from mkolesnik June 11, 2026 11:34
@openshift-ci

openshift-ci Bot commented Jun 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mkolesnik, sridhargaddam

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [mkolesnik,sridhargaddam]

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

@sridhargaddam

Copy link
Copy Markdown
Contributor Author

/test integration

@sridhargaddam sridhargaddam force-pushed the check-product-claims branch from 4861877 to b6a010c Compare June 22, 2026 10:52
@openshift-ci openshift-ci Bot removed the lgtm label Jun 22, 2026
@openshift-ci

openshift-ci Bot commented Jun 22, 2026

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@sridhargaddam

Copy link
Copy Markdown
Contributor Author

@jewertow I had to modify an existing integration test as we cannot have a namespace greater than 63 chars. PTAL, thanks.

@sridhargaddam sridhargaddam requested a review from jewertow June 22, 2026 10:54
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 17fb86c3-5c0f-4f35-acec-027b6410c512

📥 Commits

Reviewing files that changed from the base of the PR and between a56683b and a86b26b.

📒 Files selected for processing (1)
  • test/integration/controller_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/integration/controller_test.go

📝 Walkthrough

Walkthrough

doReconcile now skips clusters without a product.open-cluster-management.io claim before logging or running cert-manager work. When cert-manager issuer configuration is present, certificate creation and cacerts ManifestWork creation happen inline per eligible cluster after the operator ManifestWork is applied. The prior post-loop batch helpers for certificates and cacerts distribution were removed. Integration tests add coverage for the no-product-claim case and a helper for asserting that a Certificate is absent.

Sequence Diagram(s)

sequenceDiagram
  participant Controller
  participant Cluster
  participant cert-manager

  Controller->>Cluster: getProductClaim
  alt product claim present
    Controller->>Cluster: apply operator ManifestWork
    Controller->>cert-manager: ensureCertificateForCluster
    Controller->>Cluster: ensureCacertsManifestWork
  else product claim missing
    Controller-->>Cluster: skip cert-manager work
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • jewertow
🚥 Pre-merge checks | ✅ 8 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning New cert-manager tests use Eventually/Consistently via helpers with no explicit timeouts, and the added expectations lack failure messages. Add explicit timeouts to the new Eventually/Consistently calls (helpers and tests) and attach descriptive failure messages to key Expect/Require assertions.
✅ Passed checks (8 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: skipping cacerts distribution for clusters without product claims.
Description check ✅ Passed The description accurately describes the issue and the fix applied in this changeset.
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 Added Ginkgo titles are static; no dynamic names, dates, UUIDs, or generated suffixes appear in test titles.
No-Weak-Crypto ✅ Passed Touched code only wires cert-manager resources/tests; no weak crypto, custom crypto, or secret/token comparisons found (only strings.Compare on cluster names).
Container-Privileges ✅ Passed No changed manifest/container specs contain privileged flags; searched all differing files and found none.
No-Sensitive-Data-In-Logs ✅ Passed Logs only include cluster/mesh/secret names and status messages; no secrets, tokens, PII, or other sensitive payloads are logged.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

The operator installation code skips clusters that are
missing their product claim, but ensureCertificatesCreated
and ensureCacertsDistributed were still processing them.
This PR avoids creating certs and cacerts ManifestWorks
for clusters without the product claims.

Signed-off-by: Sridhar Gaddam <sgaddam@redhat.com>
The existing test for Subject/URI SAN used a 74-char cluster name
without a product claim. This worked before because certificate
creation was in a separate loop that didn't check product claims.

Now that certificates are created inside the product-claim-gated
loop, the cluster needs a product claim (which also means going
through the operator ManifestWork step, which requires a namespace
matching the cluster name). Since K8s limits namespace names
to 63 characters, the original name/test-case can't work end-to-end.

This PR shortens the cluster name to 62 characters so it's valid as a
namespace, and use CreateK8sManagedCluster (which sets a product
claim and creates the namespace). The OU truncation for names
exceeding 64 characters remains covered by unit tests in
certificate_test.go.

Signed-off-by: Sridhar Gaddam <sgaddam@redhat.com>
@sridhargaddam

Copy link
Copy Markdown
Contributor Author

@mkolesnik I had to rebase this PR, can you reapprove? TIA

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

Small suggestion to make test more robust

Comment thread test/integration/controller_test.go Outdated

@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 `@test/integration/controller_test.go`:
- Around line 837-844: The `Consistently` assertion in this test relies on
default timing, so update the anonymous check around `k8sClient.List` to pass
explicit timeout and polling interval values. Keep the existing
certificate-listing logic intact, but make the wait parameters explicit in the
`Consistently` call to match the project’s Ginkgo timing guidelines and avoid
environment-dependent behavior.
🪄 Autofix (Beta)

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: Enterprise

Run ID: 74f360ac-4024-4ae9-82b3-bf97a529069c

📥 Commits

Reviewing files that changed from the base of the PR and between 17e64d7 and a56683b.

📒 Files selected for processing (1)
  • test/integration/controller_test.go

Comment thread test/integration/controller_test.go
Signed-off-by: Sridhar Gaddam <sgaddam@redhat.com>
@openshift-ci openshift-ci Bot added size/L and removed size/M labels Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants