cybozu-go/moco

Add a status indicating whether or not the MySQLCluster is being updated.

Closed this issue · 4 comments

What

If there is a way to verify that the MySQLCluster update is complete, we can update MySQLCluster in stages using ArgoCD or similar.
MySQLCluster has Available and Healthy statuses, but these do not determine if the MySQLCluster is being updated.

Elasticsearch uses PHASE status to achieve this:
https://github.com/argoproj/argo-cd/blob/03026997d1a30befd89ae90e5f319304d8b25b84/resource_customizations/elasticsearch.k8s.elastic.co/Elasticsearch/health.lua#L28-L40

How

Add status to indicate if MySQLCluster is being updated

Checklist

  • Finish implementation of the issue
  • Test all functions
  • Have enough logs to trace activities
  • Notify developers of necessary actions

@shunki-fujita
Since MySQLCluster creates a StatefulSet, can't we use these?

// replicas is the number of Pods created by the StatefulSet controller.
	Replicas [int32](https://pkg.go.dev/builtin#int32) `json:"replicas" protobuf:"varint,2,opt,name=replicas"`

	// readyReplicas is the number of pods created for this StatefulSet with a Ready Condition.
	ReadyReplicas [int32](https://pkg.go.dev/builtin#int32) `json:"readyReplicas,omitempty" protobuf:"varint,3,opt,name=readyReplicas"`

	// currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version
	// indicated by currentRevision.
	CurrentReplicas [int32](https://pkg.go.dev/builtin#int32) `json:"currentReplicas,omitempty" protobuf:"varint,4,opt,name=currentReplicas"`

	// updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version
	// indicated by updateRevision.
	UpdatedReplicas [int32](https://pkg.go.dev/builtin#int32) `json:"updatedReplicas,omitempty" protobuf:"varint,5,opt,name=updatedReplicas"`

	// currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the
	// sequence [0,currentReplicas).
	CurrentRevision [string](https://pkg.go.dev/builtin#string) `json:"currentRevision,omitempty" protobuf:"bytes,6,opt,name=currentRevision"`

	// updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence
	// [replicas-updatedReplicas,replicas)
	UpdateRevision [string](https://pkg.go.dev/builtin#string) `json:"updateRevision,omitempty" protobuf:"bytes,7,opt,name=updateRevision"`

https://pkg.go.dev/k8s.io/api/apps/v1#StatefulSetStatus

These are all exported by kube-state-metrics.
https://github.com/kubernetes/kube-state-metrics/blob/main/docs/statefulset-metrics.md

@ymmt2005
We want to detect the update status of MySQLCluster by Argo CD properly.
For this purpose, I want to add the following checks to Argo CD.

  1. Reconcile is finished.
    • MySQLCluster's .metadata.generation == .status.reconcileInfo.generation.
  2. Rolling update of StatefulSet is finished.
  3. MySQLCluster is Healthy.

However, I cannot implement check 2 by Argo CD's Lua script.
So we want to add the new status to MySQLCluster.

@masa213f understood.

This feature has been released in MOCO v0.17.0.
#546