Skip to content

Commit 2d82752

Browse files
committed
Use a better condition message for pendingFailoverAckExists.
This is required because converting `unack` to string will be always something else and cluster is updated.
1 parent 77aaf86 commit 2d82752

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pkg/mysqlcluster/orc_reconciliation.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ func (f *cFactory) updateStatusForRecoveries(recoveries []orc.TopologyRecovery)
125125
}
126126

127127
if len(unack) > 0 {
128+
msg := getRecoveryTextMsg(unack)
128129
f.cluster.UpdateStatusCondition(api.ClusterConditionFailoverAck,
129-
core.ConditionTrue, "pendingFailoverAckExists", fmt.Sprintf("%v", unack))
130+
core.ConditionTrue, "pendingFailoverAckExists", msg)
130131
} else {
131132
f.cluster.UpdateStatusCondition(api.ClusterConditionFailoverAck,
132133
core.ConditionFalse, "noPendingFailoverAckExists", "no pending ack")
@@ -147,6 +148,7 @@ func (f *cFactory) registerNodesInOrc() error {
147148
}
148149

149150
func (f *cFactory) getRecoveriesToAck(recoveries []orc.TopologyRecovery) (toAck []orc.TopologyRecovery) {
151+
// TODO: check for recoveries that need acknowledge, by excluding already acked recoveries
150152
if len(recoveries) == 0 {
151153
return
152154
}

pkg/mysqlcluster/utils.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"k8s.io/client-go/tools/reference"
3232

3333
api "github.com/presslabs/mysql-operator/pkg/apis/mysql/v1alpha1"
34+
orc "github.com/presslabs/mysql-operator/pkg/util/orchestrator"
3435
)
3536

3637
func ensureProbe(in *core.Probe, ids, ts, ps int32, handler core.Handler) *core.Probe {
@@ -186,3 +187,14 @@ func (f *cFactory) getMasterHost() string {
186187

187188
return masterHost
188189
}
190+
191+
// getRecoveryTextMsg returns a string human readable for cluster recoveries
192+
func getRecoveryTextMsg(acks []orc.TopologyRecovery) string {
193+
text := ""
194+
for _, a := range acks {
195+
text += fmt.Sprintf(" {id: %d, uid: %s, success: %t, time: %s}",
196+
a.Id, a.UID, a.IsSuccessful, a.RecoveryStartTimestamp)
197+
}
198+
199+
return fmt.Sprintf("[%s]", text)
200+
}

0 commit comments

Comments
 (0)