Skip to content

Commit b754162

Browse files
committed
align syncer with latest changes
1 parent 0d07d8c commit b754162

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

pkg/controllers/resources/endpointSlices/syncer.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
)
2424

2525
func New(ctx *synccontext.RegisterContext) (syncertypes.Object, error) {
26-
mapper, err := ctx.Mappings.ByGVK(mappings.Endpoints())
26+
mapper, err := ctx.Mappings.ByGVK(mappings.EndpointSlices())
2727
if err != nil {
2828
return nil, err
2929
}
@@ -63,7 +63,7 @@ func (s *endpointSliceSyncer) SyncToHost(ctx *synccontext.SyncContext, event *sy
6363
}
6464

6565
pObj := s.translate(ctx, event.Virtual)
66-
err := pro.ApplyPatchesHostObject(ctx, nil, pObj, event.Virtual, ctx.Config.Sync.ToHost.EndpointSlices.Patches, false)
66+
err := pro.ApplyPatchesHostObject(ctx, pObj, event.Virtual, ctx.Config.Sync.ToHost.EndpointSlices.Patches, false)
6767
if err != nil {
6868
return ctrl.Result{}, err
6969
}
@@ -129,7 +129,7 @@ func (s *endpointSliceSyncer) ReconcileStart(ctx *synccontext.SyncContext, req c
129129
} else if svc.Spec.Selector != nil {
130130
// check if it was a managed endpointSlice object before and delete it
131131
endpointSlice := &discoveryv1.EndpointSlice{}
132-
err = ctx.PhysicalClient.Get(ctx, s.VirtualToHost(ctx, req.NamespacedName, nil), endpointSlice)
132+
err = ctx.HostClient.Get(ctx, s.VirtualToHost(ctx, req.NamespacedName, nil), endpointSlice)
133133
if err != nil {
134134
if !kerrors.IsNotFound(err) {
135135
klog.Infof("Error retrieving endpointSliceList: %v", err)
@@ -146,7 +146,7 @@ func (s *endpointSliceSyncer) ReconcileStart(ctx *synccontext.SyncContext, req c
146146
// to the same endpoints resulting in wrong DNS and cluster networking. Hence, deleting the previously
147147
// managed endpointSlices signals the Kubernetes controller to recreate the endpointSlices from the selector.
148148
klog.Infof("Refresh endpointSlice in physical cluster because they shouldn't be managed by vcluster anymore")
149-
err = ctx.PhysicalClient.Delete(ctx, endpointSlice)
149+
err = ctx.HostClient.Delete(ctx, endpointSlice)
150150
if err != nil {
151151
klog.Infof("Error deleting endpoints %s/%s: %v", endpointSlice.Namespace, endpointSlice.Name, err)
152152
return true, err
@@ -158,10 +158,10 @@ func (s *endpointSliceSyncer) ReconcileStart(ctx *synccontext.SyncContext, req c
158158

159159
// check if it was a Kubernetes managed endpointSlice object before and delete it
160160
endpointSlice := &discoveryv1.EndpointSlice{}
161-
err = ctx.PhysicalClient.Get(ctx, s.VirtualToHost(ctx, req.NamespacedName, nil), endpointSlice)
161+
err = ctx.HostClient.Get(ctx, s.VirtualToHost(ctx, req.NamespacedName, nil), endpointSlice)
162162
if err == nil && (endpointSlice.Annotations == nil || endpointSlice.Annotations[translate.NameAnnotation] == "") {
163163
klog.Infof("Refresh endpointSlice in physical cluster because they should be managed by vCluster now")
164-
err = ctx.PhysicalClient.Delete(ctx, endpointSlice)
164+
err = ctx.HostClient.Delete(ctx, endpointSlice)
165165
if err != nil {
166166
klog.Infof("Error deleting endpointSlice %s/%s: %v", endpointSlice.Namespace, endpointSlice.Name, err)
167167
return true, err

pkg/controllers/resources/endpointSlices/translate.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
)
1111

1212
func (s *endpointSliceSyncer) translate(ctx *synccontext.SyncContext, vObj client.Object) *discoveryv1.EndpointSlice {
13-
endpointSlice := translate.HostMetadata(vObj.(*discoveryv1.EndpointSlice), s.VirtualToHost(ctx, types.NamespacedName{Name: vObj.GetName(), Namespace: vObj.GetNamespace()}, vObj), s.excludedAnnotations...)
13+
endpointSlice := translate.HostMetadata(vObj.(*discoveryv1.EndpointSlice),
14+
s.VirtualToHost(ctx, types.NamespacedName{Name: vObj.GetName(), Namespace: vObj.GetNamespace()}, vObj),
15+
s.excludedAnnotations...)
1416
s.translateSpec(ctx, endpointSlice)
1517
return endpointSlice
1618
}

pkg/mappings/registry.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ func Endpoints() schema.GroupVersionKind {
105105
return corev1.SchemeGroupVersion.WithKind("Endpoints")
106106
}
107107

108+
func EndpointSlices() schema.GroupVersionKind {
109+
return corev1.SchemeGroupVersion.WithKind("EndpointSlice")
110+
}
111+
108112
func Services() schema.GroupVersionKind {
109113
return corev1.SchemeGroupVersion.WithKind("Service")
110114
}

0 commit comments

Comments
 (0)