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

fix: reconciliation spam for controllers #90

Merged
merged 2 commits into from
Feb 8, 2024
Merged
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
9 changes: 6 additions & 3 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ func (s *ClusterScope) Close(ctx context.Context) error {
return s.PatchObject(ctx)
}

// AddFinalizer adds a finalizer and immediately patches the object to avoid any race conditions
// AddFinalizer adds a finalizer if not present and immediately patches the
// object to avoid any race conditions.
func (s *ClusterScope) AddFinalizer(ctx context.Context) error {
controllerutil.AddFinalizer(s.LinodeCluster, infrav1alpha1.GroupVersion.String())
if controllerutil.AddFinalizer(s.LinodeCluster, infrav1alpha1.GroupVersion.String()) {
return s.Close(ctx)
}

return s.Close(ctx)
return nil
}
9 changes: 6 additions & 3 deletions cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ func (s *MachineScope) Close(ctx context.Context) error {
return s.PatchObject(ctx)
}

// AddFinalizer adds a finalizer and immediately patches the object to avoid any race conditions
// AddFinalizer adds a finalizer if not present and immediately patches the
// object to avoid any race conditions.
func (s *MachineScope) AddFinalizer(ctx context.Context) error {
controllerutil.AddFinalizer(s.LinodeMachine, infrav1alpha1.GroupVersion.String())
if controllerutil.AddFinalizer(s.LinodeMachine, infrav1alpha1.GroupVersion.String()) {
return s.Close(ctx)
}

return s.Close(ctx)
return nil
}

// GetBootstrapData returns the bootstrap data from the secret in the Machine's bootstrap.dataSecretName.
Expand Down
9 changes: 6 additions & 3 deletions cloud/scope/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ func (s *VPCScope) Close(ctx context.Context) error {
return s.PatchObject(ctx)
}

// AddFinalizer adds a finalizer and immediately patches the object to avoid any race conditions
// AddFinalizer adds a finalizer if not present and immediately patches the
// object to avoid any race conditions.
func (s *VPCScope) AddFinalizer(ctx context.Context) error {
controllerutil.AddFinalizer(s.LinodeVPC, infrav1alpha1.GroupVersion.String())
if controllerutil.AddFinalizer(s.LinodeVPC, infrav1alpha1.GroupVersion.String()) {
return s.Close(ctx)
}

return s.Close(ctx)
return nil
}
Loading