@@ -212,27 +212,35 @@ def fetch_cloud_metadata(self):
212
212
except :
213
213
self .logger .exception ("Failed to fetch cloud image metadata" )
214
214
215
- def fetch_cloud_metadata_wrapper (self ):
216
- for i in range (3 ):
217
- metadata = self .fetch_cloud_metadata ()
218
- if metadata :
219
- return metadata
220
- self .logger .exception ("Image not found on cloud: %s (retry in 10 seconds)" % self .name )
221
- time .sleep (10 )
222
- raise RuntimeError ("Failed to fetch cloud image metadata (3 times): %s" % self .name )
223
-
224
- def get_status (self ):
215
+ def get_status (self ) -> str :
216
+ """Get image update status
217
+
218
+ :return: image status
219
+ - UP_TO_DATE: The local image is the same as the cloud.
220
+ - LOCAL_OUTDATED: The local image hash is different from the cloud.
221
+ - LOCAL_NEWER: The local image is created after the cloud.
222
+ - LOCAL_MISSING: The cloud image exists but no local image.
223
+ - LOCAL_ONLY: The image only exists locally.
224
+ - UNAVAILABLE: The image is not found locally or remotely.
225
+ """
225
226
if self .node .node_config ["use_local_image" ]:
226
227
self .cloud_metadata = None
227
228
return "LOCAL_NEWER"
228
229
229
- self .cloud_metadata = self .fetch_cloud_metadata_wrapper ()
230
230
local = self .local_metadata
231
+
232
+ self .cloud_metadata = self .fetch_cloud_metadata ()
231
233
cloud = self .cloud_metadata
232
- assert cloud
234
+
235
+ if not local and not cloud :
236
+ return "UNAVAILABLE"
237
+
238
+ if local and not cloud :
239
+ return "LOCAL_ONLY"
233
240
234
241
if not local and cloud :
235
242
return "LOCAL_MISSING"
243
+
236
244
if local .digest == cloud .digest :
237
245
return "UP_TO_DATE"
238
246
else :
@@ -243,13 +251,13 @@ def status_message(self):
243
251
if self .status == "UNAVAILABLE" :
244
252
return "unavailable"
245
253
elif self .status == "LOCAL_ONLY" :
246
- return "local"
254
+ return "using local version "
247
255
elif self .status == "LOCAL_MISSING" :
248
- return "missing "
256
+ return "pull "
249
257
elif self .status == "LOCAL_NEWER" :
250
- return "newer "
258
+ return "using local version "
251
259
elif self .status == "LOCAL_OUTDATED" :
252
- return "outdated "
260
+ return "pull "
253
261
elif self .status == "UP_TO_DATE" :
254
262
return "up-to-date"
255
263
@@ -320,24 +328,16 @@ def check_for_updates(self) -> List[Image]:
320
328
images = [image for image in images if image .node .mode == "native" and not image .node .disabled ]
321
329
322
330
def print_failed (failed ):
323
- for image , error in failed :
324
- error_message = get_useful_error_message (error )
325
- if error_message == "timeout" :
326
- raise FatalError ("Timeout error: Couldn't connect to Docker to check for updates. Please check your internet connection and https://status.docker.com/." )
327
- print ("Failed to check for image updates." )
328
- for image , error in failed :
329
- error_message = get_useful_error_message (error )
330
- print ("- {}: {}" .format (image .name , error_message ))
331
+ pass
331
332
332
333
def try_again ():
333
- answer = self .shell .yes_or_no ("Try again?" )
334
- return answer == "yes"
334
+ return False
335
335
336
336
parallel_execute (images , lambda i : i .check_for_updates (), 30 , print_failed , try_again )
337
337
338
338
return images
339
339
340
- def update_images (self ):
340
+ def update_images (self ) -> None :
341
341
for image in self .images .values ():
342
342
status = image .status
343
343
pull_image = image .pull_image
0 commit comments