Skip to content

Commit

Permalink
fix suspend cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
bxy4543 committed Aug 23, 2024
1 parent 51c1b3c commit abb4c39
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers/account/controllers/namespace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"strings"
"time"

"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

"github.com/minio/madmin-go/v3"

v1 "github.com/labring/sealos/controllers/account/api/v1"
Expand Down Expand Up @@ -205,9 +207,13 @@ func (r *NamespaceReconciler) suspendKBCluster(ctx context.Context, namespace st
ops.Namespace = kbCluster.Namespace
ops.ObjectMeta.Name = "stop-" + kbCluster.Name + "-" + time.Now().Format("2006-01-02-15")
ops.Spec.TTLSecondsAfterSucceed = 1
abort := int32(60 * 60)
ops.Spec.TTLSecondsBeforeAbort = &abort
ops.Spec.ClusterRef = kbCluster.Name
ops.Spec.Type = "Stop"
err := r.Client.Create(ctx, &ops)
_, err := controllerutil.CreateOrUpdate(ctx, r.Client, &ops, func() error {
return nil
})
if err != nil {
r.Log.Error(err, "create ops request failed", "ops", ops.Name, "namespace", ops.Namespace)
}
Expand Down

0 comments on commit abb4c39

Please sign in to comment.