@@ -266,16 +266,55 @@ func DeleteBackup(request msgs.DeleteBackrestBackupRequest) msgs.DeleteBackrestB
266266 return response
267267 }
268268
269+ // determine if TLS verification is enabled or not
270+ verifyTLS , _ := strconv .ParseBool (operator .GetS3VerifyTLSSetting (cluster ))
271+
269272 // set up the command
270273 cmd := pgBackRestExpireCommand
271274 cmd = append (cmd , request .Target )
272275
273- // and execute. if there is an error, return it, otherwise we are done
274- if _ , stderr , err := kubeapi .ExecToPodThroughAPI (apiserver .RESTConfig ,
275- apiserver .Clientset , cmd , containername , podName , cluster .Spec .Namespace , nil ); err != nil {
276- log .Error (stderr )
276+ // first, if storage types is empty, assume it's the posix storage type
277+ storageTypes := cluster .Spec .BackrestStorageTypes
278+ if len (storageTypes ) == 0 {
279+ storageTypes = append (storageTypes , crv1 .BackrestStorageTypePosix )
280+ }
281+
282+ // otherwise, iterate through the different repositories types that are
283+ // available. if it's a non-local repository, we need to set an explicit
284+ // "--repo-type"
285+ ok := false
286+
287+ for _ , storageType := range storageTypes {
288+ c := cmd
289+
290+ switch storageType {
291+ default : // do nothing
292+ case crv1 .BackrestStorageTypeS3 :
293+ c = append (c , repoTypeFlagS3 ... )
294+
295+ if ! verifyTLS {
296+ c = append (c , noRepoS3VerifyTLS )
297+ }
298+ }
299+
300+ // so...we don't necessarily care about the error here, because we're
301+ // looking for which of the repos contains the target backup. We'll log the
302+ // error, and return it if we don't have success
303+ if _ , stderr , err := kubeapi .ExecToPodThroughAPI (apiserver .RESTConfig ,
304+ apiserver .Clientset , c , containername , podName , cluster .Namespace , nil ); err != nil {
305+ log .Infof ("repo type %s does not contain backup %s or other error." , storageType , request .Target )
306+ log .Info (stderr )
307+ } else {
308+ ok = true
309+ }
310+ }
311+
312+ // if we don't ever delete the backup, provide a message as to why
313+ if ! ok {
314+ msg := fmt .Sprintf ("could not find backup %s in any repo or check logs for other errors." , request .Target )
315+ log .Errorf (msg )
277316 response .Code = msgs .Error
278- response .Msg = stderr
317+ response .Msg = msg
279318 }
280319
281320 return response
0 commit comments