From 4000be8f066f031dfb9b5616c54977887871d50f Mon Sep 17 00:00:00 2001 From: William Mortl Date: Wed, 6 May 2020 15:31:19 -0700 Subject: [PATCH 1/2] trap the eventhub secret name issue --- pkg/resourcemanager/eventhubs/hub.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/resourcemanager/eventhubs/hub.go b/pkg/resourcemanager/eventhubs/hub.go index ba6fcce7e96..aa275617492 100644 --- a/pkg/resourcemanager/eventhubs/hub.go +++ b/pkg/resourcemanager/eventhubs/hub.go @@ -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 { @@ -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 } From f0d9adaea5640dc1f29e9b1b7bd68ab7aa0d5ecf Mon Sep 17 00:00:00 2001 From: William Mortl Date: Thu, 7 May 2020 08:12:18 -0700 Subject: [PATCH 2/2] erin feedback --- pkg/resourcemanager/eventhubs/hub.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/resourcemanager/eventhubs/hub.go b/pkg/resourcemanager/eventhubs/hub.go index aa275617492..0bd8e4c9268 100644 --- a/pkg/resourcemanager/eventhubs/hub.go +++ b/pkg/resourcemanager/eventhubs/hub.go @@ -296,7 +296,8 @@ func (e *azureEventHubManager) Ensure(ctx context.Context, obj runtime.Object, o 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.Provisioned = false + instance.Status.FailedProvisioning = true instance.Status.ResourceId = *hub.ID return true, nil } @@ -310,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 }