Skip to content

Commit

Permalink
issue-728, default user secret already exists error
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksiienkoMykyta authored and ribaraka committed Mar 4, 2024
1 parent a169e1d commit 5d2261a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -1075,35 +1075,35 @@
"filename": "pkg/models/operator.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 154
"line_number": 155
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "d65d45369e8aef106a8ca1c3bad151ad24163494",
"is_verified": false,
"line_number": 184
"line_number": 185
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "638724dcc0799a22cc4adce12434fcac73c8af58",
"is_verified": false,
"line_number": 185
"line_number": 186
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "4fe486f255f36f8787d5c5cc1185e3d5d5c91c03",
"is_verified": false,
"line_number": 186
"line_number": 187
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "2331919a92cbb5c2d530947171fa5e1a1415af2f",
"is_verified": false,
"line_number": 187
"line_number": 188
}
],
"pkg/utils/user_creds_from_secret_test.go": [
Expand Down Expand Up @@ -1132,5 +1132,5 @@
}
]
},
"generated_at": "2024-02-29T10:48:32Z"
"generated_at": "2024-03-04T13:33:17Z"
}
12 changes: 12 additions & 0 deletions controllers/clusters/cassandra_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,18 @@ func (r *CassandraReconciler) createDefaultSecret(ctx context.Context, c *v1beta

patch := c.NewPatch()
secret := newDefaultUserSecret(username, password, c.Name, c.Namespace)
err = controllerutil.SetOwnerReference(c, secret, r.Scheme)
if err != nil {
l.Error(err, "Cannot set secret owner reference with default user credentials",
"cluster ID", c.Status.ID,
)
r.EventRecorder.Eventf(c, models.Warning, models.SetOwnerRef,
"Setting secret owner ref with default user credentials is failed. Reason: %v", err,
)

return err
}

err = r.Create(ctx, secret)
if err != nil {
l.Error(err, "Cannot create secret with default user credentials",
Expand Down
1 change: 1 addition & 0 deletions pkg/models/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const (
DeletionFailed = "DeletionFailed"
Deleted = "Deleted"
ExternalDeleted = "ExternalDeleted"
SetOwnerRef = "SettingOwnerRefFailed"
)

const (
Expand Down

0 comments on commit 5d2261a

Please sign in to comment.