Skip to content

Commit

Permalink
Merge pull request #1052 from syself/deprecate-rate-limit
Browse files Browse the repository at this point in the history
🌱 Remove deprecated rate limit condition
  • Loading branch information
janiskemper authored Nov 15, 2023
2 parents ba26588 + a41727a commit 6640682
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/v1beta1/conditions_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,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"
)
3 changes: 3 additions & 0 deletions controllers/hetznercluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/services/baremetal/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion pkg/services/hcloud/machinetemplate/machinetemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/services/hcloud/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6640682

Please sign in to comment.