Skip to content

Commit

Permalink
Add disks and groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Jont828 committed Feb 15, 2022
1 parent 1a59ecf commit 41aeb8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions azure/services/disks/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ func (s *Service) Delete(ctx context.Context) error {
ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureServiceReconcileTimeout)
defer cancel()

var result error
specs := s.Scope.DiskSpecs()
if len(specs) == 0 {
return nil
}

// We go through the list of DiskSpecs to delete each one, independently of the result of the previous one.
// If multiple errors occur, we return the most pressing one.
// 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)
for _, diskSpec := range s.Scope.DiskSpecs() {
var result error
for _, diskSpec := range specs {
if err := s.DeleteResource(ctx, diskSpec, serviceName); err != nil {
if !azure.IsOperationNotDoneError(err) || result == nil {
result = err
Expand Down
6 changes: 6 additions & 0 deletions azure/services/groups/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func (s *Service) Reconcile(ctx context.Context) error {
defer cancel()

groupSpec := s.Scope.GroupSpec()
if groupSpec == nil {
return nil
}

_, err := s.CreateResource(ctx, groupSpec, serviceName)
s.Scope.UpdatePutStatus(infrav1.ResourceGroupReadyCondition, serviceName, err)
Expand All @@ -80,6 +83,9 @@ func (s *Service) Delete(ctx context.Context) error {
defer cancel()

groupSpec := s.Scope.GroupSpec()
if groupSpec == nil {
return nil
}

// check that the resource group is not BYO.
managed, err := s.IsGroupManaged(ctx)
Expand Down

0 comments on commit 41aeb8d

Please sign in to comment.