@@ -1093,9 +1093,10 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
10931093 sort .Slice (customPodEnvVarsList ,
10941094 func (i , j int ) bool { return customPodEnvVarsList [i ].Name < customPodEnvVarsList [j ].Name })
10951095
1096- if spec .StandbyCluster != nil && spec .StandbyCluster .S3WalPath == "" &&
1097- spec .StandbyCluster .GSWalPath == "" {
1098- return nil , fmt .Errorf ("one of s3_wal_path or gs_wal_path must be set for standby cluster" )
1096+ if spec .StandbyCluster != nil {
1097+ if spec .StandbyCluster .S3WalPath == "" && spec .StandbyCluster .GSWalPath == "" && spec .StandbyCluster .StandbyHost == "" {
1098+ return nil , fmt .Errorf ("s3_wal_path, gs_wal_path and standby_host are empty for standby cluster" )
1099+ }
10991100 }
11001101
11011102 // backward compatible check for InitContainers
@@ -1905,39 +1906,49 @@ func (c *Cluster) generateCloneEnvironment(description *acidv1.CloneDescription)
19051906func (c * Cluster ) generateStandbyEnvironment (description * acidv1.StandbyDescription ) []v1.EnvVar {
19061907 result := make ([]v1.EnvVar , 0 )
19071908
1908- if description .S3WalPath == "" && description .GSWalPath == "" {
1909- return nil
1910- }
1911-
1912- if description .S3WalPath != "" {
1913- // standby with S3, find out the bucket to setup standby
1914- msg := "Standby from S3 bucket using custom parsed S3WalPath from the manifest %s "
1915- c .logger .Infof (msg , description .S3WalPath )
1916-
1909+ if description .StandbyHost != "" {
1910+ // standby from remote primary
19171911 result = append (result , v1.EnvVar {
1918- Name : "STANDBY_WALE_S3_PREFIX " ,
1919- Value : description .S3WalPath ,
1912+ Name : "STANDBY_HOST " ,
1913+ Value : description .StandbyHost ,
19201914 })
1921- } else if description .GSWalPath != "" {
1922- msg := "Standby from GS bucket using custom parsed GSWalPath from the manifest %s "
1923- c .logger .Infof (msg , description .GSWalPath )
1915+ if description .StandbyPort != "" {
1916+ result = append (result , v1.EnvVar {
1917+ Name : "STANDBY_PORT" ,
1918+ Value : description .StandbyPort ,
1919+ })
1920+ }
1921+ } else {
1922+ if description .S3WalPath != "" {
1923+ // standby with S3, find out the bucket to setup standby
1924+ msg := "Standby from S3 bucket using custom parsed S3WalPath from the manifest %s "
1925+ c .logger .Infof (msg , description .S3WalPath )
19241926
1925- envs := []v1.EnvVar {
1926- {
1927- Name : "STANDBY_WALE_GS_PREFIX" ,
1928- Value : description .GSWalPath ,
1929- },
1930- {
1931- Name : "STANDBY_GOOGLE_APPLICATION_CREDENTIALS" ,
1932- Value : c .OpConfig .GCPCredentials ,
1933- },
1927+ result = append (result , v1.EnvVar {
1928+ Name : "STANDBY_WALE_S3_PREFIX" ,
1929+ Value : description .S3WalPath ,
1930+ })
1931+ } else if description .GSWalPath != "" {
1932+ msg := "Standby from GS bucket using custom parsed GSWalPath from the manifest %s "
1933+ c .logger .Infof (msg , description .GSWalPath )
1934+
1935+ envs := []v1.EnvVar {
1936+ {
1937+ Name : "STANDBY_WALE_GS_PREFIX" ,
1938+ Value : description .GSWalPath ,
1939+ },
1940+ {
1941+ Name : "STANDBY_GOOGLE_APPLICATION_CREDENTIALS" ,
1942+ Value : c .OpConfig .GCPCredentials ,
1943+ },
1944+ }
1945+ result = append (result , envs ... )
19341946 }
1935- result = append (result , envs ... )
19361947
1937- }
1948+ result = append (result , v1.EnvVar {Name : "STANDBY_METHOD" , Value : "STANDBY_WITH_WALE" })
1949+ result = append (result , v1.EnvVar {Name : "STANDBY_WAL_BUCKET_SCOPE_PREFIX" , Value : "" })
19381950
1939- result = append (result , v1.EnvVar {Name : "STANDBY_METHOD" , Value : "STANDBY_WITH_WALE" })
1940- result = append (result , v1.EnvVar {Name : "STANDBY_WAL_BUCKET_SCOPE_PREFIX" , Value : "" })
1951+ }
19411952
19421953 return result
19431954}
0 commit comments