Skip to content

Commit

Permalink
Merge branch 'master' into docs-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jananivMS authored May 18, 2020
2 parents 2f011d6 + f0d9ada commit 51f9a13
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pkg/resourcemanager/eventhubs/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,12 @@ func (e *azureEventHubManager) createEventhubSecrets(ctx context.Context, secret
Namespace: instance.Namespace,
}

err := e.SecretClient.Upsert(ctx,
return e.SecretClient.Upsert(ctx,
key,
data,
secrets.WithOwner(instance),
secrets.WithScheme(e.Scheme),
)
if err != nil {
return err
}

return nil
}

func (e *azureEventHubManager) deleteEventhubSecrets(ctx context.Context, secretName string, instance *azurev1alpha1.Eventhub) error {
Expand Down Expand Up @@ -292,6 +287,21 @@ func (e *azureEventHubManager) Ensure(ctx context.Context, obj runtime.Object, o

err = e.listAccessKeysAndCreateSecrets(resourcegroup, eventhubNamespace, eventhubName, secretName, instance.Spec.AuthorizationRule.Name, instance)
if err != nil {

// catch secret existing and fail reconciliation
errorStr := err.Error()
if strings.Contains(errorStr, "is already owned by another") {

// marking the reconciliation as successful BUT the status message explains the issue
instance.Status.State = string(hub.Status)
instance.Status.Message = "The configured secret name was already owned by another eventhub"
instance.Status.Provisioning = false
instance.Status.Provisioned = false
instance.Status.FailedProvisioning = true
instance.Status.ResourceId = *hub.ID
return true, nil
}

instance.Status.Message = err.Error()
return false, err
}
Expand All @@ -301,6 +311,7 @@ func (e *azureEventHubManager) Ensure(ctx context.Context, obj runtime.Object, o
instance.Status.Message = resourcemanager.SuccessMsg
instance.Status.Provisioning = false
instance.Status.Provisioned = true
instance.Status.FailedProvisioning = false
instance.Status.ResourceId = *hub.ID
return true, nil
}
Expand Down

0 comments on commit 51f9a13

Please sign in to comment.