From 46c52d8f0b01c395b00d1d12323c359ad1c3c397 Mon Sep 17 00:00:00 2001 From: Ashley Dumaine Date: Tue, 21 May 2024 10:44:22 -0400 Subject: [PATCH] handle LoadBalancer deletion if service type changes to no longer be a LoadBalancer --- cloud/linode/service_controller.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cloud/linode/service_controller.go b/cloud/linode/service_controller.go index 4ab72218..f04167e9 100644 --- a/cloud/linode/service_controller.go +++ b/cloud/linode/service_controller.go @@ -47,6 +47,21 @@ func (s *serviceController) Run(stopCh <-chan struct{}) { klog.Infof("ServiceController will handle service (%s) deletion", getServiceNn(service)) s.queue.Add(service) }, + UpdateFunc: func(oldObj, newObj interface{}) { + newSvc, ok := newObj.(*v1.Service) + if !ok { + return + } + oldSvc, ok := oldObj.(*v1.Service) + if !ok { + return + } + + if newSvc.Spec.Type != "LoadBalancer" && oldSvc.Spec.Type == "LoadBalancer" { + klog.Infof("ServiceController will handle service (%s) LoadBalancer deletion", getServiceNn(oldSvc)) + s.queue.Add(oldSvc) + } + }, }); err != nil { klog.Errorf("ServiceController didn't successfully register it's Informer %s", err) }