@@ -1971,11 +1971,17 @@ def get_backup_mode(
19711971 patch : kopf .Patch ,
19721972 status : kopf .Status ,
19731973 logger : logging .Logger ,
1974+ except_backup_mode : List = None ,
19741975) -> str :
1975- if is_s3_manual_backup_mode (meta , spec , patch , status , logger ):
1976+ if except_backup_mode is None :
1977+ except_backup_mode = [BACKUP_MODE_S3_MANUAL , BACKUP_MODE_S3_CRON ]
1978+
1979+ if BACKUP_MODE_S3_MANUAL in except_backup_mode and is_s3_manual_backup_mode (
1980+ meta , spec , patch , status , logger ):
19761981 return BACKUP_MODE_S3_MANUAL
19771982
1978- if is_s3_cron_backup_mode (meta , spec , patch , status , logger ):
1983+ if BACKUP_MODE_S3_CRON in except_backup_mode and is_s3_cron_backup_mode (
1984+ meta , spec , patch , status , logger ):
19791985 return BACKUP_MODE_S3_CRON
19801986
19811987 return BACKUP_MODE_NONE
@@ -4055,8 +4061,8 @@ def trigger_backup_to_s3_manual(
40554061 NEW , DIFF_FIELD_SPEC_BACKUPS3_MANUAL [len (
40564062 DIFF_FIELD_SPEC_BACKUPCLUSTER
40574063 ):len (DIFF_FIELD_SPEC_BACKUPS3_MANUAL )]) == True ):
4058- if get_backup_mode (meta , spec , patch , status ,
4059- logger ) == BACKUP_MODE_S3_MANUAL :
4064+ if get_backup_mode (meta , spec , patch , status , logger ,
4065+ [ BACKUP_MODE_S3_MANUAL ] ) == BACKUP_MODE_S3_MANUAL :
40604066 backup_postgresql (meta , spec , patch , status , logger )
40614067
40624068
@@ -5679,8 +5685,8 @@ def cron_backup(
56795685 cron_expression : str ,
56805686) -> None :
56815687 try :
5682- if get_backup_mode (meta , spec , patch , status ,
5683- logger ) == BACKUP_MODE_S3_CRON :
5688+ if get_backup_mode (meta , spec , patch , status , logger ,
5689+ [ BACKUP_MODE_S3_CRON ] ) == BACKUP_MODE_S3_CRON :
56845690 backup_postgresql (meta , spec , patch , status , logger )
56855691 except kopf .PermanentError :
56865692 logger .error (f"cron_backup failed." )
0 commit comments