Skip to content

Commit

Permalink
🌱 Remove deprecated rate limit condition
Browse files Browse the repository at this point in the history
Removing deprecated rate limit conditions of all objects.
  • Loading branch information
janiskemper committed Nov 13, 2023
1 parent a0c509a commit 3bfbeb0
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 @@ -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.

Check warning on line 203 in api/v1beta1/conditions_const.go

View workflow job for this annotation

GitHub Actions / Lint Pull Request

exported: comment on exported const DeprecatedRateLimitExceeded should be of the form "DeprecatedRateLimitExceeded ..." (revive)
DeprecatedRateLimitExceeded 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.DeprecatedRateLimitExceeded)

// 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.DeprecatedRateLimitExceeded)

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.DeprecatedRateLimitExceeded)

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.DeprecatedRateLimitExceeded)

// detect failure domain
failureDomain, err := s.scope.GetFailureDomain()
Expand Down

0 comments on commit 3bfbeb0

Please sign in to comment.