Skip to content

Commit

Permalink
trap the eventhub secret name issue
Browse files Browse the repository at this point in the history
  • Loading branch information
William Mortl authored and jananivMS committed May 16, 2020
1 parent 1e3b6eb commit 4000be8
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 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,20 @@ 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 = true
instance.Status.ResourceId = *hub.ID
return true, nil
}

instance.Status.Message = err.Error()
return false, err
}
Expand Down

0 comments on commit 4000be8

Please sign in to comment.