Skip to content

Commit 1f15683

Browse files
pooknullhors
andauthored
K8SPG-531: remove error on cluster creation (#746)
https://perconadev.atlassian.net/browse/K8SPG-531 Co-authored-by: Viacheslav Sarzhan <[email protected]>
1 parent 52657cb commit 1f15683

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

percona/controller/pgcluster/controller.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (r *PGClusterReconciler) Reconcile(ctx context.Context, request reconcile.R
226226
}
227227
}
228228

229-
_, err := controllerutil.CreateOrUpdate(ctx, r.Client, postgresCluster, func() error {
229+
opRes, err := controllerutil.CreateOrUpdate(ctx, r.Client, postgresCluster, func() error {
230230
var err error
231231
postgresCluster, err = cr.ToCrunchy(ctx, postgresCluster, r.Client.Scheme())
232232

@@ -236,6 +236,12 @@ func (r *PGClusterReconciler) Reconcile(ctx context.Context, request reconcile.R
236236
return ctrl.Result{}, errors.Wrap(err, "update/create PostgresCluster")
237237
}
238238

239+
// postgresCluster will not be available immediately after creation.
240+
// We should wait some time, it's better to continue on the next reconcile
241+
if opRes == controllerutil.OperationResultCreated {
242+
return ctrl.Result{RequeueAfter: 1 * time.Second}, nil
243+
}
244+
239245
if err := r.Client.Get(ctx, client.ObjectKeyFromObject(postgresCluster), postgresCluster); err != nil {
240246
return ctrl.Result{}, errors.Wrap(err, "get PostgresCluster")
241247
}

0 commit comments

Comments
 (0)