Skip to content

Commit

Permalink
Azure: Stop logging errors during role assignment retry
Browse files Browse the repository at this point in the history
Presumambly due to eventual consistency on Azure, the role assignment
always needs some retries. Do not log an error for each retry, as that
looks like something went wrong which is not the case.
  • Loading branch information
alvaroaleman committed Mar 8, 2022
1 parent 8c6d4f6 commit 5224235
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/infra/azure/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io/ioutil"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -186,14 +185,14 @@ func (o *CreateInfraOptions) Run(ctx context.Context) (*CreateInfraOutput, error
return nil, fmt.Errorf("failed to generate uuid for role assignment name: %w", err)
}

log.Log.Info("Assigning role to managed identity, this may take some time")
for try := 0; try < 100; try++ {
_, err := roleAssignmentClient.Create(ctx, *rg.ID, roleAssignmentName, authorization.RoleAssignmentCreateParameters{RoleAssignmentProperties: &authorization.RoleAssignmentProperties{
RoleDefinitionID: roleDefinitions.Values()[0].ID,
PrincipalID: utilpointer.String(identity.PrincipalID.String()),
}})
if err != nil {
if try < 99 {
log.Log.Info("Role assignment failed, retrying...", "try", strconv.Itoa(try), "err", err)
time.Sleep(time.Second)
continue
}
Expand Down

0 comments on commit 5224235

Please sign in to comment.