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

Cleanup remote peerings when resource group is deleted #2767

Merged
merged 1 commit into from
Nov 16, 2022
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
13 changes: 7 additions & 6 deletions azure/services/vnetpeerings/vnetpeerings.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
)

const serviceName = "vnetpeerings"
// ServiceName is the name of this service.
const ServiceName = "vnetpeerings"

// VnetPeeringScope defines the scope interface for a subnet service.
type VnetPeeringScope interface {
Expand All @@ -52,7 +53,7 @@ func New(scope VnetPeeringScope) *Service {

// Name returns the service name.
func (s *Service) Name() string {
return serviceName
return ServiceName
}

// Reconcile idempotently creates or updates a peering.
Expand All @@ -73,14 +74,14 @@ func (s *Service) Reconcile(ctx context.Context) error {
// Order of precedence (highest -> lowest) is: error that is not an operationNotDoneError (i.e. error creating) -> operationNotDoneError (i.e. creating in progress) -> no error (i.e. created)
var result error
for _, peeringSpec := range specs {
if _, err := s.CreateOrUpdateResource(ctx, peeringSpec, serviceName); err != nil {
if _, err := s.CreateOrUpdateResource(ctx, peeringSpec, ServiceName); err != nil {
if !azure.IsOperationNotDoneError(err) || result == nil {
result = err
}
}
}

s.Scope.UpdatePutStatus(infrav1.VnetPeeringReadyCondition, serviceName, result)
s.Scope.UpdatePutStatus(infrav1.VnetPeeringReadyCondition, ServiceName, result)
return result
}

Expand All @@ -102,13 +103,13 @@ func (s *Service) Delete(ctx context.Context) error {
// Order of precedence (highest -> lowest) is: error that is not an operationNotDoneError (i.e. error deleting) -> operationNotDoneError (i.e. deleting in progress) -> no error (i.e. deleted)
var result error
for _, peeringSpec := range specs {
if err := s.DeleteResource(ctx, peeringSpec, serviceName); err != nil {
if err := s.DeleteResource(ctx, peeringSpec, ServiceName); err != nil {
if !azure.IsOperationNotDoneError(err) || result == nil {
result = err
}
}
}
s.Scope.UpdateDeleteStatus(infrav1.VnetPeeringReadyCondition, serviceName, result)
s.Scope.UpdateDeleteStatus(infrav1.VnetPeeringReadyCondition, ServiceName, result)
return result
}

Expand Down
Loading