@@ -310,9 +310,6 @@ func deleteBeforeUpgrade(clientset kubeapi.Interface, clusterName, currentPrimar
310310 // delete the '<cluster-name>-pgha-default-config' configmap, if it exists so the config syncer
311311 // will not try to use it instead of '<cluster-name>-pgha-config'
312312 clientset .CoreV1 ().ConfigMaps (namespace ).Delete (clusterName + "-pgha-default-config" , & metav1.DeleteOptions {})
313-
314- // delete the backrest repo config secret, since key encryption has been updated from RSA to EdDSA
315- clientset .CoreV1 ().Secrets (namespace ).Delete (clusterName + "-backrest-repo-config" , & metav1.DeleteOptions {})
316313}
317314
318315// deploymentWait is modified from cluster.waitForDeploymentDelete. It simply waits for the current primary deployment
@@ -402,17 +399,35 @@ func createUpgradePGHAConfigMap(clientset kubernetes.Interface, cluster *crv1.Pg
402399 return nil
403400}
404401
405- // recreateBackrestRepoSecret deletes and recreates the secret for the pgBackRest repo. This is needed
402+ // recreateBackrestRepoSecret overwrites the secret for the pgBackRest repo. This is needed
406403// because the key encryption algorithm has been updated from RSA to EdDSA
407404func recreateBackrestRepoSecret (clientset kubernetes.Interface , clustername , namespace , operatorNamespace string ) {
408- if err := util .CreateBackrestRepoSecrets (clientset ,
409- util.BackrestRepoConfig {
410- BackrestS3Key : "" , // these are set to empty so that it can be generated
411- BackrestS3KeySecret : "" ,
412- ClusterName : clustername ,
413- ClusterNamespace : namespace ,
414- OperatorNamespace : operatorNamespace ,
415- }); err != nil {
405+ config := util.BackrestRepoConfig {
406+ ClusterName : clustername ,
407+ ClusterNamespace : namespace ,
408+ OperatorNamespace : operatorNamespace ,
409+ }
410+
411+ secretName := clustername + "-backrest-repo-config"
412+ secret , err := clientset .CoreV1 ().Secrets (namespace ).Get (secretName , metav1.GetOptions {})
413+
414+ // >= 4.3
415+ if err == nil {
416+ if b , ok := secret .Data ["aws-s3-ca.crt" ]; ok {
417+ config .BackrestS3CA = b
418+ }
419+ if b , ok := secret .Data ["aws-s3-key" ]; ok {
420+ config .BackrestS3Key = string (b )
421+ }
422+ if b , ok := secret .Data ["aws-s3-key-secret" ]; ok {
423+ config .BackrestS3KeySecret = string (b )
424+ }
425+ }
426+
427+ if err == nil {
428+ err = util .CreateBackrestRepoSecrets (clientset , config )
429+ }
430+ if err != nil {
416431 log .Errorf ("error generating new backrest repo secrets during pgcluster upgrade: %v" , err )
417432 }
418433}
@@ -499,6 +514,11 @@ func preparePgclusterForUpgrade(pgcluster *crv1.Pgcluster, parameters map[string
499514 // cluster operations in this version of the Postgres Operator
500515 pgcluster .ObjectMeta .Labels [config .LABEL_BACKREST ] = "true"
501516
517+ // added in 4.4
518+ if pgcluster .Spec .BackrestS3VerifyTLS == "" {
519+ pgcluster .Spec .BackrestS3VerifyTLS = operator .Pgo .Cluster .BackrestS3VerifyTLS
520+ }
521+
502522 // add a label with the PGO version upgraded from and to
503523 pgcluster .Annotations [config .ANNOTATION_UPGRADE_INFO ] = "From_" + oldpgoversion + "_to_" + parameters [config .LABEL_PGO_VERSION ]
504524 // update the "is upgraded" label to indicate cluster has been upgraded
0 commit comments