Skip to content

Commit

Permalink
fix(controllers): prevent crash at start when some pods are terminating
Browse files Browse the repository at this point in the history
  • Loading branch information
paullaffitte authored and Nicolasgouze committed Apr 19, 2024
1 parent e563353 commit e189105
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/v1/pod_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/google/go-containerregistry/pkg/name"
admissionv1 "k8s.io/api/admission/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -188,7 +189,7 @@ func (p *PodInitializer) Start(ctx context.Context) error {
for _, pod := range pods.Items {
setupLog.Info("patching " + pod.Namespace + "/" + pod.Name)
err := p.Client.Patch(context.Background(), &pod, client.RawPatch(types.JSONPatchType, []byte("[]")))
if err != nil {
if err != nil && !apierrors.IsNotFound(err) {
return err
}
}
Expand Down

0 comments on commit e189105

Please sign in to comment.