Skip to content

Commit

Permalink
Fix panic when checking PMM enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
inelpandzic committed Oct 4, 2023
1 parent 01952ab commit a1a66db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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

0 comments on commit a1a66db

Please sign in to comment.