Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/controller/ps/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,6 @@ func (r *PerconaServerMySQLReconciler) reconcileBootstrapStatus(ctx context.Cont
Reason: apiv1.ConditionInnoDBClusterBootstrapped,
Message: fmt.Sprintf("InnoDB cluster successfully bootstrapped with %d nodes",
cr.MySQLSpec().Size),
LastTransitionTime: metav1.Now(),
})

nn := types.NamespacedName{Namespace: cr.Namespace, Name: cr.Name}
Expand Down
8 changes: 5 additions & 3 deletions pkg/controller/ps/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ func (r *PerconaServerMySQLReconciler) reconcileCRStatus(ctx context.Context, cr
if cr == nil || cr.ObjectMeta.DeletionTimestamp != nil {
return nil
}
if err := r.Get(ctx, client.ObjectKeyFromObject(cr), cr); err != nil {
return errors.Wrap(err, "get cluster")
}
Comment on lines +37 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will overwrite anything we assign to status fields in Reconcile function, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it shouldn't cause any issues since we overwrite each field of the status in the reconcileCRStatus method

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure if it's okay, users test failure might be caused by this


initialState := cr.Status.State

clusterCondition := metav1.Condition{
Status: metav1.ConditionTrue,
Type: apiv1.StateInitializing.String(),
LastTransitionTime: metav1.Now(),
Status: metav1.ConditionTrue,
Type: apiv1.StateInitializing.String(),
}

if reconcileErr != nil {
Expand Down
9 changes: 9 additions & 0 deletions pkg/controller/ps/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,15 @@ func TestReconcileStatusAsync(t *testing.T) {
},
}

// reconcileCRStatus should get the latest cr
// We can verify this by passing an empty cluster
cr = &apiv1.PerconaServerMySQL{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name,
Namespace: cr.Namespace,
},
}

err = r.reconcileCRStatus(ctx, cr, nil)
if err != nil {
t.Fatal(err)
Expand Down
12 changes: 5 additions & 7 deletions pkg/controller/psrestore/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sync"
"time"

"github.com/pkg/errors"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -35,8 +36,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/pkg/errors"

apiv1 "github.com/percona/percona-server-mysql-operator/api/v1"
"github.com/percona/percona-server-mysql-operator/pkg/haproxy"
"github.com/percona/percona-server-mysql-operator/pkg/k8s"
Expand Down Expand Up @@ -291,11 +290,10 @@ func (r *PerconaServerMySQLRestoreReconciler) removeBootstrapCondition(ctx conte
}

meta.SetStatusCondition(&c.Status.Conditions, metav1.Condition{
Type: apiv1.ConditionInnoDBClusterBootstrapped,
Status: metav1.ConditionFalse,
Reason: apiv1.ConditionInnoDBClusterBootstrapped,
Message: "InnoDB cluster is not bootstrapped after restore",
LastTransitionTime: metav1.Now(),
Type: apiv1.ConditionInnoDBClusterBootstrapped,
Status: metav1.ConditionFalse,
Reason: apiv1.ConditionInnoDBClusterBootstrapped,
Message: "InnoDB cluster is not bootstrapped after restore",
})

return r.Client.Status().Update(ctx, c)
Expand Down
Loading