diff --git a/admiral/pkg/clusters/types.go b/admiral/pkg/clusters/types.go index 850689ad..5e2b79bc 100644 --- a/admiral/pkg/clusters/types.go +++ b/admiral/pkg/clusters/types.go @@ -191,7 +191,7 @@ func (dh *DependencyHandler) Deleted(obj *v1.Dependency) { func (gtp *GlobalTrafficHandler) Added(obj *v1.GlobalTrafficPolicy) { log.Infof(LogFormat, "Added", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received") - err := HandleEventForGlobalTrafficPolicy(admiral.Add, obj, gtp.RemoteRegistry, gtp.ClusterID) + err := HandleEventForGlobalTrafficPolicy(obj, gtp.RemoteRegistry, gtp.ClusterID) if err != nil { log.Infof(err.Error()) } @@ -199,7 +199,7 @@ func (gtp *GlobalTrafficHandler) Added(obj *v1.GlobalTrafficPolicy) { func (gtp *GlobalTrafficHandler) Updated(obj *v1.GlobalTrafficPolicy) { log.Infof(LogFormat, "Updated", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received") - err := HandleEventForGlobalTrafficPolicy(admiral.Update, obj, gtp.RemoteRegistry, gtp.ClusterID) + err := HandleEventForGlobalTrafficPolicy(obj, gtp.RemoteRegistry, gtp.ClusterID) if err != nil { log.Infof(err.Error()) } @@ -207,7 +207,7 @@ func (gtp *GlobalTrafficHandler) Updated(obj *v1.GlobalTrafficPolicy) { func (gtp *GlobalTrafficHandler) Deleted(obj *v1.GlobalTrafficPolicy) { log.Infof(LogFormat, "Deleted", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received") - err := HandleEventForGlobalTrafficPolicy(admiral.Delete, obj, gtp.RemoteRegistry, gtp.ClusterID) + err := HandleEventForGlobalTrafficPolicy(obj, gtp.RemoteRegistry, gtp.ClusterID) if err != nil { log.Infof(err.Error()) } @@ -268,7 +268,7 @@ func HandleEventForDeployment(event admiral.EventType, obj *k8sAppsV1.Deployment } // HandleEventForGlobalTrafficPolicy processes all the events related to GTPs -func HandleEventForGlobalTrafficPolicy(event admiral.EventType, gtp *v1.GlobalTrafficPolicy, remoteRegistry *RemoteRegistry, clusterName string) error { +func HandleEventForGlobalTrafficPolicy(gtp *v1.GlobalTrafficPolicy, remoteRegistry *RemoteRegistry, clusterName string) error { globalIdentifier := common.GetGtpIdentity(gtp) @@ -281,9 +281,7 @@ func HandleEventForGlobalTrafficPolicy(event admiral.EventType, gtp *v1.GlobalTr // For now we're going to force all the events to update only in order to prevent // the endpoints from being deleted. // TODO: Need to come up with a way to prevent deleting default endpoints so that this hack can be removed. - event = admiral.Update - // Use the same function as added deployment function to update and put new service entry in place to replace old one - modifyServiceEntryForNewServiceOrPod(event, env, globalIdentifier, remoteRegistry) + modifyServiceEntryForNewServiceOrPod(admiral.Update, env, globalIdentifier, remoteRegistry) return nil } diff --git a/admiral/pkg/clusters/types_test.go b/admiral/pkg/clusters/types_test.go index 73b34a2f..c49e9115 100644 --- a/admiral/pkg/clusters/types_test.go +++ b/admiral/pkg/clusters/types_test.go @@ -207,7 +207,6 @@ func TestRolloutHandler(t *testing.T) { } func TestHandleEventForGlobalTrafficPolicy(t *testing.T) { - event := admiral.EventType("Add") p := common.AdmiralParams{ KubeconfigPath: "testdata/fake.config", } @@ -254,7 +253,7 @@ func TestHandleEventForGlobalTrafficPolicy(t *testing.T) { for _, c := range testcases { t.Run(c.name, func(t *testing.T) { - err := HandleEventForGlobalTrafficPolicy(event, c.gtp, registry, "testcluster") + err := HandleEventForGlobalTrafficPolicy(c.gtp, registry, "testcluster") assert.Equal(t, err != nil, c.doesError) }) }