sigs.k8s.io/cluster-api-provider-azure@v1.14.3/azure/services/privatedns/record_reconciler.go (about)

     1  /*
     2  Copyright 2022 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package privatedns
    18  
    19  import (
    20  	"context"
    21  
    22  	"sigs.k8s.io/cluster-api-provider-azure/azure"
    23  	"sigs.k8s.io/cluster-api-provider-azure/util/tele"
    24  )
    25  
    26  func (s *Service) reconcileRecords(ctx context.Context, records []azure.ResourceSpecGetter) error {
    27  	ctx, _, done := tele.StartSpanWithLogger(ctx, "privatedns.Service.reconcileRecords")
    28  	defer done()
    29  
    30  	var resErr error
    31  
    32  	// We go through the list of links to reconcile each one, independently of the result of the previous one.
    33  	// If multiple errors occur, we return the most pressing one.
    34  	// 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)
    35  	for _, recordSpec := range records {
    36  		if _, err := s.recordReconciler.CreateOrUpdateResource(ctx, recordSpec, serviceName); err != nil {
    37  			if !azure.IsOperationNotDoneError(err) || resErr == nil {
    38  				resErr = err
    39  			}
    40  		}
    41  	}
    42  
    43  	return resErr
    44  }