Skip to content

Commit ed5a5ce

Browse files
pooknullhors
andauthored
K8SPS-375: reduce error logs on cluster startup (#837)
https://perconadev.atlassian.net/browse/K8SPS-375 Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent 43da21a commit ed5a5ce

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pkg/controller/ps/controller.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,18 @@ func (r *PerconaServerMySQLReconciler) Reconcile(
123123
return ctrl.Result{}, nil
124124
}
125125

126-
return rr, errors.Wrap(err, "get CR")
126+
return ctrl.Result{}, errors.Wrap(err, "get CR")
127127
}
128128

129129
if cr.ObjectMeta.DeletionTimestamp != nil {
130-
return rr, r.applyFinalizers(ctx, cr)
130+
if err := r.applyFinalizers(ctx, cr); err != nil {
131+
return ctrl.Result{}, errors.Wrap(err, "apply finalizers")
132+
}
133+
return rr, nil
131134
}
132135

133136
if err = r.doReconcile(ctx, cr); err != nil {
134-
return rr, errors.Wrap(err, "reconcile")
137+
return ctrl.Result{}, errors.Wrap(err, "reconcile")
135138
}
136139

137140
return rr, nil

pkg/controller/ps/upgrade.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package ps
22

33
import (
44
"context"
5-
"k8s.io/apimachinery/pkg/util/wait"
65
"time"
76

87
"github.com/pkg/errors"
@@ -11,6 +10,7 @@ import (
1110
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1211
"k8s.io/apimachinery/pkg/labels"
1312
"k8s.io/apimachinery/pkg/types"
13+
"k8s.io/apimachinery/pkg/util/wait"
1414
k8sretry "k8s.io/client-go/util/retry"
1515
"sigs.k8s.io/controller-runtime/pkg/client"
1616
logf "sigs.k8s.io/controller-runtime/pkg/log"
@@ -33,6 +33,9 @@ func (r *PerconaServerMySQLReconciler) smartUpdate(ctx context.Context, sts *app
3333
Namespace: sts.Namespace,
3434
}, currentSet)
3535
if err != nil {
36+
if k8serrors.IsNotFound(err) {
37+
return nil
38+
}
3639
return errors.Wrap(err, "failed to get current sts")
3740
}
3841

@@ -133,7 +136,6 @@ func (r *PerconaServerMySQLReconciler) smartUpdate(ctx context.Context, sts *app
133136
}
134137
return nil
135138
})
136-
137139
if err != nil {
138140
log.Info("smart update of primary pod did not finish correctly after 5 retries")
139141
return err
@@ -142,7 +144,6 @@ func (r *PerconaServerMySQLReconciler) smartUpdate(ctx context.Context, sts *app
142144
log.Info("primary pod updated", "pod", primPod.Name)
143145
log.Info("smart update finished")
144146
return nil
145-
146147
}
147148

148149
func stsChanged(sts *appsv1.StatefulSet, pods []corev1.Pod) bool {
@@ -151,7 +152,6 @@ func stsChanged(sts *appsv1.StatefulSet, pods []corev1.Pod) bool {
151152
for _, pod := range pods {
152153
if pod.ObjectMeta.Labels["controller-revision-hash"] != sts.Status.UpdateRevision {
153154
return true
154-
155155
}
156156
}
157157

@@ -207,7 +207,6 @@ func deletePod(ctx context.Context, cli client.Client, pod *corev1.Pod, sts *app
207207

208208
if s.Status.ReadyReplicas == s.Status.Replicas {
209209
return errors.New("sts.Status.readyReplicas not updated")
210-
211210
}
212211

213212
return nil

0 commit comments

Comments
 (0)