Skip to content

CM-1038: Replace istiocsr type-specific decoders with generic DecodeObjBytes#418

Open
sebrandon1 wants to merge 1 commit into
openshift:masterfrom
sebrandon1:replace-decoders-with-generic
Open

CM-1038: Replace istiocsr type-specific decoders with generic DecodeObjBytes#418
sebrandon1 wants to merge 1 commit into
openshift:masterfrom
sebrandon1:replace-decoders-with-generic

Conversation

@sebrandon1

@sebrandon1 sebrandon1 commented May 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove 8 type-specific decode*ObjBytes functions from the istiocsr package (~95 lines) and replace all 22 call sites with the existing generic common.DecodeObjBytes[T] helper
  • Cache the ServiceAccount name at init time to avoid redundant YAML deserialization on every reconcile cycle
  • Aligns the istiocsr package with the pattern already used by the trustmanager package

Test plan

  • Unit tests pass (go test ./pkg/controller/istiocsr/...)
  • Build succeeds (go build ./pkg/controller/istiocsr/)
  • No new lint issues introduced
  • CI checks pass

Jira: https://redhat.atlassian.net/browse/CM-1038

Summary by CodeRabbit

  • Refactor
    • Unified decoding of embedded Kubernetes manifests and cert templates across the IstioCSR controller using a shared decoder for consistent resource handling.
    • Updated reconciliation for certificates, deployments, RBAC (including leases variants), services, and service accounts to use the same decode path.
    • Cached the service account name to avoid repeated parsing during reconciliation.
  • Tests
    • Updated test resource builders to use the shared decoder when creating embedded Kubernetes/RBAC/workload and certificate test objects.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 6, 2026
@openshift-ci-robot

openshift-ci-robot commented May 6, 2026

Copy link
Copy Markdown

@sebrandon1: This pull request references CM-1038 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Remove 8 type-specific decode*ObjBytes functions from the istiocsr package (~95 lines) and replace all 22 call sites with the existing generic common.DecodeObjBytes[T] helper
  • Cache the ServiceAccount name at init time to avoid redundant YAML deserialization on every reconcile cycle
  • Aligns the istiocsr package with the pattern already used by the trustmanager package

Test plan

  • Unit tests pass (go test ./pkg/controller/istiocsr/...)
  • Build succeeds (go build ./pkg/controller/istiocsr/)
  • No new lint issues introduced
  • CI checks pass

Jira: https://redhat.atlassian.net/browse/CM-1038

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented May 6, 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f59eefa2-458e-434a-8765-4e53cc5d3ebc

📥 Commits

Reviewing files that changed from the base of the PR and between 0132362 and de5454a.

📒 Files selected for processing (7)
  • pkg/controller/istiocsr/certificates.go
  • pkg/controller/istiocsr/deployments.go
  • pkg/controller/istiocsr/rbacs.go
  • pkg/controller/istiocsr/serviceaccounts.go
  • pkg/controller/istiocsr/services.go
  • pkg/controller/istiocsr/test_utils.go
  • pkg/controller/istiocsr/utils.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • pkg/controller/istiocsr/certificates.go
  • pkg/controller/istiocsr/serviceaccounts.go
  • pkg/controller/istiocsr/deployments.go
  • pkg/controller/istiocsr/services.go
  • pkg/controller/istiocsr/test_utils.go
  • pkg/controller/istiocsr/rbacs.go
  • pkg/controller/istiocsr/utils.go

Walkthrough

Replaces bespoke embedded-manifest decode helpers with common.DecodeObjBytes[T] across IstioCSR runtime and test builders, caches the ServiceAccount name during package initialization, and removes the old decode helper functions.

Changes

IstioCSR Decoding Consolidation

