Skip to content

Commit 37270b9

Browse files
authored
Merge pull request #3808 from telepresenceio/thallgren/evict-by-patch
Rollout workload when disruption budget prevents pod eviction
2 parents 4c107fc + bee5ec1 commit 37270b9

23 files changed

+578
-255
lines changed

charts/telepresence-oss/templates/trafficManagerRbac/cluster-scope.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ rules:
5656
- get
5757
- list
5858
- watch
59+
{{- if .agentInjector.enabled }}
60+
- patch
61+
{{- end }}
5962
{{- if .workloads.argoRollouts.enabled }}
6063
- apiGroups:
6164
- "argoproj.io"
@@ -65,6 +68,9 @@ rules:
6568
- get
6669
- list
6770
- watch
71+
{{- if .agentInjector.enabled }}
72+
- patch
73+
{{- end }}
6874
{{- end }}
6975
- apiGroups:
7076
- "events.k8s.io"

charts/telepresence-oss/templates/trafficManagerRbac/namespace-scope.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ rules:
7373
- get
7474
- list
7575
- watch
76+
{{- if $interceptEnabled }}
77+
- patch
78+
{{- end }}
7679
{{- if $argoRolloutsEnabled }}
7780
- apiGroups:
7881
- "argoproj.io"

cmd/traffic/cmd/manager/cluster/podwatcher.go

-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ import (
1919
"github.com/telepresenceio/telepresence/v2/pkg/subnet"
2020
)
2121

22-
// PodLister helps list Pods.
23-
// All objects returned here must be treated as read-only.
24-
type PodLister interface {
25-
// List lists all Pods in the indexer.
26-
// Objects returned here must be treated as read-only.
27-
List(selector labels.Selector) (ret []*corev1.Pod, err error)
28-
}
29-
3022
type podWatcher struct {
3123
ipsMap map[netip.Addr]struct{}
3224
timer *time.Timer

cmd/traffic/cmd/manager/mutator/agent_injector.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (a *agentInjector) Inject(ctx context.Context, req *admission.AdmissionRequ
134134
uwkError := k8sapi.UnsupportedWorkloadKindError("")
135135
switch {
136136
case k8sErrors.IsNotFound(err):
137-
dlog.Debugf(ctx, "No workload owner found for pod %s.%s", pod.Name, pod.Namespace)
137+
dlog.Tracef(ctx, "No workload owner found for pod %s.%s", pod.Name, pod.Namespace)
138138
case errors.As(err, &uwkError):
139139
dlog.Debugf(ctx, "Workload owner with %s found for pod %s.%s", uwkError.Error(), pod.Name, pod.Namespace)
140140
default:
@@ -146,19 +146,21 @@ func (a *agentInjector) Inject(ctx context.Context, req *admission.AdmissionRequ
146146
scx = a.agentConfigs.Get(wl.GetName(), wl.GetNamespace())
147147
switch {
148148
case scx == nil:
149-
dlog.Debugf(ctx, "Skipping %s.%s (no agent config)", wl.GetName(), wl.GetNamespace())
149+
dlog.Tracef(ctx, "Skipping %s (no agent config)", wl)
150150
return nil, nil
151151
case scx.AgentConfig().Manual:
152-
dlog.Debugf(ctx, "Skipping webhook where agent is manually injected %s.%s", wl.GetName(), wl.GetNamespace())
152+
dlog.Tracef(ctx, "Skipping webhook where agent is manually injected %s", wl.GetNamespace())
153153
return nil, nil
154154
}
155155
default:
156156
return nil, fmt.Errorf("invalid value %q for annotation %s", ia, agentconfig.InjectAnnotation)
157157
}
158+
return createPatch(ctx, scx.AgentConfig(), pod)
159+
}
158160

161+
func createPatch(ctx context.Context, config *agentconfig.Sidecar, pod *core.Pod) (PatchOps, error) {
159162
var patches PatchOps
160163
var annotations map[string]string
161-
config := scx.AgentConfig()
162164
patches = addInitContainer(pod, config, patches)
163165
patches, annotations = addAgentContainer(ctx, pod, config, patches)
164166
patches = addPullSecrets(pod, config, patches)

0 commit comments

Comments
 (0)