127
127
SPEC_ANTIAFFINITY_POLICY_PREFERRED ,
128
128
SPEC_ANTIAFFINITY_PODANTIAFFINITYTERM ,
129
129
SPEC_ANTIAFFINITY_TOPOLOGYKEY ,
130
+ SPEC_VOLUME_TYPE ,
131
+ SPEC_VOLUME_LOCAL ,
132
+ SPEC_VOLUME_CLOUD ,
133
+ SECONDS ,
134
+ MINUTES ,
135
+ HOURS ,
136
+ DAYS ,
130
137
)
131
138
132
139
FIELD_DELIMITER = "-"
@@ -499,7 +506,7 @@ def waiting_cluster_correct_status(
499
506
def waiting_postgresql_ready (
500
507
conns : InstanceConnections ,
501
508
logger : logging .Logger ,
502
- timeout : int = 300 ,
509
+ timeout : int = MINUTES * 5 ,
503
510
connect_start : int = None ,
504
511
connect_end : int = None ,
505
512
) -> bool :
@@ -539,7 +546,7 @@ def waiting_target_postgresql_ready(meta: kopf.Meta,
539
546
connect_start : int = None ,
540
547
connect_end : int = None ,
541
548
exit : bool = False ,
542
- timeout : int = 300 ) -> None :
549
+ timeout : int = MINUTES * 5 ) -> None :
543
550
conns : InstanceConnections = connections (spec , meta , patch , field , False ,
544
551
None , logger , None , status , False ,
545
552
None )
@@ -2758,11 +2765,13 @@ def rolling_update(
2758
2765
logger : logging .Logger ,
2759
2766
target_roles : List ,
2760
2767
exit : bool = False ,
2768
+ delete_disk : bool = False ,
2769
+ timeout : int = MINUTES * 5 ,
2761
2770
) -> None :
2762
2771
if target_roles is None :
2763
2772
return
2764
2773
2765
- # rolling update autofailover
2774
+ # rolling update autofailover, not allow autofailover delete disk when update cluster
2766
2775
if get_field (AUTOFAILOVER ) in target_roles :
2767
2776
autofailover_machines = spec .get (AUTOFAILOVER ).get (MACHINES )
2768
2777
if autofailover_machines != None :
@@ -2775,7 +2784,7 @@ def rolling_update(
2775
2784
create_autofailover (meta , spec , patch , status , logger ,
2776
2785
get_autofailover_labels (meta ))
2777
2786
waiting_target_postgresql_ready (meta , spec , patch , get_field (AUTOFAILOVER ),
2778
- status , logger , 0 , 1 , exit )
2787
+ status , logger , 0 , 1 , exit , timeout )
2779
2788
2780
2789
# rolling update readwrite
2781
2790
if get_field (POSTGRESQL , READWRITEINSTANCE ) in target_roles :
@@ -2786,27 +2795,27 @@ def rolling_update(
2786
2795
delete_postgresql_readwrite (
2787
2796
meta , spec , patch , status , logger ,
2788
2797
get_field (POSTGRESQL , READWRITEINSTANCE ),
2789
- readwrite_machines [replica :replica + 1 ], None , False )
2798
+ readwrite_machines [replica :replica + 1 ], None , delete_disk )
2790
2799
create_postgresql_readwrite (meta , spec , patch , status , logger ,
2791
2800
get_readwrite_labels (meta ),
2792
2801
replica , False , replica + 1 )
2793
2802
waiting_target_postgresql_ready (
2794
2803
meta , spec , patch , get_field (POSTGRESQL ,
2795
2804
READWRITEINSTANCE ), status ,
2796
- logger , replica , replica + 1 , exit )
2805
+ logger , replica , replica + 1 , exit , timeout )
2797
2806
else :
2798
2807
for replica in range (0 , spec [POSTGRESQL ][READWRITEINSTANCE ][REPLICAS ]):
2799
2808
delete_postgresql_readwrite (
2800
2809
meta , spec , patch , status , logger ,
2801
2810
get_field (POSTGRESQL , READWRITEINSTANCE ), None ,
2802
- [replica , replica + 1 ], False )
2811
+ [replica , replica + 1 ], delete_disk )
2803
2812
create_postgresql_readwrite (meta , spec , patch , status , logger ,
2804
2813
get_readwrite_labels (meta ), replica ,
2805
2814
False , replica + 1 )
2806
2815
waiting_target_postgresql_ready (meta , spec , patch ,
2807
2816
get_field (POSTGRESQL ,
2808
2817
READWRITEINSTANCE ), status ,
2809
- logger , replica , replica + 1 , exit )
2818
+ logger , replica , replica + 1 , exit , timeout )
2810
2819
2811
2820
# rolling update readonly
2812
2821
if get_field (POSTGRESQL , READONLYINSTANCE ) in target_roles :
@@ -2817,25 +2826,25 @@ def rolling_update(
2817
2826
delete_postgresql_readonly (
2818
2827
meta , spec , patch , status , logger ,
2819
2828
get_field (POSTGRESQL , READONLYINSTANCE ),
2820
- readonly_machines [replica :replica + 1 ], None , False )
2829
+ readonly_machines [replica :replica + 1 ], None , delete_disk )
2821
2830
create_postgresql_readonly (meta , spec , patch , status , logger ,
2822
2831
get_readonly_labels (meta ), replica ,
2823
2832
replica + 1 )
2824
2833
waiting_target_postgresql_ready (
2825
2834
meta , spec , patch , get_field (POSTGRESQL , READONLYINSTANCE ),
2826
- status , logger , replica , replica + 1 , exit )
2835
+ status , logger , replica , replica + 1 , exit , timeout )
2827
2836
else :
2828
2837
for replica in range (0 , spec [POSTGRESQL ][READONLYINSTANCE ][REPLICAS ]):
2829
2838
delete_postgresql_readonly (meta , spec , patch , status , logger ,
2830
2839
get_field (POSTGRESQL , READONLYINSTANCE ),
2831
- None , [replica , replica + 1 ], False )
2840
+ None , [replica , replica + 1 ], delete_disk )
2832
2841
create_postgresql_readonly (meta , spec , patch , status , logger ,
2833
2842
get_readonly_labels (meta ), replica ,
2834
2843
replica + 1 )
2835
2844
waiting_target_postgresql_ready (meta , spec , patch ,
2836
2845
get_field (POSTGRESQL ,
2837
2846
READONLYINSTANCE ), status ,
2838
- logger , replica , replica + 1 , exit )
2847
+ logger , replica , replica + 1 , exit , timeout )
2839
2848
2840
2849
2841
2850
def update_podspec_volume (
@@ -2875,8 +2884,15 @@ def update_antiaffinity(
2875
2884
logger : logging .Logger ,
2876
2885
target_roles : List ,
2877
2886
exit : bool = False ,
2887
+ delete_disk : bool = False ,
2888
+ timeout : int = MINUTES * 5 ,
2878
2889
) -> None :
2879
- rolling_update (meta , spec , patch , status , logger , target_roles , exit )
2890
+ # local volume
2891
+ if spec .get (SPEC_VOLUME_TYPE ) == SPEC_VOLUME_LOCAL :
2892
+ delete_disk = True
2893
+ timeout = HOURS * 1
2894
+ rolling_update (meta , spec , patch , status , logger , target_roles , exit ,
2895
+ delete_disk , timeout )
2880
2896
2881
2897
2882
2898
def update_replicas (
0 commit comments