refactor(operator): switch DGD and DCD admission to v1beta1 for 1.5 - #11177
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: bdc44ab | Docs | Datadog PR Page | Give us feedback! |
|
/ok to test 7410e0a |
WalkthroughThis PR removes v1alpha1 admission webhook support for DynamoGraphDeployment, consolidating defaulting and validation webhooks onto a single v1beta1 endpoint. The Helm chart webhook configuration is updated to reference v1beta1 paths and API versions, and conversion helpers plus related v1alpha1 tests are deleted. Changesv1alpha1 webhook removal and v1beta1 consolidation
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches⚔️ Resolve merge conflicts
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
deploy/operator/internal/webhook/defaulting/dynamographdeployment_handler.go (1)
76-96: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winMove nil-
Replicasdefaulting ahead of the admission-request fetch.The replica default is described as preventing a controller nil-pointer panic and must apply "on every operation," yet it now sits after the
RequestFromContextcall, whose error branch (Line 79) returnsnilearly. If the request can't be extracted, the object is admitted withnilReplicas and the panic the comment warns about can still occur downstream. The request is only needed for the CREATE-time annotation stamping, so run the component defaulting first, then fetch the request solely to gate the stamping.🛠️ Proposed reordering
- req, err := admission.RequestFromContext(ctx) - if err != nil { - logger.Error(err, "failed to get admission request from context, skipping defaulting") - return nil - } - // Default nil replicas to 1 for all components. The Replicas field is // *int32 with omitempty, so users can legally omit it. Without this // default the controller panics on a nil pointer dereference in // expandRolesForComponent(). Apply on every operation so that components // added via UPDATE also get the default. grovePathway := d.isGrovePathway(dgd) for i := range dgd.Spec.Components { component := &dgd.Spec.Components[i] if component.Replicas == nil { component.Replicas = ptr.To(int32(1)) } if grovePathway && component.MinAvailable == nil { component.MinAvailable = ptr.To(int32(1)) } } + req, err := admission.RequestFromContext(ctx) + if err != nil { + logger.Error(err, "failed to get admission request from context, skipping origin-version stamping") + return nil + } + if req.Operation == admissionv1.Create {🤖 Prompt for 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. In `@deploy/operator/internal/webhook/defaulting/dynamographdeployment_handler.go` around lines 76 - 96, Move the nil-Replicas defaulting in dynamographdeploymentHandler.Default around the RequestFromContext logic so it always runs first, before any early return from admission request lookup. Keep the component loop that initializes Replicas (and grovePathway MinAvailable) unconditional, then call admission.RequestFromContext(ctx) only for the CREATE-time annotation stamping path so a missing request cannot bypass the safety default.deploy/helm/charts/platform/components/operator/templates/webhook-configuration.yaml (1)
44-62: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winUpdate the DCD validating webhook to use the new v1beta1 route.
deploy/operator/internal/webhook/validation/dynamocomponentdeployment_handler.gostill registers/validate-nvidia-com-v1alpha1-dynamocomponentdeploymentand gates onnvidiacomv1alpha1.DynamoComponentDeploymentGVK, while the Helm config now sends requests to/validate/nvidia.com/v1beta1/dynamocomponentdeployments. That mismatch will break CREATE/UPDATE admission fordynamocomponentdeployments.🤖 Prompt for 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. In `@deploy/helm/charts/platform/components/operator/templates/webhook-configuration.yaml` around lines 44 - 62, The validating webhook route and version gate are still on the old v1alpha1 path, so update `dynamocomponentdeployment_handler.go` to register and handle the new `/validate/nvidia.com/v1beta1/dynamocomponentdeployments` route. Make the handler use the v1beta1 `DynamoComponentDeployment` GVK and ensure the webhook registration, path matching, and admission logic all align with the Helm `webhook-configuration` template so CREATE/UPDATE requests reach the correct validator.
🤖 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.
Outside diff comments:
In
`@deploy/helm/charts/platform/components/operator/templates/webhook-configuration.yaml`:
- Around line 44-62: The validating webhook route and version gate are still on
the old v1alpha1 path, so update `dynamocomponentdeployment_handler.go` to
register and handle the new
`/validate/nvidia.com/v1beta1/dynamocomponentdeployments` route. Make the
handler use the v1beta1 `DynamoComponentDeployment` GVK and ensure the webhook
registration, path matching, and admission logic all align with the Helm
`webhook-configuration` template so CREATE/UPDATE requests reach the correct
validator.
In
`@deploy/operator/internal/webhook/defaulting/dynamographdeployment_handler.go`:
- Around line 76-96: Move the nil-Replicas defaulting in
dynamographdeploymentHandler.Default around the RequestFromContext logic so it
always runs first, before any early return from admission request lookup. Keep
the component loop that initializes Replicas (and grovePathway MinAvailable)
unconditional, then call admission.RequestFromContext(ctx) only for the
CREATE-time annotation stamping path so a missing request cannot bypass the
safety default.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: a8509ad0-004e-48a5-b913-bfe44f1b016c
📒 Files selected for processing (6)
deploy/helm/charts/platform/components/operator/templates/webhook-configuration.yamldeploy/operator/internal/webhook/defaulting/dynamographdeployment_handler.godeploy/operator/internal/webhook/defaulting/dynamographdeployment_handler_test.godeploy/operator/internal/webhook/dynamographdeployment_conversion.godeploy/operator/internal/webhook/validation/dynamographdeployment_handler.godeploy/operator/internal/webhook/validation/dynamographdeployment_handler_test.go
💤 Files with no reviewable changes (3)
- deploy/operator/internal/webhook/dynamographdeployment_conversion.go
- deploy/operator/internal/webhook/validation/dynamographdeployment_handler_test.go
- deploy/operator/internal/webhook/defaulting/dynamographdeployment_handler_test.go
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
7410e0a to
69b1460
Compare
|
/ok to test 69b1460 |
Signed-off-by: Dr. Stefan Schimanski <sschimanski@nvidia.com>
|
/ok to test bdc44ab |
Summary
/validate/nvidia.com/v1beta1/dynamocomponentdeployments.This does not remove the v1alpha1 CRD versions or the API conversion webhook.
Dependencies
Validation
GOCACHE=/private/tmp/dynamo-go-cache go test ./internal/webhook/...helm lint . --set discoveryBackend=kuberneteshelm template dcd-validation . --set discoveryBackend=kubernetes --show-only templates/webhook-configuration.yaml/validate/nvidia.com/v1beta1/dynamocomponentdeploymentswithapiVersions: [v1beta1].Summary by CodeRabbit