fix(crd): omit empty categories and drop the duplicate Tenant CRD#198
fix(crd): omit empty categories and drop the duplicate Tenant CRD#198Rohmilchkaese wants to merge 3 commits into
Conversation
crds/tenant.yaml and crds/tenant-crd.yaml were byte-identical copies of the same CustomResourceDefinition, and tracked_tenant_crds_match_generated_schema asserted the generated schema against both, which kept the two in lockstep rather than flagging the duplication. Helm renders every file in crds/, so installing the chart submits tenants.rustfs.com twice. Argo CD surfaces this as two resources sharing a name within one application. Keep crds/tenant-crd.yaml, which matches the policybinding-crd.yaml naming, and point the test at the two files it actually tracks. The PolicyBinding half of the rendered output had no assertion at all before.
kube-rs derives names.categories as Some(vec![]) for types that declare no category attribute, so the generated CRDs ship `categories: []`. The API server prunes empty arrays, so the stored object carries no categories key at all. Tools that compare a rendered manifest against the live object then diff a desired [] against an absent field and report the CRD as permanently drifted. On Argo CD the sync itself reports 'successfully synced (all tasks run)' and the application immediately reads OutOfSync again, while kubectl diff against the same cluster is clean - which makes it awkward to track down. Normalize an empty categories list to None before serializing, and regenerate the tracked CRDs. Adds a regression test asserting the rendered CRDs carry no categories key, and one asserting a populated list is left untouched.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b83b6295b1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -1,2657 +0,0 @@ | |||
| apiVersion: apiextensions.k8s.io/v1 | |||
There was a problem hiding this comment.
Update upgrade docs for the renamed Tenant CRD
Removing this file leaves the documented upgrade commands pointing at a path that no longer exists: docs/operator-user-guide.md, docs/operator-user-guide.zh-CN.md, and deploy/rustfs-operator/README.md still run kubectl apply -f deploy/rustfs-operator/crds/tenant.yaml. Users following those upgrade steps will fail before applying the Tenant CRD, so the docs should be updated to tenant-crd.yaml or this compatibility path should remain available.
Useful? React with 👍 / 👎.
The upgrade instructions applied deploy/rustfs-operator/crds/tenant.yaml, which this branch removes as a duplicate. Anyone following them would hit a missing path before the Tenant CRD was applied. Covers the chart README and both language versions of the operator user guide. The remaining tenant.yaml references are examples/ files and a tutorial-local manifest, which are unaffected.
|
Thanks - good catch. Fixed in 39f1120: the upgrade commands in I checked the rest of the tree for references to the removed path: the only other |
Two CRD-rendering bugs found while deploying the operator with Argo CD. Both make the chart's CRDs misbehave under GitOps tooling; neither affects the operator at runtime.
1.
categories: []makes CRDs permanently driftkube-rs derives
names.categoriesasSome(vec![])for types that declare nocategoryattribute, so the generated CRDs ship:The API server prunes empty arrays, so the stored object has no
categorieskey at all. Anything that compares the rendered manifest against the live object then diffs a desired[]against an absent field, forever.On Argo CD this presents confusingly: the sync succeeds and reports
and the Application immediately reads
OutOfSyncagain, whilekubectl diffagainst the same cluster is completely clean. A hard refresh and an explicit re-sync do not help, because nothing is actually wrong on the cluster — only the comparison is.Fixed by normalizing an empty
categorieslist toNonebefore serializing, and regenerating the tracked CRDs. The regeneration diff is exactly two lines, one per CRD.2. The Tenant CRD is shipped twice
deploy/rustfs-operator/crds/tenant.yamlanddeploy/rustfs-operator/crds/tenant-crd.yamlare byte-identical copies of the sameCustomResourceDefinition. Helm renders every file incrds/, so installing the chart submitstenants.rustfs.comtwice; Argo CD reports two resources sharing a name inside one Application.tracked_tenant_crds_match_generated_schemaasserted the generated schema against both paths, which kept the copies in lockstep rather than surfacing the duplication.Kept
crds/tenant-crd.yaml, matching thepolicybinding-crd.yamlnaming, and pointed the test at the two files it actually tracks. The PolicyBinding half of the rendered output previously had no assertion, so this also closes a coverage gap.Notes
categoriesfirst would leavetenant.yamlstale and break the tracking test mid-history.categorieskey; a populatedcategorieslist is left untouched (so the normalization cannot over-reach); and the tracking test now covers PolicyBinding.Verification
Behaviour confirmed against a live 4-node erasure-coded tenant on Kubernetes 1.33: with the empty
categoriesremoved, the Argo CD Application settles onSynced / Healthyinstead of flapping back toOutOfSyncafter every sync.