Layer / File(s) Summary
Caching foundation and helper removal
pkg/controller/istiocsr/utils.go
Adds assets import and cachedServiceAccountName; initializes it in init() from the embedded ServiceAccount asset; removes the local decode*ObjBytes helpers.
Runtime object decoders
pkg/controller/istiocsr/certificates.go, pkg/controller/istiocsr/deployments.go, pkg/controller/istiocsr/serviceaccounts.go, pkg/controller/istiocsr/services.go
Certificate, Deployment, ServiceAccount, and Service builders now decode embedded assets with common.DecodeObjBytes[T] using the matching scheme group/version.
RBAC decoding and cached SA use
pkg/controller/istiocsr/rbacs.go
RBAC reconciliation reads cachedServiceAccountName, and ClusterRole, ClusterRoleBinding, Role, and lease-related RBAC builders decode via common.DecodeObjBytes[T].
Test helper decoder updates
pkg/controller/istiocsr/test_utils.go
Test builders for Certificate, RBAC, Deployment, Service, and ServiceAccount switch to common.DecodeObjBytes[T] and add the shared common import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing istiocsr-specific decoders with the generic DecodeObjBytes helper.
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 PASS: No Ginkgo titles exist in pkg/controller/istiocsr tests, and no computed subtest names were found; existing names are static string literals.
Test Structure And Quality ✅ Passed No Ginkgo specs were added or changed in the touched package; tests are table-driven testing.T fakes with no cluster waits or cleanup issues.
Microshift Test Compatibility ✅ Passed The PR only refactors istiocsr unit-test helpers and controller code; no new Ginkgo e2e specs or MicroShift-unsupported APIs/features were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo/e2e specs were added; the PR only changes controller code and standard Go unit-test helpers, with no multi-node assumptions or SNO skips needed.
Topology-Aware Scheduling Compatibility ✅ Passed Only object-decoding helpers changed; deployment/affinity/nodeSelector/replica logic and embedded manifests are unchanged, so no topology-sensitive scheduling was introduced.
Ote Binary Stdout Contract ✅ Passed No stdout writes were added in init/setup code; the new init() only caches the ServiceAccount name via DecodeObjBytes, and searches found no fmt/log/klog stdout use in touched files.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PASS: The PR only changes unit-test helpers and standard t.Run tests; no new Ginkgo/e2e tests, IPv4-only parsing, or external/public connectivity were added.
No-Weak-Crypto ✅ Passed Touched files contain no weak-crypto APIs or secret comparisons; only standard x509/rand/rsa usage appears in tests and cert handling.
Container-Privileges ✅ Passed Changed files only swap decoders; no privileged fields are added. The istio-csr deployment manifest uses allowPrivilegeEscalation:false, runAsNonRoot:true, and drops ALL caps.
No-Sensitive-Data-In-Logs ✅ Passed PASS: The PR only swaps decoders/caches a SA name; touched log calls emit generic resource/namespace identifiers and no secrets, tokens, PII, or hostnames.

✏️ 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.

@openshift-ci openshift-ci Bot requested review from bharath-b-rh and mytreya-rh May 6, 2026 16:16
@openshift-ci

openshift-ci Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1
Once this PR has been reviewed and has the lgtm label, please assign bharath-b-rh 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

@sebrandon1 sebrandon1 force-pushed the replace-decoders-with-generic branch from b622911 to ee01305 Compare May 14, 2026 19:07
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1 sebrandon1 force-pushed the replace-decoders-with-generic branch from ee01305 to b251d62 Compare May 29, 2026 15:51
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1 sebrandon1 force-pushed the replace-decoders-with-generic branch from b251d62 to 0132362 Compare June 15, 2026 16:25
…bjBytes

Remove 8 type-specific decode*ObjBytes functions from the istiocsr
package and replace all call sites with the existing generic
common.DecodeObjBytes[T] helper, matching the pattern already used
by the trustmanager package.

Cache the ServiceAccount name at init time to avoid redundant YAML
deserialization on every reconcile cycle.
@sebrandon1 sebrandon1 force-pushed the replace-decoders-with-generic branch from 0132362 to de5454a Compare June 24, 2026 19:51
@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@sebrandon1: 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/prow/e2e-operator de5454a link true /test e2e-operator

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

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants