Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VZ-10194 add "deleting" cluster status #123

Open
wants to merge 3 commits into
base: oracle/release/2.7.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/controllers/provisioningv2/cluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (h *handler) updateStatus(objs []runtime.Object, cluster *v1.Cluster, statu
ready = true
}
for _, messageCond := range existing.Status.Conditions {
if messageCond.Type == "Updated" || messageCond.Type == "Provisioned" || messageCond.Type == "Removed" {
if messageCond.Type == "Updated" || messageCond.Type == "Provisioned" || messageCond.Type == "Removed" || messageCond.Type == "Deleting" {
continue
}

Expand Down
16 changes: 15 additions & 1 deletion pkg/controllers/provisioningv2/cluster/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cluster

import (
"fmt"
"github.com/rancher/wrangler/pkg/genericcondition"
"time"

v3 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
Expand All @@ -14,6 +15,10 @@ import (
)

func (h *handler) OnMgmtClusterRemove(_ string, cluster *v3.Cluster) (*v3.Cluster, error) {
rke2.Deleting.SetStatus(cluster, "True")
rke2.Deleting.SetStatusBool(cluster, true)
rke2.Deleting.Reason(cluster, "")
rke2.Deleting.Message(cluster, "")
provisioningClusters, err := h.clusterCache.GetByIndex(ByCluster, cluster.Name)
if err != nil {
return nil, err
Expand Down Expand Up @@ -42,7 +47,16 @@ func (h *handler) OnMgmtClusterRemove(_ string, cluster *v3.Cluster) (*v3.Cluste
func (h *handler) OnClusterRemove(_ string, cluster *v1.Cluster) (*v1.Cluster, error) {
oldStatus := cluster.Status
cluster = cluster.DeepCopy()

// set status as "Deleting"
rke2.Deleting.SetStatus(cluster, "True")
rke2.Deleting.SetStatusBool(cluster, true)
rke2.Deleting.Reason(cluster, "")
rke2.Deleting.Message(cluster, "")
newCond := genericcondition.GenericCondition{
Type: "Deleting",
Status: "True",
}
cluster.Status.Conditions = append(cluster.Status.Conditions, newCond)
err := rke2.DoRemoveAndUpdateStatus(cluster, h.doClusterRemove(cluster), h.clusters.EnqueueAfter)

if equality.Semantic.DeepEqual(oldStatus, cluster.Status) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/controllers/provisioningv2/rke2/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const (
Waiting = condition.Cond("Waiting")
Pending = condition.Cond("Pending")
Removed = condition.Cond("Removed")
Deleting = condition.Cond("Deleting")
PlanApplied = condition.Cond("PlanApplied")
InfrastructureReady = condition.Cond(capi.InfrastructureReadyCondition)
SystemUpgradeControllerReady = condition.Cond("SystemUpgradeControllerReady")
Expand Down Expand Up @@ -264,9 +265,9 @@ func PlanSecretFromBootstrapName(bootstrapName string) string {
func DoRemoveAndUpdateStatus(obj metav1.Object, doRemove func() (string, error), enqueueAfter func(string, string, time.Duration)) error {
if !Provisioned.IsTrue(obj) || !Waiting.IsTrue(obj) || !Pending.IsTrue(obj) {
// Ensure the Removed obj appears in the UI.
Provisioned.SetStatus(obj, "True")
Waiting.SetStatus(obj, "True")
Pending.SetStatus(obj, "True")
Provisioned.SetStatus(obj, "True")
}
message, err := doRemove()
if errors.Is(err, generic.ErrSkip) {
Expand Down