@@ -50,34 +50,35 @@ def get_unique_name(placeholder=""):
5050
5151 def wait_for_zonal_operation (self , operation ):
5252 client = ZoneOperationsClient ()
53- result = client .wait (
54- operation = operation , zone = self .DEFAULT_ZONE , project = self .DEFAULT_PROJECT
55- )
56- if result .error :
57- self .fail ("Zonal operation {} has errors" .format (operation ))
58- op = client .get (
59- operation = operation , zone = self .DEFAULT_ZONE , project = self .DEFAULT_PROJECT
60- )
61- # this is a workaround, some operations take up to 3 min, currently we cant set timeout for wait()
62- if op .status != Operation .Status .DONE :
63- client .wait (
53+ while True :
54+ op = client .wait (
6455 operation = operation ,
6556 zone = self .DEFAULT_ZONE ,
6657 project = self .DEFAULT_PROJECT ,
6758 )
59+ if op .status == Operation .Status .DONE :
60+ if op .error :
61+ self .fail ("Zonal operation {} has errors" .format (operation ))
62+ break
6863
6964 def wait_for_regional_operation (self , operation ):
7065 client = RegionOperationsClient ()
71- result = client .wait (
72- operation = operation ,
73- region = self .DEFAULT_REGION ,
74- project = self .DEFAULT_PROJECT ,
75- )
76- if result .error :
77- self .fail ("Region operation {} has errors" .format (operation ))
66+ while True :
67+ op = client .wait (
68+ operation = operation ,
69+ region = self .DEFAULT_REGION ,
70+ project = self .DEFAULT_PROJECT ,
71+ )
72+ if op .status == Operation .Status .DONE :
73+ if op .error :
74+ self .fail ("Region operation {} has errors" .format (operation ))
75+ break
7876
7977 def wait_for_global_operation (self , operation ):
8078 client = GlobalOperationsClient ()
81- result = client .wait (operation = operation , project = self .DEFAULT_PROJECT )
82- if result .error :
83- self .fail ("Global operation {} has errors" .format (operation ))
79+ while True :
80+ op = client .wait (operation = operation , project = self .DEFAULT_PROJECT )
81+ if op .status == Operation .Status .DONE :
82+ if op .error :
83+ self .fail ("Global operation {} has errors" .format (operation ))
84+ break
0 commit comments