Skip to content

Commit

Permalink
Ensure FailedProvisioning=false when Provisioned=true
Browse files Browse the repository at this point in the history
A user reported a case where a RedisCache was provisioned and working
but was marked as FailedProvisioning=true. This seems to have happened
because it initially failed (possibly a temporary error that we aren't
checking for), and then on a subsequent periodic reconciliation the
ARM query reported that it was deployed successfully. Use the
SetProvisioned helper method to prevent this state.
  • Loading branch information
babbageclunk committed Apr 6, 2021
1 parent bfabead commit d26936f
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions pkg/resourcemanager/rediscaches/redis/rediscache_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object
instance.Status.Message = err.Error()
return false, err
}
instance.Status.Message = resourcemanager.SuccessMsg
instance.Status.State = string(newRc.ProvisioningState)

if newRc.StaticIP != nil {
instance.Status.Output = *newRc.StaticIP
}

instance.Status.ResourceId = *newRc.ID
instance.Status.Provisioned = true
instance.Status.Provisioning = false
instance.Status.SetProvisioned(resourcemanager.SuccessMsg)
return true, nil
}

Expand All @@ -70,8 +68,7 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object
}

// actually provision the redis cache
instance.Status.Provisioning = true
instance.Status.FailedProvisioning = false
instance.Status.SetProvisioning("")
_, err = rc.CreateRedisCache(ctx, *instance)
if err != nil {
instance.Status.Message = errhelp.StripErrorIDs(err)
Expand All @@ -90,18 +87,15 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object

// handle the error
if helpers.ContainsString(catchInProgress, azerr.Type) {
instance.Status.Message = "RedisCache exists but may not be ready"
instance.Status.SetProvisioning("RedisCache exists but may not be ready")
return false, nil
} else if helpers.ContainsString(catchKnownError, azerr.Type) {
// TODO: Not sure why we want this to be provisioning=false?
instance.Status.Provisioning = false
return false, nil
} else {

// serious error occured, end reconcilliation and mark it as failed
instance.Status.Message = fmt.Sprintf("Error occurred creating the RedisCache: %s", errhelp.StripErrorIDs(err))
instance.Status.Provisioned = false
instance.Status.Provisioning = false
instance.Status.FailedProvisioning = true
instance.Status.SetFailedProvisioning(fmt.Sprintf("Error occurred creating the RedisCache: %s", errhelp.StripErrorIDs(err)))
return true, nil
}
}
Expand Down

0 comments on commit d26936f

Please sign in to comment.