Skip to content

dex: render the authcodes CustomResourceDefinition from templates - #3594

Draft
danish9039 wants to merge 1 commit into
kubeflow:masterfrom
danish9039:gsoc/dex-crd-lifecycle
Draft

dex: render the authcodes CustomResourceDefinition from templates#3594
danish9039 wants to merge 1 commit into
kubeflow:masterfrom
danish9039:gsoc/dex-crd-lifecycle

Conversation

@danish9039

Copy link
Copy Markdown
Member

Supersedes the bot-closed dex authcodes pull request #3574, which GitHub refuses to reopen; the change is rebased onto the merged comparison harness (#3577).

The problem

The chart kept authcodes.yaml in a crds/ directory. Helm installs that directory once and then ignores it: helm template renders no CustomResourceDefinition at all, and helm upgrade never updates the schema. A schema change in a Dex release could therefore never reach a cluster through this chart.

The change

  • common/dex/helm/templates/crds.yaml renders the definition behind crds.enabled (default true), with helm.sh/resource-policy: keep, matching how the cert-manager and Istio charts handle definitions.
  • common/dex/helm/ci/comparison.yaml declares the retained definition with its reason; the harness fails if the annotation ever disappears undeclared, and fails the declaration if it stops matching.
  • scripts/synchronize-dex-manifests.sh no longer overwrites a crds/ copy; it runs tests/dex_helm_crd_lifecycle_test.py, which fails when the hand-written template drifts from the upstream definition.
  • The lifecycle test runs in the chart-behavior-tests job.

Verification

  • python3 tests/dex_helm_crd_lifecycle_test.py — 5 tests pass.
  • python3 tests/run_helm_kustomize_comparison.py dex --all-scenarios — green under Helm 4.2.2; the retained declaration fires (a stale declaration fails the run).
  • black --check, bash -n, workflow parse, git diff --check clean.

Helm ignores a crds directory on template and upgrade, so the schema
could never be updated by a release. Rendering it from templates behind
crds.enabled fixes both, with helm.sh/resource-policy: keep declared in
ci/comparison.yaml so uninstall leaves the definition and the stored
authorization codes behind. The synchronization script fails loudly when
upstream changes the definition, and dex_helm_crd_lifecycle_test.py
performs the same check in continuous integration.

Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kimwnasptd for approval. For more information see the Kubernetes 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

Copilot AI 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.

🔵 Needs a closer look

Existing installations require an ownership-migration procedure before Helm can upgrade the previously unmanaged definition.

Pull request overview

Moves the Dex authorization-code CustomResourceDefinition into Helm templates so schema updates can be rendered and retained during uninstall.

Changes:

  • Adds configurable CustomResourceDefinition rendering and retention.
  • Adds lifecycle, parity, and upstream-drift checks.
  • Documents the revised lifecycle behavior.
File summaries
File Description
tests/dex_helm_crd_lifecycle_test.py Tests rendering, retention, disabling, and upstream parity.
scripts/synchronize-dex-manifests.sh Enforces template parity during synchronization.
common/dex/helm/values.yaml Adds the rendering toggle.
common/dex/helm/templates/crds.yaml Templates the retained definition.
common/dex/helm/README.md Documents lifecycle behavior.
common/dex/helm/ci/comparison.yaml Declares the retained definition.
.github/workflows/helm-kustomize-comparison.yml Runs the lifecycle tests.
Review details

Suppressed comments (1)

common/dex/helm/templates/crds.yaml:5

  • Moving this resource into templates/ makes the first upgrade from the previous chart fail. The old crds/ installation leaves authcodes.dex.coreos.com present without the Helm ownership label and annotations, so a normal helm upgrade rejects the existing resource as having invalid ownership metadata before it can update the schema. The current render-only lifecycle tests cannot detect this. Add and test an explicit migration path, such as a documented ownership patch or a supported helm upgrade --take-ownership procedure.
  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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