Skip to content

fix: register admission webhook handlers#504

Merged
catpineapple merged 1 commit into
apache:masterfrom
Al-assad:codex/fix-webhook-registration
Jul 7, 2026
Merged

fix: register admission webhook handlers#504
catpineapple merged 1 commit into
apache:masterfrom
Al-assad:codex/fix-webhook-registration

Conversation

@Al-assad

@Al-assad Al-assad commented Jul 7, 2026

Copy link
Copy Markdown
Member

Motivation

With controller-runtime v0.20, NewWebhookManagedBy(mgr).For(obj).Complete() only records the API type. It does not automatically register custom defaulters or validators. As a result, enabling ENABLE_WEBHOOK=true can leave the webhook server without registered handlers, and admission calls may fail or be ignored depending on failurePolicy.

The validation methods also need to validate the decoded admission object passed by controller-runtime instead of the receiver used as the validator instance.

Changes

  • Explicitly register DorisCluster and DorisDisaggregatedCluster defaulters and validators with WithDefaulter and WithValidator.
  • Validate the decoded obj / newObj passed to webhook callbacks.
  • Update webhook tests to exercise the same validator-instance shape used by admission handling.

Tests

  • go test ./api/doris/v1 ./api/disaggregated/v1
  • Verified in a test environment with yulinying/doris-operator:dev-20260707:
    • invalid DDC feSpec.replicas < feSpec.electionNumber is rejected by vdorisdisaggregatedcluster.kb.io
    • invalid DDC adminUser.name=admin is rejected by vdorisdisaggregatedcluster.kb.io
    • valid DDC dry-run is allowed

@catpineapple catpineapple merged commit 1bcd552 into apache:master Jul 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants