Skip to content

Postgres cluster reconciler creates Secret and ConfigMap#1749

Draft
DmytroPI-dev wants to merge 2 commits intofeature/database-controllersfrom
postgres-operator-secrets-confmaps
Draft

Postgres cluster reconciler creates Secret and ConfigMap#1749
DmytroPI-dev wants to merge 2 commits intofeature/database-controllersfrom
postgres-operator-secrets-confmaps

Conversation

@DmytroPI-dev
Copy link

Description

_Creates ConfigMap and Secret for PostgresCluster _

Key Changes

Highlight the updates in specific files

Testing and Verification

How did you test these changes? What automated tests are added?

Related Issues

CPI-1903 CPI-1907

PR Checklist

  • Code changes adhere to the project's coding standards.
  • Relevant unit and integration tests are included.
  • Documentation has been updated accordingly.
  • All tests pass locally.
  • The PR description follows the project's guidelines.

SuperuserSecret: cnpgv1.LocalObjectReference{
Name: secretName,
},
EnableSuperuserAccess: *ptr.To(true),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need * before ptr.To?

if cnpgCluster.Status.Phase == cnpgv1.PhaseHealthy {
logger.Info("CNPG Cluster is ready, generating ConfigMap for connection details")

// Reconcile ConfigMap
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets put a comments that doesnt reflect what we do here but lets put it with the why in case we need it

logger.Error(err, "Failed to fetch existing ConfigMap")
return err
}
existingConfigMap.Data = configMap.Data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt we check if they are equal and only send update API call if they do?

"CLUSTER_R_ENDPOINT": fmt.Sprintf("%s.%s.svc", cnpgCluster.Status.ReadService, postgresCluster.Namespace),
"CLUSTER_RO_ENDPOINT": fmt.Sprintf("%so.%s.svc", cnpgCluster.Status.ReadService, postgresCluster.Namespace),
"DEFAULT_CLUSTER_PORT": defaultPort,
"DEFAULT_USER": defaultUsername,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its probably not a default user but superuser

}

// generatePassword creates a random 16-character alphanumeric password for the default postgres user.
func generatePassword() string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to use something already provided like: https://github.com/sethvargo/go-password?

Owner string
StorageSize string
Resources corev1.ResourceRequirements
SuperuserSecret cnpgv1.LocalObjectReference
Copy link
Collaborator

@mploski mploski Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need those two in here? EnableSuperuserAccess and SuperuserSecret is not part of the class? I think secrets and configmaps can be checked outside of this process?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants