| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Utilities for operating on instance metadata.""" | 5 """Utilities for operating on instance metadata.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 | 9 |
| 10 from google.appengine.ext import ndb | 10 from google.appengine.ext import ndb |
| 11 | 11 |
| 12 from components import gce | 12 from components import gce |
| 13 from components import net | 13 from components import net |
| 14 from components import utils | |
| 15 | 14 |
| 16 import metrics | 15 import metrics |
| 17 import models | 16 import models |
| 18 import utilities | 17 import utilities |
| 19 | 18 |
| 20 | 19 |
| 21 def apply_metadata_update(items, metadata): | 20 def apply_metadata_update(items, metadata): |
| 22 """Returns the result of applying the given metadata update. | 21 """Returns the result of applying the given metadata update. |
| 23 | 22 |
| 24 Args: | 23 Args: |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 if instance.active_metadata_update: | 313 if instance.active_metadata_update: |
| 315 if instance.active_metadata_update.url: | 314 if instance.active_metadata_update.url: |
| 316 # Enqueue task to check the in-progress metadata operation. | 315 # Enqueue task to check the in-progress metadata operation. |
| 317 queue = 'check-instance-metadata-operation' | 316 queue = 'check-instance-metadata-operation' |
| 318 else: | 317 else: |
| 319 # Enqueue task to start a metadata operation. | 318 # Enqueue task to start a metadata operation. |
| 320 queue = 'update-instance-metadata' | 319 queue = 'update-instance-metadata' |
| 321 elif instance.pending_metadata_updates: | 320 elif instance.pending_metadata_updates: |
| 322 # Enqueue task to compress a list of desired metadata updates. | 321 # Enqueue task to compress a list of desired metadata updates. |
| 323 queue = 'compress-instance-metadata-updates' | 322 queue = 'compress-instance-metadata-updates' |
| 324 if queue and not utils.enqueue_task( | 323 if queue: |
| 325 '/internal/queues/%s' % queue, | 324 utilities.enqueue_task(queue, instance.key) |
| 326 queue, | |
| 327 params={ | |
| 328 'key': instance.key.urlsafe(), | |
| 329 }, | |
| 330 ): | |
| 331 logging.warning('Failed to enqueue task for Instance: %s', instance.key) | |
| OLD | NEW |