fix: Add retry logic to role synchronization

Closes #3099
This commit is contained in:
Jorge Solorzano 2026-06-04 11:18:47 +02:00
parent a2585e3ee1
commit f8116039ce
No known key found for this signature in database
GPG Key ID: F857175B7A3A5ACB
1 changed files with 13 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import (
"github.com/zalando/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"github.com/zalando/postgres-operator/pkg/util/retryutil"
batchv1 "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
policyv1 "k8s.io/api/policy/v1" policyv1 "k8s.io/api/policy/v1"
@ -1510,7 +1511,18 @@ DBUSERS:
} }
pgSyncRequests := c.userSyncStrategy.ProduceSyncRequests(dbUsers, newUsers) pgSyncRequests := c.userSyncStrategy.ProduceSyncRequests(dbUsers, newUsers)
if err = c.userSyncStrategy.ExecuteSyncRequests(pgSyncRequests, c.pgDb); err != nil {
err = retryutil.Retry(
constants.PostgresConnectTimeout,
constants.PostgresConnectRetryTimeout,
func() (bool, error) {
err2 := c.userSyncStrategy.ExecuteSyncRequests(pgSyncRequests, c.pgDb)
if err2 != nil {
return false, err2
}
return true, nil
})
if err != nil {
return fmt.Errorf("error executing sync statements: %v", err) return fmt.Errorf("error executing sync statements: %v", err)
} }