Skip to content

Commit

Permalink
feat: support skip syncing matrixonecluster cr
Browse files Browse the repository at this point in the history
  • Loading branch information
loveRhythm1990 committed Oct 23, 2024
1 parent 813ff0f commit b4d0e27
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/controllers/mocluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (

const (
RestoreCompleteAnno = "matrixorigin.io/restore-complete"
annSkipSync = "matrixorigin.io/skip-sync"
)

const (
Expand All @@ -60,6 +61,10 @@ var _ recon.Actor[*v1alpha1.MatrixOneCluster] = &MatrixOneClusterActor{}
type MatrixOneClusterActor struct{}

func (r *MatrixOneClusterActor) Observe(ctx *recon.Context[*v1alpha1.MatrixOneCluster]) (recon.Action[*v1alpha1.MatrixOneCluster], error) {
if ctx.Obj.Annotations[annSkipSync] != "" {
ctx.Log.Info(fmt.Sprintf("skip sync matrixonecluster %v", client.ObjectKeyFromObject(ctx.Obj)))
return nil, nil
}
mo := ctx.Obj
if mo.Spec.RestoreFrom != nil && mo.Annotations[RestoreCompleteAnno] == "" {
// do restore
Expand Down Expand Up @@ -473,6 +478,10 @@ func syncedCondition(mo *v1alpha1.MatrixOneCluster) metav1.Condition {
}

func (r *MatrixOneClusterActor) Finalize(ctx *recon.Context[*v1alpha1.MatrixOneCluster]) (bool, error) {
if ctx.Obj.Annotations[annSkipSync] != "" {
ctx.Log.Info(fmt.Sprintf("skip finalize matrixonecluster %v", client.ObjectKeyFromObject(ctx.Obj)))
return true, nil
}
mo := ctx.Obj
err := ctx.Client.DeleteAllOf(ctx, &v1alpha1.CNSet{}, client.InNamespace(mo.Namespace), client.MatchingLabels(
map[string]string{common.MatrixoneClusterLabelKey: mo.Name},
Expand Down

0 comments on commit b4d0e27

Please sign in to comment.