Skip to content

Commit f1a43a4

Browse files
shriramsharmaaattuluri
authored and
GitHub Enterprise
committed
Force all GTP events to update only (istio-ecosystem#235) (istio-ecosystem#132)
* Fixes: istio-ecosystem#234 force GTPs to update only Signed-off-by: Shriram Sharma <[email protected]> * fixed linting errors Signed-off-by: Shriram Sharma <[email protected]> Co-authored-by: aattuluri <[email protected]>
1 parent b347994 commit f1a43a4

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

admiral/pkg/clusters/types.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,23 @@ func (dh *DependencyHandler) Deleted(obj *v1.Dependency) {
191191

192192
func (gtp *GlobalTrafficHandler) Added(obj *v1.GlobalTrafficPolicy) {
193193
log.Infof(LogFormat, "Added", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received")
194-
err := HandleEventForGlobalTrafficPolicy(admiral.Add, obj, gtp.RemoteRegistry, gtp.ClusterID)
194+
err := HandleEventForGlobalTrafficPolicy(obj, gtp.RemoteRegistry, gtp.ClusterID)
195195
if err != nil {
196196
log.Infof(err.Error())
197197
}
198198
}
199199

200200
func (gtp *GlobalTrafficHandler) Updated(obj *v1.GlobalTrafficPolicy) {
201201
log.Infof(LogFormat, "Updated", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received")
202-
err := HandleEventForGlobalTrafficPolicy(admiral.Update, obj, gtp.RemoteRegistry, gtp.ClusterID)
202+
err := HandleEventForGlobalTrafficPolicy(obj, gtp.RemoteRegistry, gtp.ClusterID)
203203
if err != nil {
204204
log.Infof(err.Error())
205205
}
206206
}
207207

208208
func (gtp *GlobalTrafficHandler) Deleted(obj *v1.GlobalTrafficPolicy) {
209209
log.Infof(LogFormat, "Deleted", "globaltrafficpolicy", obj.Name, gtp.ClusterID, "received")
210-
err := HandleEventForGlobalTrafficPolicy(admiral.Delete, obj, gtp.RemoteRegistry, gtp.ClusterID)
210+
err := HandleEventForGlobalTrafficPolicy(obj, gtp.RemoteRegistry, gtp.ClusterID)
211211
if err != nil {
212212
log.Infof(err.Error())
213213
}
@@ -268,7 +268,7 @@ func HandleEventForDeployment(event admiral.EventType, obj *k8sAppsV1.Deployment
268268
}
269269

270270
// HandleEventForGlobalTrafficPolicy processes all the events related to GTPs
271-
func HandleEventForGlobalTrafficPolicy(event admiral.EventType, gtp *v1.GlobalTrafficPolicy, remoteRegistry *RemoteRegistry, clusterName string) error {
271+
func HandleEventForGlobalTrafficPolicy(gtp *v1.GlobalTrafficPolicy, remoteRegistry *RemoteRegistry, clusterName string) error {
272272

273273
globalIdentifier := common.GetGtpIdentity(gtp)
274274

@@ -281,9 +281,7 @@ func HandleEventForGlobalTrafficPolicy(event admiral.EventType, gtp *v1.GlobalTr
281281
// For now we're going to force all the events to update only in order to prevent
282282
// the endpoints from being deleted.
283283
// TODO: Need to come up with a way to prevent deleting default endpoints so that this hack can be removed.
284-
event = admiral.Update
285-
286284
// Use the same function as added deployment function to update and put new service entry in place to replace old one
287-
modifyServiceEntryForNewServiceOrPod(event, env, globalIdentifier, remoteRegistry)
285+
modifyServiceEntryForNewServiceOrPod(admiral.Update, env, globalIdentifier, remoteRegistry)
288286
return nil
289287
}

admiral/pkg/clusters/types_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ func TestRolloutHandler(t *testing.T) {
207207
}
208208

209209
func TestHandleEventForGlobalTrafficPolicy(t *testing.T) {
210-
event := admiral.EventType("Add")
211210
p := common.AdmiralParams{
212211
KubeconfigPath: "testdata/fake.config",
213212
}
@@ -254,7 +253,7 @@ func TestHandleEventForGlobalTrafficPolicy(t *testing.T) {
254253

255254
for _, c := range testcases {
256255
t.Run(c.name, func(t *testing.T) {
257-
err := HandleEventForGlobalTrafficPolicy(event, c.gtp, registry, "testcluster")
256+
err := HandleEventForGlobalTrafficPolicy(c.gtp, registry, "testcluster")
258257
assert.Equal(t, err != nil, c.doesError)
259258
})
260259
}

0 commit comments

Comments
 (0)