From 564a8ab519c1a8a0965be9e6d2a6da5227c20073 Mon Sep 17 00:00:00 2001 From: jananivMS Date: Fri, 28 Feb 2020 19:13:39 -0700 Subject: [PATCH] fix causing couple tests to timeout --- .../azuresql/azuresqluser/azuresqluser.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go b/pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go index 5536583bf32..dc38f29339b 100644 --- a/pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go +++ b/pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go @@ -146,27 +146,31 @@ func (s *AzureSqlUserManager) Ensure(ctx context.Context, obj runtime.Object, op } var adminSecretClient secrets.SecretClient - // if the admin credentials haven't been set, default admin credentials to servername - if len(instance.Spec.AdminSecret) == 0 { - instance.Spec.AdminSecret = instance.Namespace + "-" + instance.Spec.Server - } + var key types.NamespacedName // if the admin secret keyvault is not specified, assume it is a kube secret if len(instance.Spec.AdminSecretKeyVault) == 0 { if options.KubeClient != nil { adminSecretClient = k8sSecrets.New(options.KubeClient) + if len(instance.Spec.AdminSecret) == 0 { + instance.Spec.AdminSecret = instance.Spec.Server + } + key = types.NamespacedName{Name: instance.Spec.AdminSecret, Namespace: instance.Namespace} } else { return false, err } } else { adminSecretClient = keyvaultSecrets.New(instance.Spec.AdminSecretKeyVault) + if len(instance.Spec.AdminSecret) == 0 { + instance.Spec.AdminSecret = instance.Namespace + "-" + instance.Spec.Server + } + key = types.NamespacedName{Name: instance.Spec.AdminSecret} } // need this to detect missing databases dbClient := azuresqldb.NewAzureSqlDbManager(s.Log) // get admin creds for server - key := types.NamespacedName{Name: instance.Spec.AdminSecret} adminSecret, err := adminSecretClient.Get(ctx, key) if err != nil { instance.Status.Provisioning = false