Skip to content

Commit

Permalink
Bug Fix - ops_manager User Creation (IBM-Cloud#4790)
Browse files Browse the repository at this point in the history
* fixed ops_manager creation bug
  • Loading branch information
omaraibrahim authored and Blintmester committed Nov 21, 2023
1 parent c1b80e6 commit a142137
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
18 changes: 9 additions & 9 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "go.mod|go.sum|.*.map|^.secrets.baseline$",
"lines": null
},
"generated_at": "2023-09-01T17:36:43Z",
"generated_at": "2023-09-11T17:15:43Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -2050,31 +2050,31 @@
"hashed_secret": "deab23f996709b4e3d14e5499d1cc2de677bfaa8",
"is_secret": false,
"is_verified": false,
"line_number": 1560,
"line_number": 1559,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "20a25bac21219ffff1904bde871ded4027eca2f8",
"is_secret": false,
"is_verified": false,
"line_number": 2213,
"line_number": 2212,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 2232,
"line_number": 2231,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "1f5e25be9b575e9f5d39c82dfd1d9f4d73f1975c",
"is_secret": false,
"is_verified": false,
"line_number": 2497,
"line_number": 2496,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -2139,7 +2139,7 @@
],
"ibm/service/database/resource_ibm_database_mongodb_sharding_test.go": [
{
"hashed_secret": "75074b1c70e165b25d1a07655ce513f0053018dc",
"hashed_secret": "5667b8489a17faa9ef54941db31ed762be280bec",
"is_secret": false,
"is_verified": false,
"line_number": 141,
Expand Down Expand Up @@ -3586,23 +3586,23 @@
"hashed_secret": "f855f5027fd8fdb2df3f6a6f1cf858fffcbedb0c",
"is_secret": false,
"is_verified": false,
"line_number": 86802,
"line_number": 89160,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "5fb0fa884132a8724a8d7cba55853737e442adbd",
"is_secret": false,
"is_verified": false,
"line_number": 108081,
"line_number": 111481,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "1e5c2f367f02e47a8c160cda1cd9d91decbac441",
"is_secret": false,
"is_verified": false,
"line_number": 136739,
"line_number": 141026,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
15 changes: 11 additions & 4 deletions ibm/service/database/resource_ibm_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -3152,11 +3152,18 @@ func userUpdateCreate(userData map[string]interface{}, instanceID string, meta i
return fmt.Errorf("[ERROR] ChangeUserPassword (%s) failed %s\n%s", *changeUserPasswordOptions.Username, err, response)
}

taskID := *changeUserPasswordResponse.Task.ID
updatePass, err := waitForDatabaseTaskComplete(taskID, d, meta, d.Timeout(schema.TimeoutUpdate))
updatePass := true // Assume that update password passed

if err != nil {
log.Printf("[ERROR] Error waiting for database (%s) user (%s) password update task to complete: %s", instanceID, *changeUserPasswordOptions.Username, err)
if userData["type"].(string) == "ops_manager" && response.StatusCode == 404 {
updatePass = false // when user_password api can't find an ops_manager user, it returns a 404 and does not get to the point of creating a task
} else {
// when user_password api can't find a database user, its task fails
taskID := *changeUserPasswordResponse.Task.ID
updatePass, err = waitForDatabaseTaskComplete(taskID, d, meta, d.Timeout(schema.TimeoutUpdate))

if err != nil {
log.Printf("[ERROR] Error waiting for database (%s) user (%s) password update task to complete: %s", instanceID, *changeUserPasswordOptions.Username, err)
}
}

// Updating the password has failed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ func testAccCheckIBMDatabaseInstanceMongoDBShardingFullyspecified(databaseResour
}
users {
name = "user124"
password = "password12password"
type = "database"
password = "password$12password"
type = "ops_manager"
}
allowlist {
address = "172.168.1.2/32"
Expand Down

0 comments on commit a142137

Please sign in to comment.