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()