diff --git a/api/v1/postgres_types.go b/api/v1/postgres_types.go index 8e8a0825..c580573d 100644 --- a/api/v1/postgres_types.go +++ b/api/v1/postgres_types.go @@ -55,6 +55,8 @@ const ( BackupConfigLabelName string = "postgres.database.fits.cloud/is-backup" // BackupConfigKey defines the key under which the BackupConfig is stored in the data map. BackupConfigKey = "config" + // LastReconciledLabelName Name of the last reconciled label + LastReconciledLabelName string = "postgres.database.fits.cloud/last-reconciled" // SharedBufferParameterKey defines the key under which the shared buffer size is stored in the parameters map. Defined by the postgres-operator/patroni SharedBufferParameterKey = "shared_buffers" // StandbyKey defines the key under which the standby configuration is stored in the CR. Defined by the postgres-operator/patroni @@ -612,6 +614,8 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor // Add the newly introduced label only here, not in p.ToZalandoPostgresqlMatchingLabels() (so that the selectors using p.ToZalandoPostgresqlMatchingLabels() will still work untill all postgres resources have that new label) // TODO once all the custom resources have that new label, move this part to p.ToZalandoPostgresqlMatchingLabels() z.Labels[PartitionIDLabelName] = p.Spec.PartitionID + // Add/update the LastReconciled label + z.Labels[LastReconciledLabelName] = fmt.Sprint(time.Now().Unix()) z.Spec.NumberOfInstances = p.Spec.NumberOfInstances z.Spec.PostgresqlParam.PgVersion = p.Spec.Version diff --git a/controllers/status_controller.go b/controllers/status_controller.go index fcc8106a..d8789e1b 100644 --- a/controllers/status_controller.go +++ b/controllers/status_controller.go @@ -107,6 +107,8 @@ func (r *StatusReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr log.Info("unable to fetch the shared LoadBalancer to update postgres status socket") owner.Status.Socket = pg.Socket{} } + // reset additional sockets + owner.Status.AdditionalSockets = []pg.Socket{} if err := r.CtrlClient.Status().Update(ctx, owner); err != nil { return ctrl.Result{}, fmt.Errorf("failed to update simple postgres status socket: %w", err) @@ -145,6 +147,7 @@ func (r *StatusReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr log.Info("using dedicated loadbalancer as additional status socket") } else { log.Info("failed to use dedicated loadbalancer as additional status socket") + owner.Status.AdditionalSockets = []pg.Socket{} } } else { @@ -160,6 +163,7 @@ func (r *StatusReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr log.Info("failed to use dedicated loadbalancer as primary status socket") owner.Status.Socket = pg.Socket{} } + owner.Status.AdditionalSockets = []pg.Socket{} } // actually perform the status update