Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8SPG-401: Fix panic when checking PMM enabled #526

Merged
merged 6 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions percona/controller/pgcluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (r *PGClusterReconciler) Reconcile(ctx context.Context, request reconcile.R
users = append(users, user)
}

if cr.Spec.PMM.Enabled {
if cr.PMMEnabled() {
users = append(cr.Spec.Users, v1beta1.PostgresUserSpec{
Name: pmm.MonitoringUser,
Options: "SUPERUSER",
Expand Down Expand Up @@ -253,7 +253,7 @@ func (r *PGClusterReconciler) Reconcile(ctx context.Context, request reconcile.R
}

func (r *PGClusterReconciler) addPMMSidecar(ctx context.Context, cr *v2.PerconaPGCluster) error {
if cr.Spec.PMM == nil || !cr.Spec.PMM.Enabled {
if !cr.PMMEnabled() {
return nil
}

Expand Down Expand Up @@ -319,7 +319,7 @@ func (r *PGClusterReconciler) addPMMSidecar(ctx context.Context, cr *v2.PerconaP
}

func (r *PGClusterReconciler) handleMonitorUserPassChange(ctx context.Context, cr *v2.PerconaPGCluster) error {
if cr.Spec.PMM == nil || !cr.Spec.PMM.Enabled {
if !cr.PMMEnabled() {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion percona/controller/pgcluster/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (r *PGClusterReconciler) getVersionMeta(cr *v2.PerconaPGCluster, operatorDe
PGVersion: strconv.Itoa(cr.Spec.PostgresVersion),
BackupVersion: "",
PMMVersion: "",
PMMEnabled: cr.Spec.PMM != nil && cr.Spec.PMM.Enabled,
PMMEnabled: cr.PMMEnabled(),
}

if _, ok := cr.Labels["helm.sh/chart"]; ok {
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ type PMMSpec struct {
RuntimeClassName *string `json:"runtimeClassName,omitempty"`
}

func (cr *PerconaPGCluster) PMMEnabled() bool {
return cr.Spec.PMM != nil && cr.Spec.PMM.Enabled
}

type SecretsSpec struct {
// The secret containing the Certificates and Keys to encrypt PostgreSQL
// traffic will need to contain the server TLS certificate, TLS key and the
Expand Down
Loading