Skip to content

Commit

Permalink
Clarify documentation for sample MySQLAdministrator (#1334)
Browse files Browse the repository at this point in the history
* Clarify that Sid should be client ID for managed identities

* Add more detail to logging for errors connecting to MySQL

Co-authored-by: Bevan Arps <bevan.arps@microsoft.com>
  • Loading branch information
babbageclunk and theunrepentantgeek authored Dec 15, 2020
1 parent 0159ca8 commit 82f75ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion api/v1alpha1/mysqlserveradministrator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ type MySQLServerAdministratorSpec struct {
// +kubebuilder:validation:Required
Login string `json:"login"`

//Sid: The server administrator Sid (Secure ID). If creating an AAD user, this is the OID of the entity in AAD.
//Sid: The server administrator Sid (Secure ID). If creating for
//an AAD user or group, this is the OID of the entity in AAD. For
//a managed identity this should be the Client ID (or app id) of
//the identity.
// +kubebuilder:validation:Required
Sid string `json:"sid"`

Expand Down
4 changes: 2 additions & 2 deletions config/samples/azure_v1alpha1_mysqlserveradministrator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
# This must be the name of the AAD entity. In the case of a managed identity use the name of the managed identity.
# For example: "myuser@microsoft.com" might be the login if specifying an AAD user. "my-mi" might be the name of a managed identity.
login: my-mi
# The sid is the OID of the AAD entity
# The sid should be the client id (sometimes called app id) for a managed identity.
# For a "normal" (non-managed identity) user or group, this is the OID of the user or group.
sid: 00000000-0000-0000-0000-000000000000
tenantId: 00000000-0000-0000-0000-000000000000

4 changes: 2 additions & 2 deletions pkg/resourcemanager/mysql/mysqlhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func ConnectToSqlDB(ctx context.Context, driverName string, fullServer string, d

err = db.PingContext(ctx)
if err != nil {
return db, fmt.Errorf("error ping the mysql db: %v", err)
return db, fmt.Errorf("error pinging the mysql db (%s:%d/%s): %v", fullServer, port, database, err)
}

return db, err
Expand Down Expand Up @@ -84,7 +84,7 @@ func ConnectToSQLDBAsCurrentUser(

err = db.PingContext(ctx)
if err != nil {
return db, fmt.Errorf("error ping the mysql db: %v", err)
return db, fmt.Errorf("error pinging the mysql db (%s:%d/%s) as %s: %v", fullServer, port, database, user, err)
}

return db, err
Expand Down

0 comments on commit 82f75ea

Please sign in to comment.