Merge "Skip storage nodes when listing per-host k8s upgrade info"

This commit is contained in:
Zuul 2021-11-18 20:54:06 +00:00 committed by Gerrit Code Review
commit 27f4d85c65
3 changed files with 7 additions and 1 deletions

View File

@ -132,6 +132,10 @@ def do_kube_host_upgrade_list(cc, args):
# Get the kubernetes host upgrades
kube_host_upgrade_details = _get_kube_host_upgrade_details(cc)
# Keep only the hosts that have kubernetes upgrade details.
# Storage nodes aren't part of the kubernetes cluster, for example.
ihosts = [host for host in ihosts if host.id in kube_host_upgrade_details]
for host in ihosts:
host.target_version = \
kube_host_upgrade_details[host.id]['target_version']

View File

@ -8446,6 +8446,8 @@ class Connection(api.Connection):
query = query.join(models.ihost,
models.KubeHostUpgrade.host_id == models.ihost.id)
query = query.filter(models.ihost.recordtype == "standard")
# Filter out the storage nodes since they aren't running k8s.
query = query.filter(models.ihost.subfunctions != "storage")
return _paginate_query(models.KubeHostUpgrade, limit, marker,
sort_key, sort_dir, query)

View File

@ -193,7 +193,7 @@ class TestListKubeHostUpgrade(TestKubeHostUpgrade):
worker = self._create_worker(mgmt_ip='192.168.24.12')
storage = self._create_storage(mgmt_ip='192.168.24.13')
data = self.get_json('/kube_host_upgrades')
self.assertEqual(4, len(data['kube_host_upgrades']))
self.assertEqual(3, len(data['kube_host_upgrades']))
host_id = 1
for upgrade in data['kube_host_upgrades']:
self.assertIn('id', upgrade)