Skip to content

Commit

Permalink
Update proposal to allow individual stopping of clustering and reconc…
Browse files Browse the repository at this point in the history
…iliation

Signed-off-by: d-kuro <kurosawa7620@gmail.com>
  • Loading branch information
d-kuro committed Oct 11, 2023
1 parent fcde57d commit b33ede3
Showing 1 changed file with 61 additions and 16 deletions.
77 changes: 61 additions & 16 deletions docs/designdoc/clustering_stop.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,33 @@ Therefore, we are implementing a function to temporarily stop MOCO's clustering
## Goals

* Enable pause and resume of MySQL Cluster clustering
* Enable pausing and resuming the reconciliation loop for the MySQLCluster resource
* Operational with the `kubectl moco` command
* Check the presence or absence of a pause with `kubectl get mysqlcluster`

## Non-goals

* Changes to any MySQLCluster field will not be processed while paused
* Reconciliation loop will be stopped
* Recovery is not guaranteed in the event that the MySQL Cluster is damaged by user operations when resuming from a pause

## ActualDesign

Users can stop the MySQL Cluster clustering with the following command:
Users can stop the MySQL Cluster clustering or reconciliation with the following command:

```console
$ kubectl moco clustering stop <CLSUTER_NAME>
$ kubectl moco stop clustering <CLSUTER_NAME>
$ kubectl moco stop reconciliation <CLSUTER_NAME>
```

To resume clustering, use the following command:
To resume clustering or reconciliation, use the following command:

```console
$ kubectl moco clustering start <CLSUTER_NAME>
$ kubectl moco start clustering <CLSUTER_NAME>
$ kubectl moco start reconciliation <CLSUTER_NAME>
```

When you execute `kubectl moco clustering stop <CLSUTER_NAME>`,
### Clustering

When you execute `kubectl moco stop clustering <CLSUTER_NAME>`,
the `moco.cybozu.com/clustering-stopped: "true"` is added to the `.metadata.annotation` of MySQLCluster.

```yaml
Expand All @@ -43,15 +46,15 @@ metadata:
moco.cybozu.com/clustering-stopped: "true"
```
A MySQLCluster with this annotation will not undergo reconcile.
Also, the MySQL clustering is stopped because the `ClusterManager` is stopped.
This annotation will stop the `ClusterManager` of the annotated MySQLCluster.
Reconciliation processes due to changes in other MySQLCluster fields will continue to be performed.

```go
r.ClusterManager.Stop(req.NamespacedName)
```

The process of stopping the `ClusterManager` is carried out only at the first reconcile
after the execution of `kubectl moco clustering stop <CLSUTER_NAME>`.
after the execution of `kubectl moco stop clustering <CLSUTER_NAME>`.

The `ClusteringStopped` gets added to `.status.conditions` of MySQLCluster.
The time when the `ClusterManager` was stopped is recorded in `.lastTransitionTime`.
Expand All @@ -71,27 +74,69 @@ status:
lastTransitionTime: 2018-01-01T00:00:00Z
```

Also, `STOPPED` will be added to the table displayed when you do `kubectl get mysqlcluster`.
Also, `CLUSTERING STOPPED` will be added to the table displayed when you do `kubectl get mysqlcluster`.

```console
$ kubectl get mysqlcluster
NAME AVAILABLE HEALTHY STOPPED PRIMARY SYNCED REPLICAS ERRANT REPLICAS LAST BACKUP
test Unknown Unknown True 0 2 <no value>
NAME AVAILABLE HEALTHY PRIMARY SYNCED REPLICAS ERRANT REPLICAS CLUSTERING STOPPED RECONCILE STOPPED LAST BACKUP
test Unknown Unknown 0 2 True <no value>
```

When you execute `kubectl moco clustering start <CLSUTER_NAME>`,
When you execute `kubectl moco start clustering <CLSUTER_NAME>`,
`moco.cybozu.com/clustering-stopped: "true"` is removed from `.metadata.annotation` of MySQLCluster.

The controller resumes the reconcile process for `MySQLCluster` that does not have the `moco.cybozu.com/clustering-stopped: "true"` annotation.
The controller resumes the `ClusterManager` for `MySQLCluster` that does not have the `moco.cybozu.com/clustering-stopped: "true"` annotation.
When the `ClusterManager` resumes operation, the `.status` of `ClusteringStopped` in `.status.conditions` is updated to `False`,
and the `.status` of other `.status.conditions` is also updated from `Unknown`.

### Reconciliation

When you execute `kubectl moco stop reconciliation <CLSUTER_NAME>`,
the `moco.cybozu.com/reconciliation-stopped: "true"` is added to the `.metadata.annotation` of MySQLCluster.

```yaml
metadata:
annotations:
moco.cybozu.com/reconciliation-stopped: "true"
```

The reconcile process will not be executed for MySQLCluster resources annotated with this annotation.
Therefore, even if changes are made to the fields of the MySQLCluster resource, changes will not be propagated to other resources.

The only exception is the stopping and restarting of clustering by the `moco.cybozu.com/clustering-stopped` annotation.
Also, the `ClusterManager` does not stop even if the reconcile process is stopped.

The `ReconciliationStopped` gets added to `.status.conditions` of MySQLCluster.

```yaml
status:
conditions:
- type: ReconciliationStopped
status: "True"
lastTransitionTime: 2018-01-01T00:00:00Z
```

Also, `RECONCILE STOPPED` will be added to the table displayed when you do `kubectl get mysqlcluster`.

```console
$ kubectl get mysqlcluster
NAME AVAILABLE HEALTHY PRIMARY SYNCED REPLICAS ERRANT REPLICAS CLUSTERING STOPPED RECONCILE STOPPED LAST BACKUP
test Unknown Unknown 0 2 True <no value>
```

When you execute `kubectl moco start reconciliation <CLSUTER_NAME>`,
`moco.cybozu.com/reconciliation-stopped: "true"` is removed from `.metadata.annotation` of MySQLCluster.

The controller will resume the reconcile of MySQLCluster resources that do not have `moco.cybozu.com/clustering-stopped: "true"`.
If `ReconciliationStopped` in `.status.conditions` is `True` during this time, the controller will update `ReconciliationStopped` to `False`.

### Metrics

The following metrics are added to the moco-controller.

```
moco_cluster_clustering_stopped{name="mycluster", namespace="mynamesapce"} 1
moco_cluster_reconciliation_stopped{name="mycluster", namespace="mynamesapce"} 1
```
1 if the cluster is clustering stopped, 0 otherwise.
1 if the cluster is clustering or reconciliation stopped, 0 otherwise.

0 comments on commit b33ede3

Please sign in to comment.