@@ -2311,12 +2311,18 @@ func (r *Reconciler) reconcileManualBackup(ctx context.Context,
23112311 // resulting in a duplicated backup jobs per one pg-backup resources.
23122312 // For more information check the K8SPG-804 PR description.
23132313 currentPostgresCluster := new (v1beta1.PostgresCluster )
2314- if err := r .Client .Get (ctx , client .ObjectKeyFromObject (postgresCluster ), currentPostgresCluster ); err != nil {
2314+ err := r .Client .Get (ctx , client .ObjectKeyFromObject (postgresCluster ), currentPostgresCluster )
2315+ if client .IgnoreNotFound (err ) != nil {
23152316 return err
23162317 }
2318+
2319+ // refPostgresCluster keeps pointer to the postgresCluster which is used in other reconcile functions
2320+ // It should be used to assign values to the postgresCluster inside this function
2321+ refPostgresCluster := postgresCluster
2322+
23172323 // If it's the first run of reconcileManualBackup .Status will be nil.
23182324 // Nothing will happen if we keep the old postgresCluster.
2319- if currentPostgresCluster .Status .PGBackRest != nil {
2325+ if ! k8serrors . IsNotFound ( err ) && currentPostgresCluster .Status .PGBackRest != nil {
23202326 postgresCluster = currentPostgresCluster
23212327 }
23222328
@@ -2411,7 +2417,7 @@ func (r *Reconciler) reconcileManualBackup(ctx context.Context,
24112417 meta .RemoveStatusCondition (& postgresCluster .Status .Conditions ,
24122418 ConditionManualBackupSuccessful )
24132419
2414- postgresCluster .Status .PGBackRest .ManualBackup = manualStatus
2420+ refPostgresCluster .Status .PGBackRest .ManualBackup = manualStatus
24152421 }
24162422
24172423 // if the status shows the Job is no longer in progress, then simply exit (which means a Job
0 commit comments