Skip to content

Block DocumentDB creation when the ImageVolume feature is unavailable (fail fast via webhook) #431

Closed

Description

@WentingWu666666

Summary

The operator hard-depends on the Kubernetes ImageVolume feature — the DocumentDB extension is mounted into the PostgreSQL pod via corev1.ImageVolumeSource (operator/src/internal/cnpg/cnpg_cluster.go). When a cluster does not have ImageVolume available, the CNPG pods can never mount the extension and the cluster silently fails to become ready, with no clear signal to the user.

We should fail fast at DocumentDB creation time with an actionable error instead of letting pods hang.

Background: ImageVolume availability

K8s version ImageVolume stage Default
1.31-1.32 Alpha disabled
1.33-1.34 Beta disabled (opt-in via feature gate)
1.35+ GA enabled
  • Enabling on <1.35 requires the ImageVolume feature gate on both kube-apiserver and every kubelet, plus a runtime that supports it (containerd >= 2.1 / CRI-O >= 1.33).
  • Managed offerings (AKS/EKS/GKE standard) generally cannot enable the apiserver gate before it ships on-by-default. Ref: [Feature]: Enable ImageVolume feature gate Azure/AKS#5448.
  • Docs already pin Kubernetes 1.35+ as the minimum (docs/operator-public-documentation/preview/getting-started/before-you-start.md), but there is no runtime enforcement today.

Proposal

Add a create-time block in the validating webhook (operator/src/internal/webhook/) that rejects DocumentDB creation when the cluster does not support ImageVolume.

Detection: capability-based, not version-based. Perform a differential server-side dry-run:

  1. Dry-run a baseline probe Pod with an emptyDir volume.
  2. Dry-run an identical Pod whose only difference is an ImageVolumeSource volume.
  3. Interpret:
    • baseline rejected -> inconclusive (PSA/quota/other webhook) -> fail-open (allow)
    • baseline ok + image ok -> supported (allow)
    • baseline ok + image rejected -> unsupported (block with clear error)

Rationale for capability- over version-detection:

  • Automatically admits 1.33/1.34 clusters that have the gate enabled (functionally identical to 1.35 - same API), without officially "supporting" them.
  • Also catches 1.35 clusters with a broken/old runtime.
  • Fail-open keeps us from blocking legitimate clusters when the probe is inconclusive.

Details:

  • Cache only positive results (atomic.Bool) so steady-state create latency is ~0; never cache negatives so enabling the gate later works without an operator restart.
  • No new RBAC needed - the operator ClusterRole already grants create on pods (operator/documentdb-helm-chart/templates/05_clusterrole.yaml).
  • Error message should tell the user exactly what to do (enable gate on apiserver + kubelet, runtime requirements, note managed-cluster limitation, link to k8s docs).

Scope / decisions

  • Supported baseline stays Kubernetes 1.35+ (documented). <1.35 + gate enabled is "works, best-effort/unsupported" - allowed by the capability probe, not promised in CI.
  • Do not build a non-ImageVolume fallback (e.g. initContainer copying the extension) - doubles mount code paths and is untested; out of scope.

Tasks

  • Add capability probe helper (differential dry-run) in internal/webhook/
  • Wire into ValidateCreate (and skip on update paths that don't change this)
  • Unit tests covering supported / unsupported / inconclusive cases
  • Docs note: advanced/unsupported path for <1.35 with the gate enabled

Acceptance criteria

  • Creating a DocumentDB on a cluster without ImageVolume is rejected immediately with an actionable error.
  • Creating on a 1.35+ (or gate-enabled) cluster succeeds unchanged.
  • Inconclusive probe environments do not block creation.

Activity

  1. added
    enhancement
    on Jul 24, 2026
  2. added
    go
    on Jul 24, 2026
  3. documentdb-triage-tool commented on Jul 24, 2026

    @documentdb-triage-tool

    🤖 Auto-triaged by documentdb-triage-tool.

    Applied: go, performance
    Project fields suggested: Component controllers · Priority P2 · Effort L · Status In Progress
    Confidence: 0.82 (llm)

    Reasoning

    LLM: Adding a capability-based dry-run probe and fail-fast validating webhook for ImageVolume availability touches the webhook internals and CNPG cluster logic across multiple files, improving UX but not fixing a data-loss or security issue.

    If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementgoperformance

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions