diff --git a/api/v1alpha1/tenantcontrolplane_status.go b/api/v1alpha1/tenantcontrolplane_status.go index 812223d..6b38625 100644 --- a/api/v1alpha1/tenantcontrolplane_status.go +++ b/api/v1alpha1/tenantcontrolplane_status.go @@ -183,11 +183,12 @@ type KubernetesStatus struct { Ingress *KubernetesIngressStatus `json:"ingress,omitempty"` } -// +kubebuilder:validation:Enum=Provisioning;CertificateAuthorityRotating;Upgrading;Migrating;Ready;NotReady +// +kubebuilder:validation:Enum=Provisioning;CertificateAuthorityRotating;Upgrading;Migrating;Ready;NotReady;Sleeping type KubernetesVersionStatus string var ( VersionProvisioning KubernetesVersionStatus = "Provisioning" + VersionSleeping KubernetesVersionStatus = "Sleeping" VersionCARotating KubernetesVersionStatus = "CertificateAuthorityRotating" VersionUpgrading KubernetesVersionStatus = "Upgrading" VersionMigrating KubernetesVersionStatus = "Migrating" diff --git a/charts/kamaji/crds/kamaji.clastix.io_tenantcontrolplanes.yaml b/charts/kamaji/crds/kamaji.clastix.io_tenantcontrolplanes.yaml index bb26cdc..b51b1c1 100644 --- a/charts/kamaji/crds/kamaji.clastix.io_tenantcontrolplanes.yaml +++ b/charts/kamaji/crds/kamaji.clastix.io_tenantcontrolplanes.yaml @@ -7379,6 +7379,7 @@ spec: - Migrating - Ready - NotReady + - Sleeping type: string version: description: Version is the running Kubernetes version of the Tenant Control Plane. diff --git a/controllers/soot/manager.go b/controllers/soot/manager.go index d3e7a34..93b9410 100644 --- a/controllers/soot/manager.go +++ b/controllers/soot/manager.go @@ -136,17 +136,16 @@ func (m *Manager) Reconcile(ctx context.Context, request reconcile.Request) (res return reconcile.Result{}, err } + tcpStatus := ptr.Deref(tcp.Status.Kubernetes.Version.Status, kamajiv1alpha1.VersionProvisioning) // Handling finalizer if the TenantControlPlane is marked for deletion or scaled to zero: // the clean-up function is already taking care to stop the manager, if this exists. - if tcp.GetDeletionTimestamp() != nil || ptr.Deref(tcp.Spec.ControlPlane.Deployment.Replicas, 0) == 0 { + if tcp.GetDeletionTimestamp() != nil || tcpStatus == kamajiv1alpha1.VersionSleeping { if controllerutil.ContainsFinalizer(tcp, finalizers.SootFinalizer) { return reconcile.Result{}, m.cleanup(ctx, request, tcp) } return reconcile.Result{}, nil } - - tcpStatus := *tcp.Status.Kubernetes.Version.Status // Triggering the reconciliation of the underlying controllers of // the soot manager if this is already registered. v, ok := m.sootMap[request.String()] @@ -181,7 +180,7 @@ func (m *Manager) Reconcile(ctx context.Context, request reconcile.Request) (res } // No need to start a soot manager if the TenantControlPlane is not ready: // enqueuing back is not required since we're going to get that event once ready. - if tcpStatus == kamajiv1alpha1.VersionNotReady || tcpStatus == kamajiv1alpha1.VersionCARotating { + if tcpStatus == kamajiv1alpha1.VersionNotReady || tcpStatus == kamajiv1alpha1.VersionCARotating || tcpStatus == kamajiv1alpha1.VersionSleeping { log.FromContext(ctx).Info("skipping start of the soot manager for a not ready instance") return reconcile.Result{}, nil diff --git a/controllers/telemetry_controller.go b/controllers/telemetry_controller.go index 806d333..22e1228 100644 --- a/controllers/telemetry_controller.go +++ b/controllers/telemetry_controller.go @@ -12,6 +12,7 @@ import ( "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" @@ -81,7 +82,7 @@ func (m *TelemetryController) collectStats(ctx context.Context, uid string) { for _, tcp := range tcpList.Items { switch { - case tcp.Spec.ControlPlane.Deployment.Replicas == nil || *tcp.Spec.ControlPlane.Deployment.Replicas == 0: + case ptr.Deref(tcp.Status.Kubernetes.Version.Status, kamajiv1alpha1.VersionProvisioning) == kamajiv1alpha1.VersionSleeping: stats.TenantControlPlanes.Sleeping++ case tcp.Status.Kubernetes.Version.Status != nil && *tcp.Status.Kubernetes.Version.Status == kamajiv1alpha1.VersionNotReady: stats.TenantControlPlanes.NotReady++ diff --git a/docs/content/reference/api.md b/docs/content/reference/api.md index c312387..e3b181f 100644 --- a/docs/content/reference/api.md +++ b/docs/content/reference/api.md @@ -16199,7 +16199,7 @@ KubernetesVersion contains the information regarding the running Kubernetes vers