@@ -127,9 +127,9 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec cpov1.Postgresq
127127 if ! ok {
128128 passwordEncryption = "scram-sha-256"
129129 }
130- if pgSpec .Spec .Monitoring != nil {
131- pgSpec .AddMonitoringUser (monitorUsername )
132- }
130+ // if pgSpec.Spec.Monitoring != nil {
131+ // pgSpec.AddMonitoringUser(monitorUsername)
132+ // }
133133 cluster := & Cluster {
134134 Config : cfg ,
135135 Postgresql : pgSpec ,
@@ -352,12 +352,12 @@ func (c *Cluster) Create() (err error) {
352352 }
353353 c .logger .Info ("a TDE secret was successfully created" )
354354 }
355- if c .Postgresql .Spec .Monitoring != nil {
356- if err := c .createMonitoringSecret (); err != nil {
357- return fmt .Errorf ("could not create the monitoring secret: %v" , err )
358- }
359- c .logger .Info ("a monitoring secret was successfully created" )
360- }
355+ // if c.Postgresql.Spec.Monitoring != nil {
356+ // if err := c.createMonitoringSecret(); err != nil {
357+ // return fmt.Errorf("could not create the monitoring secret: %v", err)
358+ // }
359+ // c.logger.Info("a monitoring secret was successfully created")
360+ // }
361361
362362 if specHasPgbackrestClone (& c .Postgresql .Spec ) {
363363 if err := c .createPgbackrestCloneConfig (); err != nil {
@@ -433,29 +433,33 @@ func (c *Cluster) Create() (err error) {
433433 // something fails, report warning
434434 c .createConnectionPooler (c .installLookupFunction )
435435
436- //Setup cpo monitoring related sql statements
437- if c .Spec .Monitoring != nil {
438- c .logger .Info ("setting up CPO monitoring" )
439-
440- // Open a new connection to the postgres db tp setup monitoring struc and permissions
441- if err := c .initDbConnWithName ("postgres" ); err != nil {
442- return fmt .Errorf ("could not init database connection" )
443- }
444- defer func () {
445- if c .connectionIsClosed () {
446- return
447- }
448-
449- if err := c .closeDbConn (); err != nil {
450- c .logger .Errorf ("could not close database connection: %v" , err )
451- }
452- }()
453- _ , err := c .pgDb .Exec (CPOmonitoring )
454- if err != nil {
455- return fmt .Errorf ("CPO monitoring could not be setup: %v" , err )
456- }
436+ if c .Spec .Monitoring != nil { #Hinzufügen und in database.go die function von pooler nachbauen und dann den unteren teil (alt ) komplett entfernen
437+ c .addMonitoringPermissions ()
457438 }
458439
440+ //Setup cpo monitoring related sql statements
441+ // if c.Spec.Monitoring != nil {
442+ // c.logger.Info("setting up CPO monitoring")
443+
444+ // // Open a new connection to the postgres db tp setup monitoring struc and permissions
445+ // if err := c.initDbConnWithName("postgres"); err != nil {
446+ // return fmt.Errorf("could not init database connection")
447+ // }
448+ // defer func() {
449+ // if c.connectionIsClosed() {
450+ // return
451+ // }
452+
453+ // if err := c.closeDbConn(); err != nil {
454+ // c.logger.Errorf("could not close database connection: %v", err)
455+ // }
456+ // }()
457+ // _, err := c.pgDb.Exec(CPOmonitoring)
458+ // if err != nil {
459+ // return fmt.Errorf("CPO monitoring could not be setup: %v", err)
460+ // }
461+ // }
462+
459463 // remember slots to detect deletion from manifest
460464 for slotName , desiredSlot := range c .Spec .Patroni .Slots {
461465 c .replicationSlots [slotName ] = desiredSlot
@@ -1199,6 +1203,11 @@ func (c *Cluster) Update(oldSpec, newSpec *cpov1.Postgresql) error {
11991203 updateFailed = true
12001204 }
12011205
1206+ // Check if we need to call addMonitoringPermissions-func
1207+ if c .Spec .Monitoring != nil && needMonitoring ){
1208+ c .addMonitoringPermissions ()
1209+ }
1210+
12021211 // streams
12031212 if len (newSpec .Spec .Streams ) > 0 {
12041213 if err := c .syncStreams (); err != nil {
0 commit comments