Skip to content

Commit 475932b

Browse files
committed
add validation options to HA service reconciler
1 parent e4e87c9 commit 475932b

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

cmd/k8s-operator/operator.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,17 @@ func runReconcilers(opts reconcilerOpts) {
434434
Watches(&tsapi.ProxyGroup{}, ingressProxyGroupFilter).
435435
Watches(&discoveryv1.EndpointSlice{}, ingressSvcFromEpsFilter).
436436
Complete(&HAServiceReconciler{
437-
recorder: eventRecorder,
438-
tsClient: opts.tsClient,
439-
tsnetServer: opts.tsServer,
440-
defaultTags: strings.Split(opts.proxyTags, ","),
441-
Client: mgr.GetClient(),
442-
logger: opts.log.Named("service-pg-reconciler"),
443-
lc: lc,
444-
clock: tstime.DefaultClock{},
445-
operatorID: id,
446-
tsNamespace: opts.tailscaleNamespace,
437+
recorder: eventRecorder,
438+
tsClient: opts.tsClient,
439+
tsnetServer: opts.tsServer,
440+
defaultTags: strings.Split(opts.proxyTags, ","),
441+
Client: mgr.GetClient(),
442+
logger: opts.log.Named("service-pg-reconciler"),
443+
lc: lc,
444+
clock: tstime.DefaultClock{},
445+
operatorID: id,
446+
tsNamespace: opts.tailscaleNamespace,
447+
validationOpts: opts.validationOpts,
447448
})
448449
if err != nil {
449450
startlog.Fatalf("could not create service-pg-reconciler: %v", err)

cmd/k8s-operator/svc-for-pg.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ type HAServiceReconciler struct {
6666
defaultTags []string
6767
operatorID string // stableID of the operator's Tailscale device
6868

69+
validationOpts validationOpts
70+
6971
clock tstime.Clock
7072

7173
mu sync.Mutex // protects following
@@ -861,7 +863,7 @@ func (r *HAServiceReconciler) validateService(ctx context.Context, svc *corev1.S
861863
errs = append(errs, fmt.Errorf("ProxyGroup %q is of type %q but must be of type %q",
862864
pg.Name, pg.Spec.Type, tsapi.ProxyGroupTypeIngress))
863865
}
864-
if violations := validateService(svc); len(violations) > 0 {
866+
if violations := validateService(svc, r.validationOpts); len(violations) > 0 {
865867
errs = append(errs, fmt.Errorf("invalid Service: %s", strings.Join(violations, ", ")))
866868
}
867869
svcList := &corev1.ServiceList{}

0 commit comments

Comments
 (0)