Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force GTPs to update only #235

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions admiral/pkg/clusters/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,23 @@ 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())
}
}

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())
}
}

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())
}
Expand Down Expand Up @@ -259,7 +259,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)

Expand All @@ -269,7 +269,10 @@ func HandleEventForGlobalTrafficPolicy(event admiral.EventType, gtp *v1.GlobalTr

env := common.GetGtpEnv(gtp)

// 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.
// 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
}
3 changes: 1 addition & 2 deletions admiral/pkg/clusters/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func TestRolloutHandler(t *testing.T) {
}

func TestHandleEventForGlobalTrafficPolicy(t *testing.T) {
event := admiral.EventType("Add")
p := common.AdmiralParams{
KubeconfigPath: "testdata/fake.config",
}
Expand Down Expand Up @@ -253,7 +252,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)
})
}
Expand Down