| 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 instances.""" | 5 """Utilities for operating on instances.""" |
| 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 pubsub | |
| 15 from components import utils | 14 from components import utils |
| 16 | 15 |
| 17 import instance_group_managers | 16 import instance_group_managers |
| 18 import metrics | 17 import metrics |
| 19 import models | 18 import models |
| 20 import utilities | 19 import utilities |
| 21 | 20 |
| 22 | 21 |
| 23 def get_instance_key(base_name, revision, zone, instance_name): | 22 def get_instance_key(base_name, revision, zone, instance_name): |
| 24 """Returns a key for an Instance. | 23 """Returns a key for an Instance. |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 orphaned = 0 | 394 orphaned = 0 |
| 396 for instance in models.Instance.query(): | 395 for instance in models.Instance.query(): |
| 397 total += 1 | 396 total += 1 |
| 398 instance_group_manager = instance.key.parent().get() | 397 instance_group_manager = instance.key.parent().get() |
| 399 if (not instance_group_manager | 398 if (not instance_group_manager |
| 400 or instance.key not in instance_group_manager.instances): | 399 or instance.key not in instance_group_manager.instances): |
| 401 logging.warning('Found orphaned Instance: %s', instance.key) | 400 logging.warning('Found orphaned Instance: %s', instance.key) |
| 402 orphaned += 1 | 401 orphaned += 1 |
| 403 logging.info('Orphaned Instances: %s/%s', orphaned, total) | 402 logging.info('Orphaned Instances: %s/%s', orphaned, total) |
| 404 return orphaned, total | 403 return orphaned, total |
| OLD | NEW |