Skip to content

Commit

Permalink
Run reset-admin-password on reinstallation
Browse files Browse the repository at this point in the history
fixes: #1294
  • Loading branch information
git-hyagi committed Aug 7, 2024
1 parent f36d26a commit e65c0f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES/1294.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed an issue where the reset-admin-password `Job` was not being deployed during
a reinstallation with the same admin `Secret`.
8 changes: 6 additions & 2 deletions controllers/repo_manager/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ func (r *RepoManagerReconciler) updateAdminPasswordJob(ctx context.Context, pulp
log.Error(err, "Failed to find "+adminSecretName+" Secret!")
}

// if the secret didn't change there is nothing to do
// if the secret is already set (it is not the first execution) and it
// didn't change, there is nothing to do
calculatedHash := controllers.CalculateHash(adminSecret.Data)
currentHash := controllers.GetCurrentHash(adminSecret)
if currentHash == calculatedHash {
if pulp.Status.AdminPasswordSecret != "" && currentHash == calculatedHash {
return
}

Expand Down Expand Up @@ -81,6 +82,9 @@ func (r *RepoManagerReconciler) updateAdminPasswordJob(ctx context.Context, pulp
if err := r.Update(ctx, adminSecret); err != nil {
log.Error(err, "Failed to update "+adminSecretName+" Secret label!")
}

// update the status.admin_password_secret field
setStatus(ctx, pulp, adminPwdSecretCondition(), *r, "AdminPasswordSecret")
}

// pulpcoreVolumes defines the list of volumes used by pulpcore containers
Expand Down
1 change: 0 additions & 1 deletion controllers/repo_manager/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func setStatusFields(ctx context.Context, pulp *repomanagerpulpprojectorgv1beta2
{verifyFunc: dbFieldsEncrSecretCondition(), fieldName: "DBFieldsEncryptionSecret"},
{verifyFunc: ingressTypeCondition(), fieldName: "IngressType"},
{verifyFunc: containerTokenSecretCondition(), fieldName: "ContainerTokenSecret"},
{verifyFunc: adminPwdSecretCondition(), fieldName: "AdminPasswordSecret"},
{verifyFunc: ingressClassNameCondition(), fieldName: "IngressClassName"},
{verifyFunc: pulpSecretKeyCondition(), fieldName: "PulpSecretKey"},
}
Expand Down

0 comments on commit e65c0f3

Please sign in to comment.