Skip to content

Commit

Permalink
Merge pull request #14 from vshn/fix/panic-on-not-found
Browse files Browse the repository at this point in the history
Fix panic when StatefulSet is not found
  • Loading branch information
glrf authored Sep 1, 2021
2 parents d29f502 + 3b022ef commit c0f1abf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ func (r *StatefulSetReconciler) Reconcile(ctx context.Context, req ctrl.Request)

sts, err := r.fetchStatefulSet(ctx, req.NamespacedName)
if err != nil {
l.Error(err, "Unable to fetch StatefulSet")
return ctrl.Result{}, err
return ctrl.Result{}, client.IgnoreNotFound(err)
}
if !sts.Resizing() || sts.Failed() {
return ctrl.Result{}, nil
Expand Down
3 changes: 1 addition & 2 deletions controllers/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/vshn/statefulset-resize-controller/statefulset"
Expand Down Expand Up @@ -43,7 +42,7 @@ func (r StatefulSetReconciler) fetchStatefulSet(ctx context.Context, namespacedN
old := &appsv1.StatefulSet{}
err := r.Get(ctx, namespacedName, old)
if err != nil {
return nil, client.IgnoreNotFound(err)
return nil, err
}
sts, err := statefulset.NewEntity(old)
if err != nil {
Expand Down

0 comments on commit c0f1abf

Please sign in to comment.