Skip to content

Commit a187d99

Browse files
authored
[release/v1.4] fix: make topology injector best effort (#5891) (#5895)
fix: make topology injector best effort (#5891) * fix: make topology injector best effort * allow pods even if there is an internal error in the webhook processing the request Relates to #5890 * fix build --------- (cherry picked from commit 5b8269d) Signed-off-by: Arko Dasgupta <[email protected]>
1 parent b84117a commit a187d99

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

internal/provider/kubernetes/topology_injector.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package kubernetes
88
import (
99
"context"
1010
"fmt"
11-
"net/http"
1211

1312
"github.com/go-openapi/jsonpointer"
1413
corev1 "k8s.io/api/core/v1"
@@ -31,7 +30,7 @@ func (m *ProxyTopologyInjector) Handle(ctx context.Context, req admission.Reques
3130
if err := m.Decoder.Decode(req, binding); err != nil {
3231
klog.Error(err, "decoding binding failed", "request.ObjectKind", req.Object.Object.GetObjectKind())
3332
topologyInjectorEventsTotal.WithFailure(metrics.ReasonError).Increment()
34-
return admission.Errored(http.StatusInternalServerError, err)
33+
return admission.Allowed("internal error, skipped")
3534
}
3635

3736
if binding.Target.Name == "" {
@@ -48,7 +47,7 @@ func (m *ProxyTopologyInjector) Handle(ctx context.Context, req admission.Reques
4847
if err := m.Get(ctx, podName, pod); err != nil {
4948
klog.Error(err, "get pod failed", "pod", podName.String())
5049
topologyInjectorEventsTotal.WithFailure(metrics.ReasonError).Increment()
51-
return admission.Errored(http.StatusInternalServerError, err)
50+
return admission.Allowed("internal error, skipped")
5251
}
5352

5453
// Skip non-proxy pods
@@ -65,7 +64,7 @@ func (m *ProxyTopologyInjector) Handle(ctx context.Context, req admission.Reques
6564
if err := m.Get(ctx, nodeName, node); err != nil {
6665
klog.Error(err, "get node failed", "node", node.Name)
6766
topologyInjectorEventsTotal.WithFailure(metrics.ReasonError).Increment()
68-
return admission.Errored(http.StatusInternalServerError, err)
67+
return admission.Allowed("internal error, skipped")
6968
}
7069

7170
var patch string
@@ -77,7 +76,7 @@ func (m *ProxyTopologyInjector) Handle(ctx context.Context, req admission.Reques
7776
if err := m.Patch(ctx, pod, rawPatch); err != nil {
7877
klog.Error(err, "patch pod failed", "pod", podName.String())
7978
topologyInjectorEventsTotal.WithFailure(metrics.ReasonError).Increment()
80-
return admission.Errored(http.StatusInternalServerError, err)
79+
return admission.Allowed("internal error, skipped")
8180
}
8281
klog.V(1).Info("patch pod succeeded", "pod", podName.String())
8382
topologyInjectorEventsTotal.WithSuccess().Increment()

0 commit comments

Comments
 (0)