From b94aea8118a5663bfbe501accb86526bd6edd318 Mon Sep 17 00:00:00 2001 From: rambohe Date: Tue, 7 Jan 2025 01:17:14 +1100 Subject: [PATCH] fix: endpointslices belongs to discovery.k8s.io group (#2244) Signed-off-by: rambohe-ch --- .../templates/yurt-manager-auto-generated.yaml | 6 +++--- .../webhook/endpointslice/v1/endpointslice_default.go | 7 ++++--- .../webhook/endpointslice/v1/endpointslice_handler.go | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/charts/yurt-manager/templates/yurt-manager-auto-generated.yaml b/charts/yurt-manager/templates/yurt-manager-auto-generated.yaml index b87fc6c5c98..e0d5685314f 100644 --- a/charts/yurt-manager/templates/yurt-manager-auto-generated.yaml +++ b/charts/yurt-manager/templates/yurt-manager-auto-generated.yaml @@ -1444,12 +1444,12 @@ webhooks: service: name: yurt-manager-webhook-service namespace: {{ .Release.Namespace }} - path: /mutate-core-openyurt-io-v1-endpointslice + path: /mutate-discovery-k8s-io-v1-endpointslice failurePolicy: Ignore - name: mutate.core.v1.endpointslice.openyurt.io + name: mutate.discovery.v1.endpointslice.k8s.io rules: - apiGroups: - - "" + - discovery.k8s.io apiVersions: - v1 operations: diff --git a/pkg/yurtmanager/webhook/endpointslice/v1/endpointslice_default.go b/pkg/yurtmanager/webhook/endpointslice/v1/endpointslice_default.go index af0178b3623..4b27b33b55e 100644 --- a/pkg/yurtmanager/webhook/endpointslice/v1/endpointslice_default.go +++ b/pkg/yurtmanager/webhook/endpointslice/v1/endpointslice_default.go @@ -77,7 +77,8 @@ func remapAutonomyEndpoints(ctx context.Context, client client.Client, slice *di return nil } - for _, e := range slice.Endpoints { + readyServing := true + for i, e := range slice.Endpoints { // If the endpoint is ready, skip if e.Conditions.Ready != nil && *e.Conditions.Ready { continue @@ -115,10 +116,10 @@ func remapAutonomyEndpoints(ctx context.Context, client client.Client, slice *di // Set not ready addresses to ready & serving if e.Conditions.Ready != nil { - *e.Conditions.Ready = true + slice.Endpoints[i].Conditions.Ready = &readyServing } if e.Conditions.Serving != nil { - *e.Conditions.Serving = true + slice.Endpoints[i].Conditions.Serving = &readyServing } } diff --git a/pkg/yurtmanager/webhook/endpointslice/v1/endpointslice_handler.go b/pkg/yurtmanager/webhook/endpointslice/v1/endpointslice_handler.go index bd3e8162a82..e07ddff4d70 100644 --- a/pkg/yurtmanager/webhook/endpointslice/v1/endpointslice_handler.go +++ b/pkg/yurtmanager/webhook/endpointslice/v1/endpointslice_handler.go @@ -44,6 +44,6 @@ func (webhook *EndpointSliceHandler) SetupWebhookWithManager(mgr ctrl.Manager) ( return util.RegisterWebhook(mgr, &v1.EndpointSlice{}, webhook) } -// +kubebuilder:webhook:path=/mutate-core-openyurt-io-v1-endpointslice,mutating=true,failurePolicy=ignore,sideEffects=None,admissionReviewVersions=v1,groups="",resources=endpointslices,verbs=update,versions=v1,name=mutate.core.v1.endpointslice.openyurt.io +// +kubebuilder:webhook:path=/mutate-discovery-k8s-io-v1-endpointslice,mutating=true,failurePolicy=ignore,sideEffects=None,admissionReviewVersions=v1,groups="discovery.k8s.io",resources=endpointslices,verbs=update,versions=v1,name=mutate.discovery.v1.endpointslice.k8s.io var _ webhook.CustomDefaulter = &EndpointSliceHandler{}