Skip to content

Commit e66fa64

Browse files
committed
Ensure the a local-only intercept is removed on quit.
Signed-off-by: Thomas Hallgren <[email protected]>
1 parent 31e40da commit e66fa64

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pkg/client/userd/trafficmgr/intercept.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ func (s *session) handleInterceptSnapshot(ctx context.Context, podIcepts *podInt
324324
podIcepts.cancelUnwanted(ctx)
325325
}
326326

327-
// getCurrentIntercepts returns a copy of the current intercept snapshot.
327+
// getCurrentIntercepts returns a copy of the current intercept snapshot. This snapshot does
328+
// not include any local-only intercepts.
328329
func (s *session) getCurrentIntercepts() []*intercept {
329330
// Copy the current snapshot
330331
s.currentInterceptsLock.Lock()
@@ -750,7 +751,8 @@ func (s *session) RemoveIntercept(c context.Context, name string) error {
750751
dlog.Debugf(c, "Removing intercept %s", name)
751752

752753
if _, ok := s.localIntercepts[name]; ok {
753-
return s.RemoveLocalOnlyIntercept(c, name)
754+
s.RemoveLocalOnlyIntercept(c, name)
755+
return nil
754756
}
755757

756758
ii := s.getInterceptByName(name)
@@ -861,6 +863,10 @@ func (s *session) ClearIntercepts(c context.Context) error {
861863
return err
862864
}
863865
}
866+
for ic := range s.localIntercepts {
867+
dlog.Debugf(c, "Clearing local-only intercept %s", ic)
868+
s.RemoveLocalOnlyIntercept(c, ic)
869+
}
864870
return nil
865871
}
866872

@@ -986,7 +992,7 @@ func (s *session) addLocalOnlyIntercept(c context.Context, spec *manager.Interce
986992
}
987993
}
988994

989-
func (s *session) RemoveLocalOnlyIntercept(c context.Context, name string) error {
995+
func (s *session) RemoveLocalOnlyIntercept(c context.Context, name string) {
990996
dlog.Debugf(c, "removing local-only intercept %s", name)
991997

992998
// Ensure that namespace is removed from localInterceptedNamespaces if this was the last local intercept
@@ -998,5 +1004,4 @@ func (s *session) RemoveLocalOnlyIntercept(c context.Context, name string) error
9981004
}
9991005
s.currentInterceptsLock.Unlock()
10001006
s.updateDaemonNamespaces(c)
1001-
return nil
10021007
}

0 commit comments

Comments
 (0)