From 49e835acd8d8cb23d1ed909991e024bde9dfa931 Mon Sep 17 00:00:00 2001 From: Erin Corson Date: Tue, 24 Mar 2020 17:46:03 -0600 Subject: [PATCH 01/20] add fields for subnetid, staticip, redisconfid --- api/v1alpha1/rediscache_types.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/v1alpha1/rediscache_types.go b/api/v1alpha1/rediscache_types.go index 537b55c461a..5be9f1b259b 100644 --- a/api/v1alpha1/rediscache_types.go +++ b/api/v1alpha1/rediscache_types.go @@ -26,9 +26,11 @@ type RedisCacheSpec struct { // RedisCacheProperties the properties of the Redis Cache. type RedisCacheProperties struct { - Sku RedisCacheSku `json:"sku,omitempty"` - - EnableNonSslPort bool `json:"enableNonSslPort,omitempty"` + Sku RedisCacheSku `json:"sku,omitempty"` + EnableNonSslPort bool `json:"enableNonSslPort,omitempty"` + SubnetID string `json:"subnetId,omitempty"` + StaticIP string `json:"staticIp,omitempty"` + RedisConfiguration map[string]string `json:"configuration,omitempty"` } // RedisCacheSku the SKU of the Redis Cache. From c2c881516f3c7021611c9f64c77fe99b3f990903 Mon Sep 17 00:00:00 2001 From: Erin Corson Date: Tue, 24 Mar 2020 17:47:10 -0600 Subject: [PATCH 02/20] pass new property fields to Azure during redis-cache creation --- .../rediscaches/rediscache_manager.go | 7 +-- .../rediscaches/rediscache_reconcile.go | 14 +---- .../rediscaches/rediscaches.go | 62 +++++++++++++------ 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/pkg/resourcemanager/rediscaches/rediscache_manager.go b/pkg/resourcemanager/rediscaches/rediscache_manager.go index a046e74e7a1..bc6b237cefe 100644 --- a/pkg/resourcemanager/rediscaches/rediscache_manager.go +++ b/pkg/resourcemanager/rediscaches/rediscache_manager.go @@ -15,12 +15,7 @@ import ( type RedisCacheManager interface { // CreateRedisCache creates a new RedisCache CreateRedisCache(ctx context.Context, - groupName string, - redisCacheName string, - location string, - sku azurev1alpha1.RedisCacheSku, - enableNonSSLPort bool, - tags map[string]*string) (*redis.ResourceType, error) + instance azurev1alpha1.RedisCache) (*redis.ResourceType, error) // DeleteRedisCache removes the resource group named by env var DeleteRedisCache(ctx context.Context, groupName string, redisCacheName string) (result redis.DeleteFuture, err error) diff --git a/pkg/resourcemanager/rediscaches/rediscache_reconcile.go b/pkg/resourcemanager/rediscaches/rediscache_reconcile.go index b44f089bcf7..53c575eccc2 100644 --- a/pkg/resourcemanager/rediscaches/rediscache_reconcile.go +++ b/pkg/resourcemanager/rediscaches/rediscache_reconcile.go @@ -33,19 +33,9 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object return false, err } - redisName := instance.ObjectMeta.Name + redisName := instance.Name groupName := instance.Spec.ResourceGroupName name := instance.ObjectMeta.Name - location := instance.Spec.Location - sku := instance.Spec.Properties.Sku - enableNonSSLPort := instance.Spec.Properties.EnableNonSslPort - - // convert kube labels to expected tag format - labels := map[string]*string{} - for k, v := range instance.GetLabels() { - value := v - labels[k] = &value - } if len(instance.Spec.SecretName) == 0 { instance.Spec.SecretName = redisName @@ -74,7 +64,7 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object } instance.Status.Message = fmt.Sprintf("RedisCache Get error %s", err.Error()) - _, err = rc.CreateRedisCache(ctx, groupName, name, location, sku, enableNonSSLPort, labels) + _, err = rc.CreateRedisCache(ctx, *instance) if err != nil { instance.Status.Message = err.Error() instance.Status.Provisioning = false diff --git a/pkg/resourcemanager/rediscaches/rediscaches.go b/pkg/resourcemanager/rediscaches/rediscaches.go index 4ddb1dcbea9..700692563be 100644 --- a/pkg/resourcemanager/rediscaches/rediscaches.go +++ b/pkg/resourcemanager/rediscaches/rediscaches.go @@ -6,6 +6,7 @@ package rediscaches import ( "context" "errors" + "fmt" "log" "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis" @@ -49,15 +50,20 @@ func getRedisCacheClient() (redis.Client, error) { } // CreateRedisCache creates a new RedisCache -func (r *AzureRedisCacheManager) CreateRedisCache(ctx context.Context, - groupName string, - redisCacheName string, - location string, - sku azurev1alpha1.RedisCacheSku, - enableNonSSLPort bool, - tags map[string]*string) (*redis.ResourceType, error) { - redisClient, err := getRedisCacheClient() +func (r *AzureRedisCacheManager) CreateRedisCache( + ctx context.Context, + instance azurev1alpha1.RedisCache) (*redis.ResourceType, error) { + + props := instance.Spec.Properties + // convert kube labels to expected tag format + tags := map[string]*string{} + for k, v := range instance.GetLabels() { + value := v + tags[k] = &value + } + + redisClient, err := getRedisCacheClient() if err != nil { return nil, err } @@ -65,7 +71,7 @@ func (r *AzureRedisCacheManager) CreateRedisCache(ctx context.Context, //Check if name is available redisType := "Microsoft.Cache/redis" checkNameParams := redis.CheckNameAvailabilityParameters{ - Name: &redisCacheName, + Name: &instance.Name, Type: &redisType, } checkNameResult, err := redisClient.CheckNameAvailability(ctx, checkNameParams) @@ -74,27 +80,47 @@ func (r *AzureRedisCacheManager) CreateRedisCache(ctx context.Context, } if checkNameResult.StatusCode != 200 { - log.Println("redis cache name (%s) not available: " + redisCacheName + checkNameResult.Status) + log.Println("redis cache name (%s) not available: " + instance.Name + checkNameResult.Status) return nil, errors.New("redis cache name not available") } - redisSku := redis.Sku{ - Name: redis.SkuName(sku.Name), - Family: redis.SkuFamily(sku.Family), - Capacity: to.Int32Ptr(sku.Capacity), + redisSku := &redis.Sku{ + Name: redis.SkuName(props.Sku.Name), + Family: redis.SkuFamily(props.Sku.Family), + Capacity: to.Int32Ptr(props.Sku.Capacity), } createParams := redis.CreateParameters{ - Location: to.StringPtr(location), + Location: to.StringPtr(instance.Spec.Location), Tags: tags, CreateProperties: &redis.CreateProperties{ - EnableNonSslPort: &enableNonSSLPort, - Sku: &redisSku, + EnableNonSslPort: &props.EnableNonSslPort, + Sku: redisSku, }, } + // handle vnet settings + if len(props.SubnetID) > 0 { + if len(props.StaticIP) == 0 { + return nil, fmt.Errorf("subnet id provided but no static ip has been set") + } + createParams.CreateProperties.SubnetID = &props.SubnetID + createParams.CreateProperties.StaticIP = &props.StaticIP + } + + // set redis config if one was provided + if len(props.RedisConfiguration) > 0 { + config := map[string]*string{} + for k, v := range props.RedisConfiguration { + value := v + config[k] = &value + } + createParams.CreateProperties.RedisConfiguration = config + } + future, err := redisClient.Create( - ctx, groupName, redisCacheName, createParams) + ctx, instance.Spec.ResourceGroupName, instance.Name, createParams, + ) if err != nil { return nil, err } From dbb893e06d83e86af9bf11abb50fb3b988d07ecb Mon Sep 17 00:00:00 2001 From: Erin Corson Date: Tue, 24 Mar 2020 18:36:55 -0600 Subject: [PATCH 03/20] add example usage --- config/samples/azure_v1alpha1_rediscache.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/samples/azure_v1alpha1_rediscache.yaml b/config/samples/azure_v1alpha1_rediscache.yaml index 412f7fb3fa7..59bed31c424 100644 --- a/config/samples/azure_v1alpha1_rediscache.yaml +++ b/config/samples/azure_v1alpha1_rediscache.yaml @@ -17,6 +17,9 @@ spec: family: C capacity: 1 enableNonSslPort: true + ## Optional - vnet usage may require a higher tier sku + #subnetId: /subscriptions/{SUBID}/resourceGroups/{resourcegroupName}/providers/Microsoft.Network/virtualNetworks/{vnet name}/subnets/{subnet name} + #staticIp: 172.22.0.10 # Use the field below to optionally specify a different keyvault # to store the primary and secondary key secrets in #keyVaultToStoreSecrets: asoSecretKeyVault \ No newline at end of file From 49b951e5e84e0b6251d6303159c0c5e83bd0f2fa Mon Sep 17 00:00:00 2001 From: jpflueger Date: Wed, 25 Mar 2020 17:05:18 -0600 Subject: [PATCH 04/20] updating provisioning flags --- .../azuresql/azuresqldb/azuresqldb_reconcile.go | 2 ++ .../azuresqlvnetrule_reconcile.go | 16 +++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go index 637569122a5..07a0c73a304 100644 --- a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go @@ -75,6 +75,7 @@ func (db *AzureSqlDbManager) Ensure(ctx context.Context, obj runtime.Object, opt } if !helpers.ContainsString(ignore, azerr.Type) { instance.Status.Message = err.Error() + instance.Status.Provisioning = false return false, fmt.Errorf("AzureSqlDb GetDB error %v", err) } } @@ -100,6 +101,7 @@ func (db *AzureSqlDbManager) Ensure(ctx context.Context, obj runtime.Object, opt return false, nil } + instance.Status.Provisioning = false return true, fmt.Errorf("AzureSqlDb CreateOrUpdate error %v", err) } diff --git a/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go index 2aa1c31ab2d..ee4745cd0d1 100644 --- a/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go @@ -34,14 +34,12 @@ func (vr *AzureSqlVNetRuleManager) Ensure(ctx context.Context, obj runtime.Objec vnetrule, err := vr.GetSQLVNetRule(ctx, groupName, server, ruleName) if err == nil { - if vnetrule.VirtualNetworkRuleProperties != nil { - if vnetrule.VirtualNetworkRuleProperties.State == sql.Ready { - instance.Status.Provisioning = false - instance.Status.Provisioned = true - instance.Status.Message = resourcemanager.SuccessMsg - instance.Status.ResourceId = *vnetrule.ID - return true, nil - } + if vnetrule.VirtualNetworkRuleProperties != nil && vnetrule.VirtualNetworkRuleProperties.State == sql.Ready { + instance.Status.Provisioning = false + instance.Status.Provisioned = true + instance.Status.Message = resourcemanager.SuccessMsg + instance.Status.ResourceId = *vnetrule.ID + return true, nil } return false, nil } @@ -54,6 +52,7 @@ func (vr *AzureSqlVNetRuleManager) Ensure(ctx context.Context, obj runtime.Objec azerr := errhelp.NewAzureErrorAzureError(err) if strings.Contains(azerr.Type, errhelp.AsyncOpIncompleteError) { + instance.Status.Provisioning = false instance.Status.Message = "Resource request submitted to Azure successfully" return false, nil } @@ -63,7 +62,6 @@ func (vr *AzureSqlVNetRuleManager) Ensure(ctx context.Context, obj runtime.Objec errhelp.ParentNotFoundErrorCode, errhelp.ResourceNotFound, } - if helpers.ContainsString(ignorableErrors, azerr.Type) { instance.Status.Provisioning = false return false, nil From c76869e50b1b4eb4818e2b64b9ece71a1ebeea70 Mon Sep 17 00:00:00 2001 From: jpflueger Date: Thu, 26 Mar 2020 12:14:01 -0600 Subject: [PATCH 05/20] adding script to validate copyright headers --- Makefile | 6 +++++- pkg/helpers/rand.go | 3 +++ pkg/resourcemanager/apim/apimgmt/apimgmt.go | 17 ++-------------- .../apim/apimgmt/apimgmt_test.go | 17 +++------------- pkg/resourcemanager/apim/apimgmt/manager.go | 17 ++-------------- .../apim/apimgmt/suite_test.go | 17 ++-------------- scripts/validate-copyright-headers.sh | 20 +++++++++++++++++++ 7 files changed, 37 insertions(+), 60 deletions(-) create mode 100755 scripts/validate-copyright-headers.sh diff --git a/Makefile b/Makefile index 37eac79ffe1..907d3f6c35e 100644 --- a/Makefile +++ b/Makefile @@ -108,6 +108,10 @@ delete: kubectl delete -f config/crd/bases kustomize build config/default | kubectl delete -f - +# Validate copyright headers +validate-copyright-headers: + @./scripts/validate-copyright-headers.sh + # Generate manifests for helm and package them up helm-chart-manifests: manifests kustomize build ./config/default -o ./charts/azure-service-operator/templates @@ -125,7 +129,7 @@ fmt: go fmt ./... # Run go vet against code -vet: +vet: go vet ./... # Generate code diff --git a/pkg/helpers/rand.go b/pkg/helpers/rand.go index 3dcb6fc72e1..edd9a89c33e 100644 --- a/pkg/helpers/rand.go +++ b/pkg/helpers/rand.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + // copied from github.com/Azure/open-service-broker-azure/ package helpers diff --git a/pkg/resourcemanager/apim/apimgmt/apimgmt.go b/pkg/resourcemanager/apim/apimgmt/apimgmt.go index c4244b5f3fc..abce2a47542 100644 --- a/pkg/resourcemanager/apim/apimgmt/apimgmt.go +++ b/pkg/resourcemanager/apim/apimgmt/apimgmt.go @@ -1,18 +1,5 @@ -/* -MIT License - -Copyright (c) Microsoft Corporation. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -*/ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. package apimgmt diff --git a/pkg/resourcemanager/apim/apimgmt/apimgmt_test.go b/pkg/resourcemanager/apim/apimgmt/apimgmt_test.go index f8af79ea676..f8d00dc19f9 100644 --- a/pkg/resourcemanager/apim/apimgmt/apimgmt_test.go +++ b/pkg/resourcemanager/apim/apimgmt/apimgmt_test.go @@ -1,19 +1,8 @@ -/* -MIT License +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. -Copyright (c) Microsoft Corporation. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -*/ // +build all apimgmt + package apimgmt import ( diff --git a/pkg/resourcemanager/apim/apimgmt/manager.go b/pkg/resourcemanager/apim/apimgmt/manager.go index 371b993f214..e24779e45d9 100644 --- a/pkg/resourcemanager/apim/apimgmt/manager.go +++ b/pkg/resourcemanager/apim/apimgmt/manager.go @@ -1,18 +1,5 @@ -/* -MIT License - -Copyright (c) Microsoft Corporation. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -*/ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. package apimgmt diff --git a/pkg/resourcemanager/apim/apimgmt/suite_test.go b/pkg/resourcemanager/apim/apimgmt/suite_test.go index 01bcb012ca8..d266bd86ec0 100644 --- a/pkg/resourcemanager/apim/apimgmt/suite_test.go +++ b/pkg/resourcemanager/apim/apimgmt/suite_test.go @@ -1,18 +1,5 @@ -/* -MIT License - -Copyright (c) Microsoft Corporation. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -*/ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. package apimgmt diff --git a/scripts/validate-copyright-headers.sh b/scripts/validate-copyright-headers.sh new file mode 100755 index 00000000000..71345670f40 --- /dev/null +++ b/scripts/validate-copyright-headers.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. + +set -euo pipefail + +echo "==> Checking copyright headers <==" + +regx="(Copyright.*Microsoft.*Licensed.*MIT)|(generated)" +files=$(find . -type f -iname '*.go' ! -path './vendor/*' ! -path './hack/tools/*' ! -path './test/e2e/vendor/*') +licRes=$(for file in $files; do + head -4 "$file" | tr -d '\n' | grep -Eiq "$regx" || echo "$file"; + done) + +if [ -n "$licRes" ]; then + echo "Copyright header check failed:"; + echo "${licRes}"; + exit 1; +fi \ No newline at end of file From bce3f6f9477685f62ae5f59be76c31fc32e444eb Mon Sep 17 00:00:00 2001 From: jpflueger Date: Thu, 26 Mar 2020 12:19:27 -0600 Subject: [PATCH 06/20] adding step to pipeline for copyright validation --- devops/azure-pipelines.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/devops/azure-pipelines.yaml b/devops/azure-pipelines.yaml index 1ed8b68838c..1d909b87c62 100644 --- a/devops/azure-pipelines.yaml +++ b/devops/azure-pipelines.yaml @@ -99,6 +99,12 @@ steps: # REQUEUE_AFTER: $(REQUEUE_AFTER) # workingDirectory: '$(MODULE_PATH)' +- script: | + make validate-copyright-headers + continueOnError: 'false' + displayName: 'Validate Copyright Headers' + workingDirectory: '$(MODULE_PATH)' + - script: | set -e GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0 @@ -136,7 +142,7 @@ steps: REQUEUE_AFTER: $(REQUEUE_AFTER) KUBEBUILDER_ASSETS: $(MODULE_PATH)/bin BUILD_ID: $(Build.BuildId) - workingDirectory: '$(MODULE_PATH)' + workingDirectory: '$(MODULE_PATH)' - task: AzureCLI@2 displayName: 'Clean up Azure Resources' From ede1660bdd0f3737d33d59840135038ddb5fba12 Mon Sep 17 00:00:00 2001 From: Erin Corson Date: Thu, 26 Mar 2020 15:43:34 -0600 Subject: [PATCH 07/20] Update config/samples/azure_v1alpha1_rediscache.yaml Co-Authored-By: Janani Vasudevan <49576785+jananivMS@users.noreply.github.com> --- config/samples/azure_v1alpha1_rediscache.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/samples/azure_v1alpha1_rediscache.yaml b/config/samples/azure_v1alpha1_rediscache.yaml index 59bed31c424..08139496f6a 100644 --- a/config/samples/azure_v1alpha1_rediscache.yaml +++ b/config/samples/azure_v1alpha1_rediscache.yaml @@ -17,9 +17,9 @@ spec: family: C capacity: 1 enableNonSslPort: true - ## Optional - vnet usage may require a higher tier sku + ## Optional - vnet usage requires the 'Premium' sku #subnetId: /subscriptions/{SUBID}/resourceGroups/{resourcegroupName}/providers/Microsoft.Network/virtualNetworks/{vnet name}/subnets/{subnet name} #staticIp: 172.22.0.10 # Use the field below to optionally specify a different keyvault # to store the primary and secondary key secrets in - #keyVaultToStoreSecrets: asoSecretKeyVault \ No newline at end of file + #keyVaultToStoreSecrets: asoSecretKeyVault From 1b529e3a40ec71590e6346d5236c5876a8dc37a8 Mon Sep 17 00:00:00 2001 From: Erin Corson Date: Thu, 26 Mar 2020 18:02:50 -0600 Subject: [PATCH 08/20] fixes from review --- api/v1alpha1/rediscache_types.go | 10 +++++----- config/samples/azure_v1alpha1_rediscache.yaml | 16 +++++++++++----- pkg/errhelp/errhelp.go | 13 +++++++++++++ .../rediscaches/rediscache_reconcile.go | 10 ++++++++-- pkg/resourcemanager/rediscaches/rediscaches.go | 11 ++++++++--- 5 files changed, 45 insertions(+), 15 deletions(-) diff --git a/api/v1alpha1/rediscache_types.go b/api/v1alpha1/rediscache_types.go index 5be9f1b259b..01abff59a93 100644 --- a/api/v1alpha1/rediscache_types.go +++ b/api/v1alpha1/rediscache_types.go @@ -26,11 +26,11 @@ type RedisCacheSpec struct { // RedisCacheProperties the properties of the Redis Cache. type RedisCacheProperties struct { - Sku RedisCacheSku `json:"sku,omitempty"` - EnableNonSslPort bool `json:"enableNonSslPort,omitempty"` - SubnetID string `json:"subnetId,omitempty"` - StaticIP string `json:"staticIp,omitempty"` - RedisConfiguration map[string]string `json:"configuration,omitempty"` + Sku RedisCacheSku `json:"sku,omitempty"` + EnableNonSslPort bool `json:"enableNonSslPort,omitempty"` + SubnetID string `json:"subnetId,omitempty"` + StaticIP string `json:"staticIp,omitempty"` + Configuration map[string]string `json:"configuration,omitempty"` } // RedisCacheSku the SKU of the Redis Cache. diff --git a/config/samples/azure_v1alpha1_rediscache.yaml b/config/samples/azure_v1alpha1_rediscache.yaml index 59bed31c424..475e83dec4b 100644 --- a/config/samples/azure_v1alpha1_rediscache.yaml +++ b/config/samples/azure_v1alpha1_rediscache.yaml @@ -8,6 +8,9 @@ metadata: spec: location: westus resourceGroup: resourcegroup-azure-operators + # Use the field below to optionally specify a different keyvault + # to store the primary and secondary key secrets in + # keyVaultToStoreSecrets: asoSecretKeyVault properties: # possible values for sku.Name are "Basic", "Premium" or "Standard" # possible values for sku.family are "C" and "P". @@ -18,8 +21,11 @@ spec: capacity: 1 enableNonSslPort: true ## Optional - vnet usage may require a higher tier sku - #subnetId: /subscriptions/{SUBID}/resourceGroups/{resourcegroupName}/providers/Microsoft.Network/virtualNetworks/{vnet name}/subnets/{subnet name} - #staticIp: 172.22.0.10 - # Use the field below to optionally specify a different keyvault - # to store the primary and secondary key secrets in - #keyVaultToStoreSecrets: asoSecretKeyVault \ No newline at end of file + subnetId: /subscriptions/{SUBID}/resourceGroups/{resourcegroupName}/providers/Microsoft.Network/virtualNetworks/{vnet name}/subnets/{subnet name} + staticIp: 172.22.0.10 + # All redis configuration - Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta, + # maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value, + # hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value + # configuration: + # key: value + diff --git a/pkg/errhelp/errhelp.go b/pkg/errhelp/errhelp.go index 6a43e2dbd04..58008895018 100644 --- a/pkg/errhelp/errhelp.go +++ b/pkg/errhelp/errhelp.go @@ -4,6 +4,8 @@ package errhelp import ( + "fmt" + "regexp" "strings" ) @@ -41,3 +43,14 @@ func IsStatusCode404(err error) bool { func IsResourceNotFound(err error) bool { return strings.Contains(err.Error(), "ResourceNotFound") } + +// StripErrorIDs takes an error and returns its string representation after filtering some common ID patterns +func StripErrorIDs(err error) string { + patterns := []string{ + "RequestID=", + "CorrelationId:\\s", + } + reg := regexp.MustCompile(fmt.Sprintf(`(%s)\S+`, strings.Join(patterns, "|"))) + return reg.ReplaceAllString(err.Error(), "") + +} diff --git a/pkg/resourcemanager/rediscaches/rediscache_reconcile.go b/pkg/resourcemanager/rediscaches/rediscache_reconcile.go index 53c575eccc2..dde376be1cf 100644 --- a/pkg/resourcemanager/rediscaches/rediscache_reconcile.go +++ b/pkg/resourcemanager/rediscaches/rediscache_reconcile.go @@ -64,11 +64,17 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object } instance.Status.Message = fmt.Sprintf("RedisCache Get error %s", err.Error()) - _, err = rc.CreateRedisCache(ctx, *instance) + result, err := rc.CreateRedisCache(ctx, *instance) if err != nil { - instance.Status.Message = err.Error() + instance.Status.Message = errhelp.StripErrorIDs(err) instance.Status.Provisioning = false + if result != nil { + // stop reconciling if the spec is bad + if result.StatusCode == http.StatusBadRequest { + return true, nil + } + } catch := []string{ errhelp.ParentNotFoundErrorCode, errhelp.ResourceGroupNotFoundErrorCode, diff --git a/pkg/resourcemanager/rediscaches/rediscaches.go b/pkg/resourcemanager/rediscaches/rediscaches.go index 700692563be..8f908a09b2e 100644 --- a/pkg/resourcemanager/rediscaches/rediscaches.go +++ b/pkg/resourcemanager/rediscaches/rediscaches.go @@ -15,6 +15,7 @@ import ( "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" "github.com/Azure/azure-service-operator/pkg/secrets" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/to" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/runtime" @@ -109,9 +110,9 @@ func (r *AzureRedisCacheManager) CreateRedisCache( } // set redis config if one was provided - if len(props.RedisConfiguration) > 0 { + if len(props.Configuration) > 0 { config := map[string]*string{} - for k, v := range props.RedisConfiguration { + for k, v := range props.Configuration { value := v config[k] = &value } @@ -122,7 +123,11 @@ func (r *AzureRedisCacheManager) CreateRedisCache( ctx, instance.Spec.ResourceGroupName, instance.Name, createParams, ) if err != nil { - return nil, err + return &redis.ResourceType{ + Response: autorest.Response{ + Response: future.Response(), + }, + }, err } result, err := future.Result(redisClient) From 02cbc9adb2d7bbb1da8ce184d5fba70fc5a4002a Mon Sep 17 00:00:00 2001 From: jpflueger Date: Thu, 26 Mar 2020 18:59:15 -0600 Subject: [PATCH 09/20] addressing pr feedback --- .../azuresql/azuresqldb/azuresqldb_reconcile.go | 8 +++++++- .../azuresqlvnetrule/azuresqlvnetrule_reconcile.go | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go index 07a0c73a304..4faa118d253 100644 --- a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go @@ -85,13 +85,19 @@ func (db *AzureSqlDbManager) Ensure(ctx context.Context, obj runtime.Object, opt instance.Status.Message = err.Error() azerr := errhelp.NewAzureErrorAzureError(err) + // resource request has been sent to ARM + if azerr.Type == errhelp.AsyncOpIncompleteError { + instance.Status.Provisioning = true + return false, nil + } + // the errors that can arise during reconcilliation where we simply requeue catch := []string{ errhelp.ResourceGroupNotFoundErrorCode, errhelp.ParentNotFoundErrorCode, - errhelp.AsyncOpIncompleteError, } if helpers.ContainsString(catch, azerr.Type) { + instance.Status.Provisioning = false return false, nil } diff --git a/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go index ee4745cd0d1..dc64bfb88df 100644 --- a/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go @@ -6,7 +6,6 @@ package azuresqlvnetrule import ( "context" "fmt" - "strings" "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" @@ -51,8 +50,8 @@ func (vr *AzureSqlVNetRuleManager) Ensure(ctx context.Context, obj runtime.Objec instance.Status.Message = err.Error() azerr := errhelp.NewAzureErrorAzureError(err) - if strings.Contains(azerr.Type, errhelp.AsyncOpIncompleteError) { - instance.Status.Provisioning = false + if azerr.Type == errhelp.AsyncOpIncompleteError { + instance.Status.Provisioning = true instance.Status.Message = "Resource request submitted to Azure successfully" return false, nil } @@ -66,6 +65,7 @@ func (vr *AzureSqlVNetRuleManager) Ensure(ctx context.Context, obj runtime.Objec instance.Status.Provisioning = false return false, nil } + return false, err } From 8db7a11f7f61fb4ffa481a45a2a89e4b8c91359d Mon Sep 17 00:00:00 2001 From: jpflueger Date: Thu, 26 Mar 2020 19:03:34 -0600 Subject: [PATCH 10/20] remove extra false provisioning --- pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go index 4faa118d253..23796d97a86 100644 --- a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go @@ -107,7 +107,6 @@ func (db *AzureSqlDbManager) Ensure(ctx context.Context, obj runtime.Object, opt return false, nil } - instance.Status.Provisioning = false return true, fmt.Errorf("AzureSqlDb CreateOrUpdate error %v", err) } From 3dddfcfe1932b5b533799f85a0123bf756b3525f Mon Sep 17 00:00:00 2001 From: hobu <37413937+buhongw7583c@users.noreply.github.com> Date: Fri, 27 Mar 2020 20:00:41 +0800 Subject: [PATCH 11/20] task#800RemoveSQLlogger --- controllers/suite_test.go | 7 ++----- main.go | 7 ++----- .../azuresql/azuresqlaction/azuresqlaction.go | 9 +-------- .../azuresqlaction/azuresqlaction_reconcile.go | 1 - .../azuresql/azuresqldb/azuresqldb.go | 6 ++---- .../azuresqlfailovergroup/azuresqlfailovergroup.go | 8 +------- .../azuresqlfirewallrule/azuresqlfirewallrule.go | 6 ++---- .../azuresql/azuresqlserver/azuresqlserver.go | 5 +---- .../azuresql/azuresqluser/azuresqluser.go | 12 +++--------- 9 files changed, 14 insertions(+), 47 deletions(-) diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 6c59df12a95..fa362243f7b 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -167,7 +167,6 @@ func setup() error { eventhubNamespaceClient = resourcemanagereventhub.NewEventHubNamespaceClient(ctrl.Log.WithName("controllers").WithName("EventhubNamespace")) sqlServerManager = resourcemanagersqlserver.NewAzureSqlServerManager( - ctrl.Log.WithName("sqlservermanager").WithName("AzureSqlServer"), secretClient, scheme.Scheme, ) @@ -176,17 +175,15 @@ func setup() error { secretClient, scheme.Scheme, ) - sqlDbManager = resourcemanagersqldb.NewAzureSqlDbManager(ctrl.Log.WithName("sqldbmanager").WithName("AzureSqlDb")) - sqlFirewallRuleManager = resourcemanagersqlfirewallrule.NewAzureSqlFirewallRuleManager(ctrl.Log.WithName("sqlfirewallrulemanager").WithName("AzureSqlFirewallRule")) + sqlDbManager = resourcemanagersqldb.NewAzureSqlDbManager() + sqlFirewallRuleManager = resourcemanagersqlfirewallrule.NewAzureSqlFirewallRuleManager() sqlVNetRuleManager = resourcemanagersqlvnetrule.NewAzureSqlVNetRuleManager() sqlFailoverGroupManager = resourcemanagersqlfailovergroup.NewAzureSqlFailoverGroupManager( - ctrl.Log.WithName("sqlfailovergroupmanager").WithName("AzureSqlFailoverGroup"), secretClient, scheme.Scheme, ) consumerGroupClient = resourcemanagereventhub.NewConsumerGroupClient(ctrl.Log.WithName("controllers").WithName("ConsumerGroup")) sqlUserManager = resourcemanagersqluser.NewAzureSqlUserManager( - ctrl.Log.WithName("sqlusermanager").WithName("AzureSqlUser"), secretClient, scheme.Scheme, ) diff --git a/main.go b/main.go index 75f66d49c58..8a431b2e36a 100644 --- a/main.go +++ b/main.go @@ -129,15 +129,13 @@ func main() { } eventhubClient := resourcemanagereventhub.NewEventhubClient(secretClient, scheme) sqlServerManager := resourcemanagersqlserver.NewAzureSqlServerManager( - ctrl.Log.WithName("sqlservermanager").WithName("AzureSqlServer"), secretClient, scheme, ) - sqlDBManager := resourcemanagersqldb.NewAzureSqlDbManager(ctrl.Log.WithName("sqldbmanager").WithName("AzureSqlDb")) - sqlFirewallRuleManager := resourcemanagersqlfirewallrule.NewAzureSqlFirewallRuleManager(ctrl.Log.WithName("sqlfirewallrulemanager").WithName("AzureSqlFirewallRule")) + sqlDBManager := resourcemanagersqldb.NewAzureSqlDbManager() + sqlFirewallRuleManager := resourcemanagersqlfirewallrule.NewAzureSqlFirewallRuleManager() sqlVNetRuleManager := resourcemanagersqlvnetrule.NewAzureSqlVNetRuleManager() sqlFailoverGroupManager := resourcemanagersqlfailovergroup.NewAzureSqlFailoverGroupManager( - ctrl.Log.WithName("sqlfailovergroupmanager").WithName("AzureSqlFailoverGroup"), secretClient, scheme, ) @@ -145,7 +143,6 @@ func main() { psqldatabaseclient := psqldatabase.NewPSQLDatabaseClient() psqlfirewallruleclient := psqlfirewallrule.NewPSQLFirewallRuleClient() sqlUserManager := resourcemanagersqluser.NewAzureSqlUserManager( - ctrl.Log.WithName("sqlusermanager").WithName("AzureSqlUser"), secretClient, scheme, ) diff --git a/pkg/resourcemanager/azuresql/azuresqlaction/azuresqlaction.go b/pkg/resourcemanager/azuresql/azuresqlaction/azuresqlaction.go index 411a28f047f..6cc80884755 100644 --- a/pkg/resourcemanager/azuresql/azuresqlaction/azuresqlaction.go +++ b/pkg/resourcemanager/azuresql/azuresqlaction/azuresqlaction.go @@ -12,25 +12,18 @@ import ( azuresqlserver "github.com/Azure/azure-service-operator/pkg/resourcemanager/azuresql/azuresqlserver" "github.com/Azure/azure-service-operator/pkg/resourcemanager/azuresql/azuresqlshared" "github.com/Azure/azure-service-operator/pkg/secrets" - "github.com/Azure/azure-service-operator/pkg/telemetry" "github.com/Azure/go-autorest/autorest/to" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - ctrl "sigs.k8s.io/controller-runtime" ) type AzureSqlActionManager struct { - Telemetry telemetry.Telemetry SecretClient secrets.SecretClient Scheme *runtime.Scheme } func NewAzureSqlActionManager(secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlActionManager { return &AzureSqlActionManager{ - Telemetry: *telemetry.InitializeTelemetryDefault( - "AzureSqlAction", - ctrl.Log.WithName("controllers").WithName("AzureSqlAction"), - ), SecretClient: secretClient, Scheme: scheme, } @@ -40,7 +33,7 @@ func NewAzureSqlActionManager(secretClient secrets.SecretClient, scheme *runtime // for the server and stores the new password in the secret func (s *AzureSqlActionManager) UpdateAdminPassword(ctx context.Context, groupName string, serverName string, secretKey types.NamespacedName, secretClient secrets.SecretClient) error { - azuresqlserverManager := azuresqlserver.NewAzureSqlServerManager(s.Telemetry.Logger, secretClient, s.Scheme) + azuresqlserverManager := azuresqlserver.NewAzureSqlServerManager(secretClient, s.Scheme) // Get the SQL server instance server, err := azuresqlserverManager.GetServer(ctx, groupName, serverName) if err != nil { diff --git a/pkg/resourcemanager/azuresql/azuresqlaction/azuresqlaction_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlaction/azuresqlaction_reconcile.go index caf2f2d922d..056d10bde30 100644 --- a/pkg/resourcemanager/azuresql/azuresqlaction/azuresqlaction_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlaction/azuresqlaction_reconcile.go @@ -50,7 +50,6 @@ func (s *AzureSqlActionManager) Ensure(ctx context.Context, obj runtime.Object, } else { adminSecretClient = keyvaultsecretlib.New(instance.Spec.ServerSecretKeyVault) if !keyvaultsecretlib.IsKeyVaultAccessible(adminSecretClient) { - s.Telemetry.LogInfo("requeuing", "Keyvault specified not accessible yet") instance.Status.Message = "InvalidKeyVaultAccess: Keyvault not accessible yet" return false, nil } diff --git a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb.go b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb.go index 7c77861930b..dde5a2213ea 100644 --- a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb.go +++ b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb.go @@ -12,15 +12,13 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/to" - "github.com/go-logr/logr" ) type AzureSqlDbManager struct { - Log logr.Logger } -func NewAzureSqlDbManager(log logr.Logger) *AzureSqlDbManager { - return &AzureSqlDbManager{Log: log} +func NewAzureSqlDbManager() *AzureSqlDbManager { + return &AzureSqlDbManager{} } // GetServer returns a SQL server diff --git a/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup.go b/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup.go index abf60175cce..a6971d79fc1 100644 --- a/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup.go +++ b/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup.go @@ -15,18 +15,15 @@ import ( sql "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql" "github.com/Azure/go-autorest/autorest" - "github.com/go-logr/logr" ) type AzureSqlFailoverGroupManager struct { - Log logr.Logger SecretClient secrets.SecretClient Scheme *runtime.Scheme } -func NewAzureSqlFailoverGroupManager(log logr.Logger, secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlFailoverGroupManager { +func NewAzureSqlFailoverGroupManager(secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlFailoverGroupManager { return &AzureSqlFailoverGroupManager{ - Log: log, SecretClient: secretClient, Scheme: scheme, } @@ -163,12 +160,9 @@ func (f *AzureSqlFailoverGroupManager) GetOrPrepareSecret(ctx context.Context, i key := types.NamespacedName{Name: failovergroupname, Namespace: instance.Namespace} if stored, err := f.SecretClient.Get(ctx, key); err == nil { - f.Log.Info("secret already exists, pulling stored values") return stored, nil } - f.Log.Info("secret not found, generating values for new secret") - secret["azureSqlPrimaryServer"] = []byte(azuresqlprimaryserver) secret["readWriteListenerEndpoint"] = []byte(failovergroupname + ".database.windows.net") secret["azureSqlSecondaryServer"] = []byte(azuresqlsecondaryserver) diff --git a/pkg/resourcemanager/azuresql/azuresqlfirewallrule/azuresqlfirewallrule.go b/pkg/resourcemanager/azuresql/azuresqlfirewallrule/azuresqlfirewallrule.go index 91ec8137c6d..4f4a48cb49f 100644 --- a/pkg/resourcemanager/azuresql/azuresqlfirewallrule/azuresqlfirewallrule.go +++ b/pkg/resourcemanager/azuresql/azuresqlfirewallrule/azuresqlfirewallrule.go @@ -10,15 +10,13 @@ import ( azuresqlshared "github.com/Azure/azure-service-operator/pkg/resourcemanager/azuresql/azuresqlshared" "github.com/Azure/go-autorest/autorest/to" - "github.com/go-logr/logr" ) type AzureSqlFirewallRuleManager struct { - Log logr.Logger } -func NewAzureSqlFirewallRuleManager(log logr.Logger) *AzureSqlFirewallRuleManager { - return &AzureSqlFirewallRuleManager{Log: log} +func NewAzureSqlFirewallRuleManager() *AzureSqlFirewallRuleManager { + return &AzureSqlFirewallRuleManager{} } // GetServer returns a SQL server diff --git a/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver.go b/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver.go index 1eab590e63a..c55e93586c6 100644 --- a/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver.go +++ b/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver.go @@ -13,21 +13,18 @@ import ( "github.com/Azure/azure-service-operator/pkg/secrets" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/to" - "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/runtime" ) const typeOfService = "Microsoft.Sql/servers" type AzureSqlServerManager struct { - Log logr.Logger SecretClient secrets.SecretClient Scheme *runtime.Scheme } -func NewAzureSqlServerManager(log logr.Logger, secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlServerManager { +func NewAzureSqlServerManager(secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlServerManager { return &AzureSqlServerManager{ - Log: log, SecretClient: secretClient, Scheme: scheme, } diff --git a/pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go b/pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go index 743a0836d53..dc7eeb1f907 100644 --- a/pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go +++ b/pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go @@ -18,7 +18,6 @@ import ( "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/resourcemanager" keyvaultSecrets "github.com/Azure/azure-service-operator/pkg/secrets/keyvault" - "github.com/go-logr/logr" "github.com/google/uuid" "k8s.io/apimachinery/pkg/runtime" @@ -39,14 +38,12 @@ const SecretUsernameKey = "username" const SecretPasswordKey = "password" type AzureSqlUserManager struct { - Log logr.Logger SecretClient secrets.SecretClient Scheme *runtime.Scheme } -func NewAzureSqlUserManager(log logr.Logger, secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlUserManager { +func NewAzureSqlUserManager(secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlUserManager { return &AzureSqlUserManager{ - Log: log, SecretClient: secretClient, Scheme: scheme, } @@ -60,13 +57,11 @@ func (m *AzureSqlUserManager) ConnectToSqlDb(ctx context.Context, drivername str db, err := sql.Open(drivername, connString) if err != nil { - m.Log.Info("ConnectToSqlDb", "error from sql.Open is:", err.Error()) return db, err } err = db.PingContext(ctx) if err != nil { - m.Log.Info("ConnectToSqlDb", "error from db.Ping is:", err.Error()) return db, err } @@ -85,7 +80,6 @@ func (m *AzureSqlUserManager) GrantUserRoles(ctx context.Context, user string, r sql.Named("user", user), ) if err != nil { - m.Log.Info("GrantUserRoles:", "Error executing add role:", err.Error()) errorStrings = append(errorStrings, err.Error()) } } @@ -180,7 +174,7 @@ func (s *AzureSqlUserManager) Ensure(ctx context.Context, obj runtime.Object, op } // need this to detect missing databases - dbClient := azuresqldb.NewAzureSqlDbManager(s.Log) + dbClient := azuresqldb.NewAzureSqlDbManager() // get admin creds for server adminSecret, err := adminSecretClient.Get(ctx, key) @@ -443,7 +437,7 @@ func (s *AzureSqlUserManager) Delete(ctx context.Context, obj runtime.Object, op } // short circuit connection if database doesn't exist - dbClient := azuresqldb.NewAzureSqlDbManager(s.Log) + dbClient := azuresqldb.NewAzureSqlDbManager() _, err = dbClient.GetDB(ctx, instance.Spec.ResourceGroup, instance.Spec.Server, instance.Spec.DbName) if err != nil { instance.Status.Message = err.Error() From 10cd7b3d79eddb5112c689f79398f396d1d0d0ef Mon Sep 17 00:00:00 2001 From: jpflueger Date: Fri, 27 Mar 2020 09:21:57 -0600 Subject: [PATCH 12/20] not provisioning on sqldb 404 --- pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go index 23796d97a86..fae66455458 100644 --- a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go @@ -104,6 +104,7 @@ func (db *AzureSqlDbManager) Ensure(ctx context.Context, obj runtime.Object, opt // assertion that a 404 error implies that the Azure SQL server hasn't been provisioned yet if resp != nil && resp.StatusCode == 404 { instance.Status.Message = fmt.Sprintf("Waiting for SQL Server %s to provision", server) + instance.Status.Provisioning = false return false, nil } From 6e18ec3ba2998276b765dc80d4dc874a8b8a9b6d Mon Sep 17 00:00:00 2001 From: jpflueger Date: Fri, 27 Mar 2020 09:52:53 -0600 Subject: [PATCH 13/20] build flag causing vet error --- pkg/resourcemanager/apim/apimgmt/apimgmt_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/resourcemanager/apim/apimgmt/apimgmt_test.go b/pkg/resourcemanager/apim/apimgmt/apimgmt_test.go index f8d00dc19f9..dab131d2512 100644 --- a/pkg/resourcemanager/apim/apimgmt/apimgmt_test.go +++ b/pkg/resourcemanager/apim/apimgmt/apimgmt_test.go @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -// +build all apimgmt - package apimgmt import ( From 0b958d0729ff75fc3fd6415246288d980a7bdc54 Mon Sep 17 00:00:00 2001 From: jpflueger Date: Fri, 27 Mar 2020 11:21:42 -0600 Subject: [PATCH 14/20] replacing hashstructure with helpers function --- pkg/resourcemanager/keyvaults/keyvault.go | 28 ++--------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/pkg/resourcemanager/keyvaults/keyvault.go b/pkg/resourcemanager/keyvaults/keyvault.go index 3bce3f58757..e2507930cb4 100644 --- a/pkg/resourcemanager/keyvaults/keyvault.go +++ b/pkg/resourcemanager/keyvaults/keyvault.go @@ -6,7 +6,6 @@ package keyvaults import ( "context" "fmt" - "strconv" auth "github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac" "github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault" @@ -21,7 +20,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/to" "github.com/go-logr/logr" - "github.com/mitchellh/hashstructure" uuid "github.com/satori/go.uuid" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -114,25 +112,6 @@ func ParseNetworkPolicy(ruleSet *v1alpha1.NetworkRuleSet) keyvault.NetworkRuleSe return networkAcls } -// GenerateSpecHash - helper function that generates a unique hash for a Kubernetes runtime.Object resource -func GenerateSpecHash(obj runtime.Object) (string, error) { - unstructured, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) - if err != nil { - return "", err - } - - hash, err := hashstructure.Hash(unstructured["spec"].(map[string]interface{}), nil) - if err != nil { - return "", err - } - - if hash == 0 { - return "", fmt.Errorf("InvalidHash: Hashing function returned 0") - } - - return strconv.FormatUint(hash, 10), nil -} - // ParseAccessPolicy - helper function to parse access policies from Kubernetes spec func ParseAccessPolicy(policy *v1alpha1.AccessPolicyEntry, ctx context.Context) (keyvault.AccessPolicyEntry, error) { tenantID, err := uuid.FromString(policy.TenantID) @@ -397,11 +376,8 @@ func (k *azureKeyVaultManager) Ensure(ctx context.Context, obj runtime.Object, o return true, err } - hash, err := GenerateSpecHash(obj) - if err != nil { - return true, err - } - + // hash the spec and set if new + hash := helpers.Hash256(instance.Spec) if instance.Status.SpecHash == "" { instance.Status.SpecHash = hash } From 641fe57dd59ad89fb9ca782e112d8fab97038d2e Mon Sep 17 00:00:00 2001 From: jpflueger Date: Fri, 27 Mar 2020 11:24:41 -0600 Subject: [PATCH 15/20] tidying go mods --- go.mod | 16 ++++++-------- go.sum | 66 ---------------------------------------------------------- 2 files changed, 6 insertions(+), 76 deletions(-) diff --git a/go.mod b/go.mod index b0c215a7816..4add8843540 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,6 @@ go 1.13 require ( cloud.google.com/go v0.37.4 // indirect - github.com/AlekSi/gocov-xml v0.0.0-20190121064608-3a14fb1c4737 // indirect - github.com/Azure-Samples/azure-sdk-for-go-samples v0.0.0-20190805235326-79e3f3af791c // indirect github.com/Azure/azure-sdk-for-go v38.0.0+incompatible github.com/Azure/go-autorest/autorest v0.5.0 github.com/Azure/go-autorest/autorest/adal v0.2.0 @@ -13,29 +11,29 @@ require ( github.com/Azure/go-autorest/autorest/date v0.1.0 github.com/Azure/go-autorest/autorest/to v0.2.0 github.com/Azure/go-autorest/autorest/validation v0.1.0 - github.com/axw/gocov v1.0.0 // indirect github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e github.com/go-logr/logr v0.1.0 github.com/gobuffalo/envy v1.7.0 + github.com/gogo/protobuf v1.2.1 // indirect github.com/google/go-cmp v0.3.0 + github.com/google/gofuzz v1.0.0 // indirect github.com/google/uuid v1.1.1 github.com/googleapis/gnostic v0.3.0 // indirect - github.com/gophercloud/gophercloud v0.4.0 // indirect github.com/hashicorp/go-multierror v1.0.0 - github.com/jstemmer/go-junit-report v0.9.1 // indirect + github.com/json-iterator/go v1.1.6 // indirect github.com/marstr/randname v0.0.0-20181206212954-d5b0f288ab8c - github.com/mitchellh/hashstructure v1.0.0 + github.com/modern-go/reflect2 v1.0.1 // indirect github.com/onsi/ginkgo v1.11.0 github.com/onsi/gomega v1.7.0 github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 - github.com/prometheus/common v0.2.0 github.com/satori/go.uuid v1.2.0 github.com/sethvargo/go-password v0.1.2 + github.com/spf13/pflag v1.0.3 // indirect github.com/stretchr/testify v1.5.1 golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 // indirect golang.org/x/net v0.0.0-20190620200207-3b0461eec859 golang.org/x/sys v0.0.0-20190621203818-d432491b9138 // indirect - golang.org/x/tools v0.0.0-20200130203232-449c356b79e5 // indirect + golang.org/x/text v0.3.2 // indirect gopkg.in/yaml.v2 v2.2.8 // indirect k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d @@ -43,6 +41,4 @@ require ( k8s.io/klog v0.3.3 // indirect k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 // indirect sigs.k8s.io/controller-runtime v0.2.0-beta.4 - sigs.k8s.io/controller-tools v0.2.0 // indirect - sigs.k8s.io/kind v0.4.0 // indirect ) diff --git a/go.sum b/go.sum index 873e81f6254..6c7be23d8b2 100644 --- a/go.sum +++ b/go.sum @@ -4,11 +4,8 @@ cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU= cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw= contrib.go.opencensus.io/exporter/ocagent v0.4.12 h1:jGFvw3l57ViIVEPKKEUXPcLYIXJmQxLUh6ey1eJhwyc= contrib.go.opencensus.io/exporter/ocagent v0.4.12/go.mod h1:450APlNTSR6FrvC3CTRqYosuDstRB9un7SOx2k/9ckA= -github.com/AlekSi/gocov-xml v0.0.0-20190121064608-3a14fb1c4737/go.mod h1:w1KSuh2JgIL3nyRiZijboSUwbbxOrTzWwyWVFUHtXBQ= -github.com/Azure-Samples/azure-sdk-for-go-samples v0.0.0-20190805235326-79e3f3af791c/go.mod h1:fHSkenNUlKPxCdWPfkfEubZHu7B3er09X30oJ6db8Fg= github.com/Azure/azure-sdk-for-go v38.0.0+incompatible h1:3D2O4g8AwDwyWkM1HpMFVux/ccQJmGJHXsE004Wsu1Q= github.com/Azure/azure-sdk-for-go v38.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v39.2.0+incompatible h1:zeY2FNH9mauj53XcRJQ2JVSNH0M+eYxeWhep8nnhNoc= github.com/Azure/go-autorest/autorest v0.1.0/go.mod h1:AKyIcETwSUFxIcs/Wnq/C+kwCtlEYGUVd7FPNb2slmg= github.com/Azure/go-autorest/autorest v0.5.0 h1:Mlm9qy2fpQ9MvfyI41G2Zf5B4CsgjjNbLOWszfK6KrY= github.com/Azure/go-autorest/autorest v0.5.0/go.mod h1:9HLKlQjVBH6U3oDfsXOeVc56THsLPw1L03yban4xThw= @@ -34,9 +31,7 @@ github.com/Azure/go-autorest/tracing v0.1.0/go.mod h1:ROEEAFwXycQw7Sn3DXNtEedEvd github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= @@ -44,7 +39,6 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/axw/gocov v1.0.0/go.mod h1:LvQpEYiwwIb2nYkXY2fDWhg9/AsYqkhmrCshjlUJECE= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/census-instrumentation/opencensus-proto v0.2.0 h1:LzQXZOgg4CQfE6bFvXGM30YZL1WW/M337pXml+GrcZ4= @@ -54,8 +48,6 @@ github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73 h1:OGNva6WhsKst5OZf7eZOklDztV3hwtTHovdrLHV+MsA= -github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e h1:LzwWXEScfcTu7vUZNlDDWDARoSGEtvlDKK2BYHowNeE= github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= @@ -66,11 +58,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -82,18 +71,12 @@ github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7 github.com/go-logr/zapr v0.1.0 h1:h+WVe9j6HAA01niTJPA/kKH0i7e0rLZBCwauQFcRE54= github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= -github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= -github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= -github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU= github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.5 h1:xpKq9ap8MbYfhuPCF0dBH854Gp9CxZjr/IocxELFflo= -github.com/gobuffalo/flect v0.1.5/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= @@ -128,7 +111,6 @@ github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9/go.mod h1:sJBsC github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.3.0 h1:CcQijm0XKekKjP/YCz28LXVSpgguuB+nCxaSjCe09y0= github.com/googleapis/gnostic v0.3.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/gophercloud/gophercloud v0.4.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/grpc-ecosystem/grpc-gateway v1.8.5 h1:2+KSC78XiO6Qy0hIjfc1OD9H+hsaJdJlb8Kqsd41CTE= @@ -144,8 +126,6 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -153,8 +133,6 @@ github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -167,21 +145,14 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/marstr/collection v1.0.1 h1:j61osRfyny7zxBlLRtoCvOZ2VX7HEyybkZcsLNLJ0z0= github.com/marstr/collection v1.0.1/go.mod h1:HHDXVxjLO3UYCBXJWY+J/ZrxCUOYqrO66ob1AzIsmYA= github.com/marstr/randname v0.0.0-20181206212954-d5b0f288ab8c h1:JE+MDz5rhFN5EC9Dj/N8dLYKboTWm6FXeWhnyKVj0vA= github.com/marstr/randname v0.0.0-20181206212954-d5b0f288ab8c/go.mod h1:Xc224oUXd7/sKMjWKl17cfkYOKQ1S+HSOW7YHEGXauI= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y= -github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -193,14 +164,11 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= @@ -236,11 +204,7 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh github.com/sethvargo/go-password v0.1.2 h1:fhBF4thiPVKEZ7R6+CX46GWJiPyCyXshbeqZ7lqEeYo= github.com/sethvargo/go-password v0.1.2/go.mod h1:qKHfdSjT26DpHQWHWWR5+X4BI45jT31dg6j4RI2TEb0= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= @@ -250,8 +214,6 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.1-0.20200116033420-8c465a0c8e80 h1:12tA8gmaPflFQ/nkGyjDKnup+O2gTLaOArNYBYxtm2Q= -github.com/stretchr/testify v1.4.1-0.20200116033420-8c465a0c8e80/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -265,26 +227,19 @@ go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 h1:QmwruyY+bKbDDL0BaglrbZABEali68eoMFhTZpCjYVA= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -292,8 +247,6 @@ golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190514140710-3ec191127204/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -312,12 +265,9 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190621203818-d432491b9138 h1:t8BZD9RDjkm9/h7yYN6kE8oaeov5r9aztkB7zKA5Tkg= golang.org/x/sys v0.0.0-20190621203818-d432491b9138/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -335,14 +285,6 @@ golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190501045030-23463209683d/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190909214602-067311248421 h1:NmmWqJbt02YJHmp4A4gBXvsXXIzzixjzE1y6PKUyIjk= -golang.org/x/tools v0.0.0-20190909214602-067311248421/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200130203232-449c356b79e5 h1:TbxOZzZ5R17ZNLXxtNEYQk2r8tRFm0eEENtdH/ixYyU= -golang.org/x/tools v0.0.0-20200130203232-449c356b79e5/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gomodules.xyz/jsonpatch/v2 v2.0.0 h1:lHNQverf0+Gm1TbSbVIDWVXOhZ2FpZopxRqpr2uIjs4= gomodules.xyz/jsonpatch/v2 v2.0.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= google.golang.org/api v0.3.1 h1:oJra/lMfmtm13/rgY/8i3MzjFWYXvQIAKjQ3HqofMk8= @@ -386,28 +328,20 @@ k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 h1:q1Qvjzs/iEd k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE= k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d h1:Jmdtdt1ZnoGfWWIIik61Z7nKYgO3J+swQJtPYsP9wHA= k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= -k8s.io/client-go v11.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible h1:U5Bt+dab9K8qaUmXINrkXO135kA11/i5Kg1RUydgaMQ= k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v0.2.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.3 h1:niceAagH1tzskmaie/icWd7ci1wbG7Bf2c6YGcQv+3c= k8s.io/klog v0.3.3/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/kube-openapi v0.0.0-20180731170545-e3762e86a74c/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= -k8s.io/kube-openapi v0.0.0-20190510232812-a01b7d5d6c22/go.mod h1:iU+ZGYsNlvU9XKUSso6SQfKTCCw7lFduMZy26Mgr2Fw= k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 h1:5sW+fEHvlJI3Ngolx30CmubFulwH28DhKjGf70Xmtco= k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4= k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 h1:VBM/0P5TWxwk+Nw6Z+lAw3DKgO76g90ETOiA6rfLV1Y= k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/controller-runtime v0.2.0-beta.4 h1:S1XVfRWR1MuIXZdkYx3jN8JDw+bbQxmWZroy0i87z/A= sigs.k8s.io/controller-runtime v0.2.0-beta.4/go.mod h1:HweyYKQ8fBuzdu2bdaeBJvsFgAi/OqBBnrVGXcqKhME= -sigs.k8s.io/controller-tools v0.2.0 h1:AmQ/0JKBJAjyAiPAkrAf9QW06jkx2lc5hpxMjamsFpw= -sigs.k8s.io/controller-tools v0.2.0/go.mod h1:8t/X+FVWvk6TaBcsa+UKUBbn7GMtvyBKX30SGl4em6Y= -sigs.k8s.io/kind v0.4.0/go.mod h1:bgGo2cWxKGQ7esVxtGp9H17Ttlexju92CTMjCg08HNQ= -sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= -sigs.k8s.io/structured-merge-diff v0.0.0-20190426204423-ea680f03cc65/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/testing_frameworks v0.1.1 h1:cP2l8fkA3O9vekpy5Ks8mmA0NW/F7yBdXf8brkWhVrs= sigs.k8s.io/testing_frameworks v0.1.1/go.mod h1:VVBKrHmJ6Ekkfz284YKhQePcdycOzNH9qL6ht1zEr/U= From 0ca47ea37df7df1b27dd4a0c9ad30a4f0de1bfd6 Mon Sep 17 00:00:00 2001 From: Erin Corson Date: Fri, 27 Mar 2020 13:39:29 -0600 Subject: [PATCH 16/20] better error handling for redis --- .../rediscaches/rediscache_reconcile.go | 30 ++++++++++++------- .../rediscaches/rediscaches.go | 7 +---- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pkg/resourcemanager/rediscaches/rediscache_reconcile.go b/pkg/resourcemanager/rediscaches/rediscache_reconcile.go index dde376be1cf..8e301eb6ffd 100644 --- a/pkg/resourcemanager/rediscaches/rediscache_reconcile.go +++ b/pkg/resourcemanager/rediscaches/rediscache_reconcile.go @@ -42,6 +42,7 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object } instance.Status.Provisioning = true + instance.Status.FailedProvisioning = false newRc, err := rc.GetRedisCache(ctx, groupName, name) if err == nil { @@ -64,29 +65,38 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object } instance.Status.Message = fmt.Sprintf("RedisCache Get error %s", err.Error()) - result, err := rc.CreateRedisCache(ctx, *instance) + _, err = rc.CreateRedisCache(ctx, *instance) if err != nil { instance.Status.Message = errhelp.StripErrorIDs(err) instance.Status.Provisioning = false + azerr := errhelp.NewAzureErrorAzureError(err) - if result != nil { - // stop reconciling if the spec is bad - if result.StatusCode == http.StatusBadRequest { - return true, nil - } + unrecoverable := []string{ + errhelp.RequestConflictError, + errhelp.BadRequest, } - catch := []string{ + if helpers.ContainsString(unrecoverable, azerr.Type) { + return true, nil + } + + catchNotProvisioning := []string{ errhelp.ParentNotFoundErrorCode, errhelp.ResourceGroupNotFoundErrorCode, errhelp.AlreadyExists, errhelp.NotFoundErrorCode, + } + if helpers.ContainsString(catchNotProvisioning, azerr.Type) { + return false, nil + } + + catchProvisioning := []string{ errhelp.AsyncOpIncompleteError, - errhelp.BadRequest, } - azerr := errhelp.NewAzureErrorAzureError(err) - if helpers.ContainsString(catch, azerr.Type) { + if helpers.ContainsString(catchProvisioning, azerr.Type) { + instance.Status.Provisioning = true return false, nil } + return false, err } diff --git a/pkg/resourcemanager/rediscaches/rediscaches.go b/pkg/resourcemanager/rediscaches/rediscaches.go index 8f908a09b2e..c4922fe71b9 100644 --- a/pkg/resourcemanager/rediscaches/rediscaches.go +++ b/pkg/resourcemanager/rediscaches/rediscaches.go @@ -15,7 +15,6 @@ import ( "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" "github.com/Azure/azure-service-operator/pkg/secrets" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/to" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/runtime" @@ -123,11 +122,7 @@ func (r *AzureRedisCacheManager) CreateRedisCache( ctx, instance.Spec.ResourceGroupName, instance.Name, createParams, ) if err != nil { - return &redis.ResourceType{ - Response: autorest.Response{ - Response: future.Response(), - }, - }, err + return nil, err } result, err := future.Result(redisClient) From c78f3a7f9f2adaa2391aa1639b4dffdb7f270806 Mon Sep 17 00:00:00 2001 From: Erin Corson Date: Fri, 27 Mar 2020 13:52:22 -0600 Subject: [PATCH 17/20] handle bad configurations error --- pkg/resourcemanager/rediscaches/rediscache_reconcile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/resourcemanager/rediscaches/rediscache_reconcile.go b/pkg/resourcemanager/rediscaches/rediscache_reconcile.go index 8e301eb6ffd..28e8ee253f7 100644 --- a/pkg/resourcemanager/rediscaches/rediscache_reconcile.go +++ b/pkg/resourcemanager/rediscaches/rediscache_reconcile.go @@ -75,7 +75,7 @@ func (rc *AzureRedisCacheManager) Ensure(ctx context.Context, obj runtime.Object errhelp.RequestConflictError, errhelp.BadRequest, } - if helpers.ContainsString(unrecoverable, azerr.Type) { + if helpers.ContainsString(unrecoverable, azerr.Type) || azerr.Code == http.StatusBadRequest { return true, nil } From af72aba4b224d4fa52bc18e175100271979be74d Mon Sep 17 00:00:00 2001 From: Jarrod Skulavik <2044176+jskulavik@users.noreply.github.com> Date: Fri, 27 Mar 2020 14:33:45 -0600 Subject: [PATCH 18/20] Handle LocationNotAvailableForResourceType for Azure SQL (#801) * Trap SQL Server region dis-allowed error * Fix issue with Delete, handle generic error lastly * Fix name check timing and move error handling to a switch statement * Add error handling for LocationNotAvailableForResourceType * Fix secret not found status message set * Add back old secret checking logic * Add Status message back in error handling * Add FailedProvisioning check back Co-authored-by: William Mortl <32373900+WilliamMortlMicrosoft@users.noreply.github.com> --- controllers/async_controller.go | 47 ++++++++------- .../azuresqlserver_reconcile.go | 60 +++++++++---------- 2 files changed, 53 insertions(+), 54 deletions(-) diff --git a/controllers/async_controller.go b/controllers/async_controller.go index 662ac118241..cc1f732a74b 100644 --- a/controllers/async_controller.go +++ b/controllers/async_controller.go @@ -41,17 +41,18 @@ type AsyncReconciler struct { } // Reconcile reconciles the change request -func (r *AsyncReconciler) Reconcile(req ctrl.Request, local runtime.Object) (result ctrl.Result, err error) { +func (r *AsyncReconciler) Reconcile(req ctrl.Request, obj runtime.Object) (result ctrl.Result, err error) { ctx := context.Background() - if err := r.Get(ctx, req.NamespacedName, local); err != nil { + if err := r.Get(ctx, req.NamespacedName, obj); err != nil { r.Telemetry.LogInfoByInstance("ignorable error", "error during fetch from api server", req.String()) return ctrl.Result{}, client.IgnoreNotFound(err) } // get the ASOStatus struct - status, err := r.AzureClient.GetStatus(local) + status, err := r.AzureClient.GetStatus(obj) if err != nil { + r.Telemetry.LogErrorByInstance("unable to fetch status", err, req.String()) return ctrl.Result{}, err } @@ -61,7 +62,7 @@ func (r *AsyncReconciler) Reconcile(req ctrl.Request, local runtime.Object) (res status.RequestedAt = &timeNow } - res, err := meta.Accessor(local) + res, err := meta.Accessor(obj) if err != nil { r.Telemetry.LogErrorByInstance("accessor fail", err, req.String()) return ctrl.Result{}, err @@ -70,7 +71,7 @@ func (r *AsyncReconciler) Reconcile(req ctrl.Request, local runtime.Object) (res var keyvaultSecretClient secrets.SecretClient // Determine if we need to check KeyVault for secrets - KeyVaultName := keyvaultsecretlib.GetKeyVaultName(local) + KeyVaultName := keyvaultsecretlib.GetKeyVaultName(obj) if len(KeyVaultName) != 0 { // Instantiate the KeyVault Secret Client @@ -83,7 +84,7 @@ func (r *AsyncReconciler) Reconcile(req ctrl.Request, local runtime.Object) (res // update the status of the resource in kubernetes status.Message = "Waiting for secretclient keyvault to be available" - return ctrl.Result{RequeueAfter: requeDuration}, r.Status().Update(ctx, local) + return ctrl.Result{RequeueAfter: requeDuration}, r.Status().Update(ctx, obj) } } @@ -103,48 +104,48 @@ func (r *AsyncReconciler) Reconcile(req ctrl.Request, local runtime.Object) (res RemoveFinalizer(res, finalizerName) } } - r.Recorder.Event(local, corev1.EventTypeNormal, "Skipping", "Skipping reconcile based on provided annotation") - return ctrl.Result{}, r.Update(ctx, local) + r.Recorder.Event(obj, corev1.EventTypeNormal, "Skipping", "Skipping reconcile based on provided annotation") + return ctrl.Result{}, r.Update(ctx, obj) } var configOptions []resourcemanager.ConfigOption if res.GetDeletionTimestamp().IsZero() { if !HasFinalizer(res, finalizerName) { AddFinalizer(res, finalizerName) - r.Recorder.Event(local, corev1.EventTypeNormal, "Added", "Object finalizer is added") - return ctrl.Result{}, r.Update(ctx, local) + r.Recorder.Event(obj, corev1.EventTypeNormal, "Added", "Object finalizer is added") + return ctrl.Result{}, r.Update(ctx, obj) } } else { if HasFinalizer(res, finalizerName) { if len(KeyVaultName) != 0 { //KeyVault was specified in Spec, so use that for secrets configOptions = append(configOptions, resourcemanager.WithSecretClient(keyvaultSecretClient)) } - found, deleteErr := r.AzureClient.Delete(ctx, local, configOptions...) + found, deleteErr := r.AzureClient.Delete(ctx, obj, configOptions...) final := multierror.Append(deleteErr) if err := final.ErrorOrNil(); err != nil { r.Telemetry.LogErrorByInstance("error deleting object", err, req.String()) - r.Recorder.Event(local, corev1.EventTypeWarning, "FailedDelete", fmt.Sprintf("Failed to delete resource: %s", err.Error())) + r.Recorder.Event(obj, corev1.EventTypeWarning, "FailedDelete", fmt.Sprintf("Failed to delete resource: %s", err.Error())) return ctrl.Result{}, err } if !found { - r.Recorder.Event(local, corev1.EventTypeNormal, "Deleted", "Successfully deleted") + r.Recorder.Event(obj, corev1.EventTypeNormal, "Deleted", "Successfully deleted") RemoveFinalizer(res, finalizerName) - return ctrl.Result{}, r.Update(ctx, local) + return ctrl.Result{}, r.Update(ctx, obj) } r.Telemetry.LogInfoByInstance("requeuing", "deletion unfinished", req.String()) - return ctrl.Result{RequeueAfter: requeDuration}, r.Status().Update(ctx, local) + return ctrl.Result{RequeueAfter: requeDuration}, r.Status().Update(ctx, obj) } return ctrl.Result{}, nil } // loop through parents until one is successfully referenced - parents, err := r.AzureClient.GetParents(local) + parents, err := r.AzureClient.GetParents(obj) for _, p := range parents { if err := r.Get(ctx, p.Key, p.Target); err == nil { if pAccessor, err := meta.Accessor(p.Target); err == nil { if err := controllerutil.SetControllerReference(pAccessor, res, r.Scheme); err == nil { r.Telemetry.LogInfoByInstance("status", "setting parent reference", req.String()) - err := r.Update(ctx, local) + err := r.Update(ctx, obj) if err != nil { r.Telemetry.LogErrorByInstance("failed to reference parent", err, req.String()) } @@ -160,7 +161,7 @@ func (r *AsyncReconciler) Reconcile(req ctrl.Request, local runtime.Object) (res configOptions = append(configOptions, resourcemanager.WithSecretClient(keyvaultSecretClient)) } - done, ensureErr := r.AzureClient.Ensure(ctx, local, configOptions...) + done, ensureErr := r.AzureClient.Ensure(ctx, obj, configOptions...) if ensureErr != nil { r.Telemetry.LogErrorByInstance("ensure err", ensureErr, req.String()) } @@ -172,18 +173,18 @@ func (r *AsyncReconciler) Reconcile(req ctrl.Request, local runtime.Object) (res } // update the status of the resource in kubernetes - // Implementations of Ensure() tend to set their outcomes in local.Status - err = r.Status().Update(ctx, local) + // Implementations of Ensure() tend to set their outcomes in obj.Status + err = r.Status().Update(ctx, obj) if err != nil { r.Telemetry.LogInfoByInstance("status", "failed updating status", req.String()) } - final := multierror.Append(ensureErr, r.Update(ctx, local)) + final := multierror.Append(ensureErr, r.Update(ctx, obj)) err = final.ErrorOrNil() if err != nil { - r.Recorder.Event(local, corev1.EventTypeWarning, "FailedReconcile", fmt.Sprintf("Failed to reconcile resource: %s", err.Error())) + r.Recorder.Event(obj, corev1.EventTypeWarning, "FailedReconcile", fmt.Sprintf("Failed to reconcile resource: %s", err.Error())) } else if done { - r.Recorder.Event(local, corev1.EventTypeNormal, "Reconciled", "Successfully reconciled") + r.Recorder.Event(obj, corev1.EventTypeNormal, "Reconciled", "Successfully reconciled") } result = ctrl.Result{} diff --git a/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go index 88d472eab13..2b8e2e2da7f 100644 --- a/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go @@ -8,7 +8,6 @@ import ( "fmt" "strings" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql" "github.com/Azure/azure-service-operator/api/v1alpha1" "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/helpers" @@ -39,20 +38,6 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object, return false, err } - // convert kube labels to expected tag format - labels := map[string]*string{} - for k, v := range instance.GetLabels() { - value := v - labels[k] = &value - } - - // set a spec hash if one hasn't been set - hash := helpers.Hash256(instance.Spec) - if instance.Status.SpecHash == hash && instance.Status.Provisioned { - instance.Status.RequestedAt = nil - return true, nil - } - // Check to see if secret already exists for admin username/password // create or update the secret key := types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace} @@ -63,8 +48,9 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object, return false, fmt.Errorf("Secret missing for provisioned server: %s", key.String()) } + // Assure that the requested name is available and assume the secret exists checkNameResult, _ := CheckNameAvailability(ctx, instance.Name) - if checkNameResult.Reason == sql.AlreadyExists { + if *checkNameResult.Available != true { instance.Status.Provisioning = false if _, err := s.GetServer(ctx, instance.Spec.ResourceGroup, instance.Name); err != nil { instance.Status.Message = "SQL server already exists somewhere else" @@ -102,6 +88,20 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object, AdministratorLoginPassword: to.StringPtr(string(secret["password"])), } + // convert kube labels to expected tag format + labels := map[string]*string{} + for k, v := range instance.GetLabels() { + value := v + labels[k] = &value + } + + // set a spec hash if one hasn't been set + hash := helpers.Hash256(instance.Spec) + if instance.Status.SpecHash == hash && instance.Status.Provisioned { + instance.Status.RequestedAt = nil + return true, nil + } + if instance.Status.SpecHash == "" { instance.Status.SpecHash = hash } @@ -137,19 +137,21 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object, // create the sql server instance.Status.Provisioning = true if _, err := s.CreateOrUpdateSQLServer(ctx, instance.Spec.ResourceGroup, instance.Spec.Location, instance.Name, labels, azureSQLServerProperties, false); err != nil { + instance.Status.Message = err.Error() + // check for our known errors azerr := errhelp.NewAzureErrorAzureError(err) - // the first successful call to create the server should result in this type of error - // we save the credentials here - if azerr.Type == errhelp.AsyncOpIncompleteError { + switch azerr.Type { + case errhelp.AsyncOpIncompleteError: + // the first successful call to create the server should result in this type of error + // we save the credentials here instance.Status.Message = "Resource request successfully submitted to Azure" return false, nil - } - - // SQL Server names are globally unique so if a server with this name exists we need to see if it meets our criteria (ie. same rg/sub) - if azerr.Type == errhelp.AlreadyExists { + case errhelp.AlreadyExists: + // SQL Server names are globally unique so if a server with this name exists we + // need to see if it meets our criteria (ie. same rg/sub) // see if server exists in correct rg if serv, err := s.GetServer(ctx, instance.Spec.ResourceGroup, instance.Name); err == nil { // mismatched location @@ -163,19 +165,15 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object, // should be good, let the next reconcile finish return false, nil } - // this server likely belongs to someone else instance.Status.Provisioning = false instance.Status.RequestedAt = nil - return true, nil - } - - // is this a bad location / region? - if azerr.Type == errhelp.LocationNotAvailableForResourceType { + case errhelp.LocationNotAvailableForResourceType: + // Subscription does not support the requested service in the requested region instance.Status.Message = fmt.Sprintf("%s is an invalid location for an Azure SQL Server based on your subscription", instance.Spec.Location) - instance.Status.Provisioned = false instance.Status.Provisioning = false + instance.Status.Provisioned = false return true, nil } @@ -225,7 +223,7 @@ func (s *AzureSqlServerManager) Delete(ctx context.Context, obj runtime.Object, groupName := instance.Spec.ResourceGroup key := types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace} - // if the resource is in a failed state it was never creatred or could never be verified + // if the resource is in a failed state it was never created or could never be verified // so we skip attempting to delete the resrouce from Azure if instance.Status.FailedProvisioning || strings.Contains(instance.Status.Message, "credentials could not be found") { return false, nil From fd5eae44e86d23252714a5018e95468b77a39c20 Mon Sep 17 00:00:00 2001 From: Jarrod Skulavik <2044176+jskulavik@users.noreply.github.com> Date: Mon, 30 Mar 2020 12:29:20 -0600 Subject: [PATCH 19/20] Handle RequestDisallowedByPolicy for Azure SQL Server (#847) * Add RequestDisallowedByPolicy to error types * Add error handler for Azure policy restrictions for Azure SQL Server * Trap correct error and successfully set status message --- pkg/errhelp/errors.go | 1 + .../azuresql/azuresqlserver/azuresqlserver_reconcile.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/pkg/errhelp/errors.go b/pkg/errhelp/errors.go index dce494064ec..f3dde7b0e52 100644 --- a/pkg/errhelp/errors.go +++ b/pkg/errhelp/errors.go @@ -46,6 +46,7 @@ const ( RequestConflictError = "Conflict" ValidationError = "ValidationError" SubscriptionDoesNotHaveServer = "SubscriptionDoesNotHaveServer" + RequestDisallowedByPolicy = "RequestDisallowedByPolicy" ) func NewAzureError(err error) error { diff --git a/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go index 2b8e2e2da7f..0cfd41c2c66 100644 --- a/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go @@ -175,6 +175,11 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object, instance.Status.Provisioning = false instance.Status.Provisioned = false return true, nil + case errhelp.RequestDisallowedByPolicy: + instance.Status.Message = "Unable to provision Azure SQL Server due to Azure Policy restrictions contact your policy administrators for further assistance" + instance.Status.Provisioning = false + instance.Status.Provisioned = false + return true, nil } // these errors are expected for recoverable states From e5dd2f1cbca84a6878e216028c56f25f0fc39f81 Mon Sep 17 00:00:00 2001 From: Mel Rush Date: Mon, 30 Mar 2020 13:06:44 -0600 Subject: [PATCH 20/20] Postgresql: DB state removal, and Server state var update (#819) * state fixes * removing my yaml i accidently added hehe * comment fix * fixing else block * bumping status so both cases can read * swapping to same format * fix depointer - switch back Co-authored-by: William Mortl <32373900+WilliamMortlMicrosoft@users.noreply.github.com> --- pkg/resourcemanager/psql/database/client.go | 12 +++--------- pkg/resourcemanager/psql/server/client.go | 8 +++----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/pkg/resourcemanager/psql/database/client.go b/pkg/resourcemanager/psql/database/client.go index e663fb10cae..553196d5612 100644 --- a/pkg/resourcemanager/psql/database/client.go +++ b/pkg/resourcemanager/psql/database/client.go @@ -69,14 +69,13 @@ func (p *PSQLDatabaseClient) Ensure(ctx context.Context, obj runtime.Object, opt client := getPSQLDatabasesClient() instance.Status.Provisioning = true - // Check if this database already exists and its state if it does. This is required + // Check if this database already exists. This is required // to overcome the issue with the lack of idempotence of the Create call - db, err := p.GetDatabase(ctx, instance.Spec.ResourceGroup, instance.Spec.Server, instance.Name) + _, err = p.GetDatabase(ctx, instance.Spec.ResourceGroup, instance.Spec.Server, instance.Name) if err == nil { instance.Status.Provisioned = true instance.Status.Provisioning = false - instance.Status.State = db.Status instance.Status.Message = resourcemanager.SuccessMsg return true, nil } @@ -114,9 +113,7 @@ func (p *PSQLDatabaseClient) Ensure(ctx context.Context, obj runtime.Object, opt return false, err } - instance.Status.State = future.Status() - - db, err = future.Result(client) + _, err = future.Result(client) if err != nil { // let the user know what happened instance.Status.Message = err.Error() @@ -146,8 +143,6 @@ func (p *PSQLDatabaseClient) Ensure(ctx context.Context, obj runtime.Object, opt return false, err } - instance.Status.State = db.Status - if instance.Status.Provisioning { instance.Status.Provisioned = true instance.Status.Provisioning = false @@ -173,7 +168,6 @@ func (p *PSQLDatabaseClient) Delete(ctx context.Context, obj runtime.Object, opt return true, err } } - instance.Status.State = status if err == nil { if status != "InProgress" { diff --git a/pkg/resourcemanager/psql/server/client.go b/pkg/resourcemanager/psql/server/client.go index c32b129ba87..6ef051c4c7c 100644 --- a/pkg/resourcemanager/psql/server/client.go +++ b/pkg/resourcemanager/psql/server/client.go @@ -105,16 +105,14 @@ func (p *PSQLServerClient) Ensure(ctx context.Context, obj runtime.Object, opts server, err := p.GetServer(ctx, instance.Spec.ResourceGroup, instance.Name) if err == nil { + instance.Status.State = string(server.UserVisibleState) if server.UserVisibleState == "Ready" { instance.Status.Provisioned = true instance.Status.Provisioning = false - instance.Status.State = "Ready" instance.Status.Message = resourcemanager.SuccessMsg return true, nil - } else { - instance.Status.State = "InProgress" - return false, nil } + return false, nil } adminlogin := string(secret["username"]) @@ -205,7 +203,7 @@ func (p *PSQLServerClient) Ensure(ctx context.Context, obj runtime.Object, opts return false, err } - instance.Status.State = server.Status + instance.Status.State = string(server.UserVisibleState) if instance.Status.Provisioning { instance.Status.Provisioned = true