From a41727a8e48eaa84afa426d3b64001b1e6fd89b6 Mon Sep 17 00:00:00 2001 From: janiskemper Date: Mon, 13 Nov 2023 12:56:04 +0100 Subject: [PATCH] :seedling: Remove deprecated rate limit condition Removing deprecated rate limit conditions of all objects. --- api/v1beta1/conditions_const.go | 3 +++ controllers/hetznercluster_controller.go | 3 +++ pkg/services/baremetal/host/host.go | 1 + pkg/services/hcloud/machinetemplate/machinetemplate.go | 7 ++++++- pkg/services/hcloud/server/server.go | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/v1beta1/conditions_const.go b/api/v1beta1/conditions_const.go index 7068febb1..c4fc1eb6b 100644 --- a/api/v1beta1/conditions_const.go +++ b/api/v1beta1/conditions_const.go @@ -199,4 +199,7 @@ const ( // DeprecatedAssociateBMHCondition reports on whether the Hetzner cluster is in ready state. DeprecatedAssociateBMHCondition clusterv1.ConditionType = "AssociateBMHCondition" + + // DeprecatedRateLimitExceededCondition reports whether the rate limit has been reached. + DeprecatedRateLimitExceededCondition clusterv1.ConditionType = "RateLimitExceeded" ) diff --git a/controllers/hetznercluster_controller.go b/controllers/hetznercluster_controller.go index d52b96c66..133ce2680 100644 --- a/controllers/hetznercluster_controller.go +++ b/controllers/hetznercluster_controller.go @@ -152,6 +152,9 @@ func (r *HetznerClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reque } }() + // delete the deprecated condition from existing cluster objects + conditions.Delete(hetznerCluster, infrav1.DeprecatedRateLimitExceededCondition) + // check whether rate limit has been reached and if so, then wait. if wait := reconcileRateLimit(hetznerCluster, r.RateLimitWaitTime); wait { return ctrl.Result{RequeueAfter: 30 * time.Second}, nil diff --git a/pkg/services/baremetal/host/host.go b/pkg/services/baremetal/host/host.go index a8b0fc4f4..f21e0255e 100644 --- a/pkg/services/baremetal/host/host.go +++ b/pkg/services/baremetal/host/host.go @@ -99,6 +99,7 @@ func (s *Service) Reconcile(ctx context.Context) (result reconcile.Result, err e // remove deprecated conditions conditions.Delete(s.scope.HetznerBareMetalHost, infrav1.DeprecatedHetznerBareMetalHostReadyCondition) conditions.Delete(s.scope.HetznerBareMetalHost, infrav1.DeprecatedHostProvisionSucceededCondition) + conditions.Delete(s.scope.HetznerBareMetalHost, infrav1.DeprecatedRateLimitExceededCondition) conditions.SetSummary(s.scope.HetznerBareMetalHost) diff --git a/pkg/services/hcloud/machinetemplate/machinetemplate.go b/pkg/services/hcloud/machinetemplate/machinetemplate.go index 757467fcc..0b51cce70 100644 --- a/pkg/services/hcloud/machinetemplate/machinetemplate.go +++ b/pkg/services/hcloud/machinetemplate/machinetemplate.go @@ -22,7 +22,9 @@ import ( "fmt" corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/cluster-api/util/conditions" + infrav1 "github.com/syself/cluster-api-provider-hetzner/api/v1beta1" "github.com/syself/cluster-api-provider-hetzner/pkg/scope" hcloudutil "github.com/syself/cluster-api-provider-hetzner/pkg/services/hcloud/util" ) @@ -39,8 +41,11 @@ func NewService(scope *scope.HCloudMachineTemplateScope) *Service { } } -// Reconcile implements reconcilement of HCloud machines. +// Reconcile implements reconcilement of HCloudMachinesTemplates. func (s *Service) Reconcile(ctx context.Context) error { + // delete the deprecated condition from existing machinetemplate objects + conditions.Delete(s.scope.HCloudMachineTemplate, infrav1.DeprecatedRateLimitExceededCondition) + capacity, err := s.getCapacity(ctx) if err != nil { return fmt.Errorf("failed to get capacity: %w", err) diff --git a/pkg/services/hcloud/server/server.go b/pkg/services/hcloud/server/server.go index 4a836d0c9..3e34c5df7 100644 --- a/pkg/services/hcloud/server/server.go +++ b/pkg/services/hcloud/server/server.go @@ -65,6 +65,7 @@ func (s *Service) Reconcile(ctx context.Context) (res reconcile.Result, err erro // delete the deprecated condition from existing machine objects conditions.Delete(s.scope.HCloudMachine, infrav1.DeprecatedInstanceReadyCondition) conditions.Delete(s.scope.HCloudMachine, infrav1.DeprecatedInstanceBootstrapReadyCondition) + conditions.Delete(s.scope.HCloudMachine, infrav1.DeprecatedRateLimitExceededCondition) // detect failure domain failureDomain, err := s.scope.GetFailureDomain()