Skip to content

Commit 6072cdc

Browse files
disable kueue validating webhook (#3263)
Remove kubebuilder webhook markers, comment out webhook registration and SetupWithManager body, and skip all related unit, integration, and e2e tests. The webhook can be re-enabled by restoring the markers and uncommenting the commented-out code blocks. Co-authored-by: Adrián Sanz Gómiz <100594859+asanzgom@users.noreply.github.com>
1 parent 4db342b commit 6072cdc

File tree

7 files changed

+48
-34
lines changed

7 files changed

+48
-34
lines changed

internal/webhook/envtestutil/webhook_registration.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
66

77
hardwareprofilewebhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/hardwareprofile"
8-
kueuewebhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/kueue"
98
notebookwebhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/notebook"
109
servingwebhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/serving"
1110
webhookutils "github.com/opendatahub-io/opendatahub-operator/v2/pkg/webhook"
@@ -24,15 +23,17 @@ import (
2423
// - Testing any workflow that creates resources matching multiple webhook selectors
2524
// - You need all webhooks to be available to avoid "webhook endpoint not found" errors
2625
func RegisterWebhooks(mgr manager.Manager) error {
27-
// Register Kueue webhook for all resource types
28-
kueueValidator := &kueuewebhook.Validator{
29-
Client: mgr.GetAPIReader(),
30-
Decoder: admission.NewDecoder(mgr.GetScheme()),
31-
Name: "kueue-validating",
32-
}
33-
if err := kueueValidator.SetupWithManager(mgr); err != nil {
34-
return err
35-
}
26+
// NOTE: kueue validating webhook registration is disabled.
27+
// To re-enable, uncomment the block below and restore the kueuewebhook import.
28+
//
29+
// kueueValidator := &kueuewebhook.Validator{
30+
// Client: mgr.GetAPIReader(),
31+
// Decoder: admission.NewDecoder(mgr.GetScheme()),
32+
// Name: "kueue-validating",
33+
// }
34+
// if err := kueueValidator.SetupWithManager(mgr); err != nil {
35+
// return err
36+
// }
3637

3738
// Register Hardware Profile webhook
3839
hardwareProfileInjector := &hardwareprofilewebhook.Injector{

internal/webhook/kueue/integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var (
3030
)
3131

3232
func TestKueueWebhook_Integration(t *testing.T) {
33+
t.Skip("kueue validating webhook is disabled")
3334
t.Parallel()
3435

3536
testCases := []struct {

internal/webhook/kueue/register.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package kueue
44

55
import (
66
ctrl "sigs.k8s.io/controller-runtime"
7-
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
87
)
98

109
// RegisterWebhooks registers the webhooks for kueue label validation.
@@ -14,14 +13,17 @@ import (
1413
//
1514
// Returns:
1615
// - error: Any error encountered during webhook registration.
17-
func RegisterWebhooks(mgr ctrl.Manager) error {
18-
if err := (&Validator{
19-
Client: mgr.GetAPIReader(),
20-
Decoder: admission.NewDecoder(mgr.GetScheme()),
21-
Name: "kueue-validating",
22-
}).SetupWithManager(mgr); err != nil {
23-
return err
24-
}
16+
func RegisterWebhooks(_ ctrl.Manager) error {
17+
// NOTE: kueue validating webhook is disabled. To re-enable, uncomment the
18+
// lines below and restore the +kubebuilder:webhook: markers in validating.go.
19+
//
20+
// if err := (&Validator{
21+
// Client: mgr.GetAPIReader(),
22+
// Decoder: admission.NewDecoder(mgr.GetScheme()),
23+
// Name: "kueue-validating",
24+
// }).SetupWithManager(mgr); err != nil {
25+
// return err
26+
// }
2527

2628
return nil
2729
}

internal/webhook/kueue/validating.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,27 @@ import (
1818
ctrl "sigs.k8s.io/controller-runtime"
1919
"sigs.k8s.io/controller-runtime/pkg/client"
2020
logf "sigs.k8s.io/controller-runtime/pkg/log"
21-
"sigs.k8s.io/controller-runtime/pkg/webhook"
2221
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2322

2423
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
2524
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster/gvk"
2625
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/resources"
27-
webhookutils "github.com/opendatahub-io/opendatahub-operator/v2/pkg/webhook"
2826
)
2927

3028
// Webhooks for Kueue label validation:
3129
// - kubeflow.org/v1: pytorchjobs, notebooks
3230
// - ray.io/v1 and v1alpha1: rayjobs, rayclusters
3331
// - serving.kserve.io/v1beta1: inferenceservices
3432
// - serving.kserve.io/v1alpha1: llminferenceservices
35-
36-
//+kubebuilder:webhook:path=/validate-kueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=kubeflow.org,resources=pytorchjobs;notebooks,verbs=create;update,versions=v1,name=kubeflow-kueuelabels-validator.opendatahub.io,admissionReviewVersions=v1
37-
//+kubebuilder:webhook:path=/validate-kueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=ray.io,resources=rayjobs;rayclusters,verbs=create;update,versions=v1;v1alpha1,name=ray-kueuelabels-validator.opendatahub.io,admissionReviewVersions=v1
38-
//+kubebuilder:webhook:path=/validate-kueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=serving.kserve.io,resources=inferenceservices,verbs=create;update,versions=v1beta1,name=kserve-isvc-kueuelabels-validator.opendatahub.io,admissionReviewVersions=v1
39-
//+kubebuilder:webhook:path=/validate-kueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=serving.kserve.io,resources=llminferenceservices,verbs=create;update,versions=v1alpha1,name=kserve-llmisvc-kueuelabels-validator.opendatahub.io,admissionReviewVersions=v1
33+
//
34+
// NOTE: The kueue validating webhook is currently disabled. To re-enable it,
35+
// restore the +kubebuilder:webhook: prefix on the marker lines below and
36+
// uncomment the SetupWithManager body and RegisterWebhooks body.
37+
38+
// webhook:path=/validate-kueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=kubeflow.org,resources=pytorchjobs;notebooks,verbs=create;update,versions=v1,name=kubeflow-kueuelabels-validator.opendatahub.io,admissionReviewVersions=v1
39+
// webhook:path=/validate-kueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=ray.io,resources=rayjobs;rayclusters,verbs=create;update,versions=v1;v1alpha1,name=ray-kueuelabels-validator.opendatahub.io,admissionReviewVersions=v1
40+
// webhook:path=/validate-kueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=serving.kserve.io,resources=inferenceservices,verbs=create;update,versions=v1beta1,name=kserve-isvc-kueuelabels-validator.opendatahub.io,admissionReviewVersions=v1
41+
// webhook:path=/validate-kueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=serving.kserve.io,resources=llminferenceservices,verbs=create;update,versions=v1alpha1,name=kserve-llmisvc-kueuelabels-validator.opendatahub.io,admissionReviewVersions=v1
4042
//nolint:lll
4143

4244
var (
@@ -62,12 +64,15 @@ var _ admission.Handler = &Validator{}
6264
//
6365
// Returns:
6466
// - error: Always nil (for future extensibility).
65-
func (v *Validator) SetupWithManager(mgr ctrl.Manager) error {
66-
hookServer := mgr.GetWebhookServer()
67-
hookServer.Register("/validate-kueue", &webhook.Admission{
68-
Handler: v,
69-
LogConstructor: webhookutils.NewWebhookLogConstructor(v.Name),
70-
})
67+
func (v *Validator) SetupWithManager(_ ctrl.Manager) error {
68+
// NOTE: kueue validating webhook is disabled. To re-enable, uncomment the
69+
// lines below and restore the +kubebuilder:webhook: markers above.
70+
//
71+
// hookServer := mgr.GetWebhookServer()
72+
// hookServer.Register("/validate-kueue", &webhook.Admission{
73+
// Handler: v,
74+
// LogConstructor: webhookutils.NewWebhookLogConstructor(v.Name),
75+
// })
7176
return nil
7277
}
7378

internal/webhook/kueue/validation_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func createDSCWithKueueState(state operatorv1.ManagementState) *dscv2.DataScienc
4343

4444
// TestKueueWebhook_DeniesWhenDecoderNotInitialized tests that the webhook returns an error when the decoder is nil.
4545
func TestKueueWebhook_DeniesWhenDecoderNotInitialized(t *testing.T) {
46+
t.Skip("kueue validating webhook is disabled")
4647
t.Parallel()
4748
g := NewWithT(t)
4849
ctx := t.Context()
@@ -80,6 +81,7 @@ func TestKueueWebhook_DeniesWhenDecoderNotInitialized(t *testing.T) {
8081

8182
// TestKueueWebhook_DeniesUnexpectedKind tests that the webhook properly rejects requests with unexpected kinds.
8283
func TestKueueWebhook_DeniesUnexpectedKind(t *testing.T) {
84+
t.Skip("kueue validating webhook is disabled")
8385
t.Parallel()
8486
g := NewWithT(t)
8587
ctx := t.Context()
@@ -121,6 +123,7 @@ func TestKueueWebhook_DeniesUnexpectedKind(t *testing.T) {
121123

122124
// TestKueueWebhook_AcceptsExpectedKinds tests that the webhook properly accepts requests with expected kinds.
123125
func TestKueueWebhook_AcceptsExpectedKinds(t *testing.T) {
126+
t.Skip("kueue validating webhook is disabled")
124127
t.Parallel()
125128
g := NewWithT(t)
126129
ctx := t.Context()
@@ -286,6 +289,7 @@ func TestKueueWebhook_AcceptsExpectedKinds(t *testing.T) {
286289
// It verifies that workloads are properly validated based on namespace labels, DSC state, and required Kueue labels
287290
// using table-driven tests and a fake client.
288291
func TestKueueWebhook_ValidatingWebhook(t *testing.T) {
292+
t.Skip("kueue validating webhook is disabled")
289293
t.Parallel()
290294
g := NewWithT(t)
291295
ctx := t.Context()

internal/webhook/webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
dsciv1webhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/dscinitialization/v1"
1717
dsciv2webhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/dscinitialization/v2"
1818
hardwareprofilewebhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/hardwareprofile"
19-
kueuewebhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/kueue"
2019
monitoringwebhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/monitoring"
2120
notebookwebhook "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/notebook"
2221
serving "github.com/opendatahub-io/opendatahub-operator/v2/internal/webhook/serving"
@@ -43,7 +42,8 @@ func RegisterAllWebhooks(mgr ctrl.Manager) error {
4342
{name: "hardwareprofile", register: hardwareprofilewebhook.RegisterWebhooks, disabled: func() bool {
4443
return !cr.IsEnabled(componentApi.KserveComponentName) && !cr.IsEnabled(componentApi.WorkbenchesComponentName)
4544
}},
46-
{name: "kueue", register: kueuewebhook.RegisterWebhooks, disabled: func() bool { return !cr.IsEnabled(componentApi.KueueComponentName) }},
45+
// NOTE: kueue validating webhook is disabled. To re-enable, uncomment the entry below.
46+
// {name: "kueue", register: kueuewebhook.RegisterWebhooks, disabled: func() bool { return !cr.IsEnabled(componentApi.KueueComponentName) }},
4747
{name: "monitoring", register: monitoringwebhook.RegisterWebhooks, disabled: func() bool { return !sr.IsEnabled(serviceApi.MonitoringServiceName) }},
4848
{name: "serving", register: serving.RegisterWebhooks, disabled: func() bool { return !cr.IsEnabled(componentApi.KserveComponentName) }},
4949
{name: "notebook", register: notebookwebhook.RegisterWebhooks, disabled: func() bool { return !cr.IsEnabled(componentApi.WorkbenchesComponentName) }},

tests/e2e/kueue_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ func (tc *KueueTestCtx) ValidateWebhookValidations(t *testing.T) {
397397

398398
// ValidateKueueWebhookValidation validates the Kueue validating webhook behavior using table-driven tests.
399399
func (tc *KueueTestCtx) ValidateKueueWebhookValidation(t *testing.T) {
400+
t.Skip("kueue validating webhook is disabled")
400401
t.Helper()
401402

402403
managedNS := "test-kueue-managed-" + xid.New().String()

0 commit comments

Comments
 (0)