diff --git a/manifests/postgresql.crd.yaml b/manifests/postgresql.crd.yaml index c8bf1b07d..808326444 100644 --- a/manifests/postgresql.crd.yaml +++ b/manifests/postgresql.crd.yaml @@ -3470,6 +3470,12 @@ spec: properties: failsafe_mode: type: boolean + ignore_slots: + type: array + items: + type: object + additionalProperties: + type: string initdb: additionalProperties: type: string diff --git a/pkg/apis/acid.zalan.do/v1/postgresql_type.go b/pkg/apis/acid.zalan.do/v1/postgresql_type.go index b304db652..3dced435d 100644 --- a/pkg/apis/acid.zalan.do/v1/postgresql_type.go +++ b/pkg/apis/acid.zalan.do/v1/postgresql_type.go @@ -244,6 +244,7 @@ type Patroni struct { SynchronousModeStrict bool `json:"synchronous_mode_strict,omitempty"` SynchronousNodeCount uint32 `json:"synchronous_node_count,omitempty" defaults:"1"` FailsafeMode *bool `json:"failsafe_mode,omitempty"` + IgnoreSlots []map[string]string `json:"ignore_slots,omitempty"` } // StandbyDescription contains remote primary config and/or s3/gs wal path. diff --git a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go index 79e0787bc..94a2dbdad 100644 --- a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go +++ b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go @@ -597,6 +597,19 @@ func (in *Patroni) DeepCopyInto(out *Patroni) { *out = new(bool) **out = **in } + if in.IgnoreSlots != nil { + in, out := &in.IgnoreSlots, &out.IgnoreSlots + *out = make([]map[string]string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + } + } return } diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 224ef26f6..5826a52d0 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -57,6 +57,7 @@ type patroniDCS struct { PGBootstrapConfiguration map[string]interface{} `json:"postgresql,omitempty"` Slots map[string]map[string]string `json:"slots,omitempty"` FailsafeMode *bool `json:"failsafe_mode,omitempty"` + IgnoreSlots []map[string]string `json:"ignore_slots,omitempty"` } type pgBootstrap struct { @@ -449,6 +450,10 @@ PatroniInitDBParams: config.Bootstrap.DCS.FailsafeMode = opConfig.EnablePatroniFailsafeMode } + + if patroni.IgnoreSlots != nil { + config.Bootstrap.DCS.IgnoreSlots = patroni.IgnoreSlots + } config.PgLocalConfiguration = make(map[string]interface{}) // the newer and preferred way to specify the PG version is to use the `PGVERSION` env variable diff --git a/pkg/cluster/k8sres_test.go b/pkg/cluster/k8sres_test.go index e39e18cd5..16be25640 100644 --- a/pkg/cluster/k8sres_test.go +++ b/pkg/cluster/k8sres_test.go @@ -135,6 +135,17 @@ func TestGenerateSpiloJSONConfiguration(t *testing.T) { }, result: `{"postgresql":{"bin_dir":"/usr/lib/postgresql/17/bin"},"bootstrap":{"initdb":[{"auth-host":"md5"},{"auth-local":"trust"}],"dcs":{"failsafe_mode":true}}}`, }, + { + subtest: "Patroni ignore_slots configured for PostgreSQL 17 slot sync", + pgParam: &acidv1.PostgresqlParam{PgVersion: "17"}, + patroni: &acidv1.Patroni{ + IgnoreSlots: []map[string]string{ + {"type": "logical"}, + }, + }, + opConfig: &config.Config{}, + result: `{"postgresql":{"bin_dir":"/usr/lib/postgresql/17/bin"},"bootstrap":{"initdb":[{"auth-host":"md5"},{"auth-local":"trust"}],"dcs":{"ignore_slots":[{"type":"logical"}]}}}`, + }, } for _, tt := range tests { cluster.OpConfig = *tt.opConfig