fix: propagate maxExpirationDays from Tenant CR to maas-parameters ConfigMap#982
fix: propagate maxExpirationDays from Tenant CR to maas-parameters ConfigMap#982EgorLu wants to merge 2 commits into
Conversation
…nfigMap The api-key-max-expiration-days value was hardcoded to 90 in the maas-parameters ConfigMap and never updated when the Tenant CR's spec.apiKeys.maxExpirationDays changed. In downstream RHOAI, where the maas-api Deployment reads this value via configMapKeyRef, the direct env var patch was overwritten by the RHOAI reconciler. During PostRender, the maas-parameters ConfigMap is now patched (if already rendered) or synthesized with the resolved value and SSA-applied alongside other platform resources. Resolves: RHOAIENG-66311 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@coderabbitai review |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: EgorLu The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis pull request adds end-to-end support for MaaS parameters ConfigMap handling in the tenant reconciliation pipeline. The constant Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 10✅ Passed checks (10 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@maas-controller/pkg/platform/tenantreconcile/params.go`:
- Around line 387-394: The code in patchMaaSParametersConfigMap currently writes
params.APIKeyMaxExpirationDays directly into the ConfigMap data; add input
validation for params.APIKeyMaxExpirationDays (e.g., parse to int, ensure it's
within acceptable bounds like >0 and <= a sensible max) before assigning into
data["api-key-max-expiration-days"], and return an error if validation fails;
make the same validation change for the analogous code paths noted around lines
396-407 so every place that writes params.APIKeyMaxExpirationDays (before
calling unstructured.SetNestedStringMap) enforces bounds and returns an
explanatory error instead of persisting an invalid value.
In `@maas-controller/pkg/platform/tenantreconcile/postrender.go`:
- Around line 56-58: The current existence check uses
hasRenderedConfigMap(filteredResources, MaaSParametersConfigMapName) which only
matches by name and can be fooled by a ConfigMap in a different namespace;
modify the check to be namespace-aware (e.g., add or change to
hasRenderedConfigMapInNamespace or update hasRenderedConfigMap to accept and
compare namespace) and call it with params.AppNamespace so the code only treats
a matching ConfigMap in params.AppNamespace as present; ensure the namespace
comparison uses the same field used when building the resource
(buildMaaSParametersConfigMap and params.AppNamespace).
🪄 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: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 46d6527e-2e4a-443c-a725-70dc40ef24a1
📒 Files selected for processing (4)
maas-controller/pkg/platform/tenantreconcile/constants.gomaas-controller/pkg/platform/tenantreconcile/params.gomaas-controller/pkg/platform/tenantreconcile/params_test.gomaas-controller/pkg/platform/tenantreconcile/postrender.go
…ce-aware check - resolveAPIKeyMaxExpirationDays now falls back to the default when the Tenant CR value is <= 0, preventing unintended policy weakening. - hasRenderedConfigMap matches on both name and namespace so a ConfigMap in a different namespace cannot suppress creation. - Added test for zero-value fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@EgorLu: The following test has Failed: OCI Artifact Browser URLInspecting Test Artifacts ManuallyTo inspect your test artifacts manually, follow these steps:
mkdir -p oras-artifacts
cd oras-artifacts
oras pull quay.io/opendatahub/odh-ci-artifacts:maas-group-test-8gdpb |
|
PR needs rebase. DetailsInstructions 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. |
|
@EgorLu I think changes look good as long as we can resolve the conflicts? Once you rebase, I think I can leave |
|
@yu-teo Thanks for the review! I've marked this PR as draft, so we know not to look at it currently. |
Summary
api-key-max-expiration-dayswas hardcoded to 90 in themaas-parametersConfigMap and never updated when the Tenant CR'sspec.apiKeys.maxExpirationDayschanged.configMapKeyRef, the direct env var patch fromsetOrAddEnvVarwas overwritten by the RHOAI reconciler, so the ConfigMap's stale value always won.PostRender, themaas-parametersConfigMap is now patched (if already in rendered resources) or synthesized with the resolved value from the Tenant CR, then SSA-applied alongside other platform resources.Risk analysis
api-key-max-expiration-dayskey, so SSA field ownership is narrow. Existing Deployment env var patching is unchanged. Unit tests cover all new code paths, and the existingTestApplyPlatformParamsWithRenderedOverlayintegration test continues to pass. The Prow smoke path exercises Tenant reconciliation and maas-api deployment, which should validate the fix end-to-end.Test plan
patchMaaSParametersConfigMap(existing and empty ConfigMap data)applyPlatformParamswithmaas-parametersConfigMap in rendered resourcesbuildMaaSParametersConfigMapoutput structureTestApplyPlatformParamsWithRenderedOverlaypasses (no regressions)maxExpirationDays🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests