From 484557f023948b3363b7c5d78d6a457810e8f64d Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Fri, 20 Nov 2020 13:01:52 +0100 Subject: [PATCH] Fix conditionals/types in check_flavors and verify_profiles Existing resources "DISK_GB", "MEMORY_MB", "VCPU" were not considered to be available in case of custom_resource_class_val == False, also use correct types for resource comparison and required_count calculation. Change-Id: Ia194cebaeb7dcc40b4011e50cdde7648b4bf87b1 Closes-Bug: #1905018 (cherry picked from commit 3221727a8d56d9edb8f6b3dd4cdfb0094b49f757) --- library/check_flavors.py | 7 ++++--- library/verify_profiles.py | 2 +- .../consider_existing_resources-addc5b2527d9db1b.yaml | 6 ++++++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/consider_existing_resources-addc5b2527d9db1b.yaml diff --git a/library/check_flavors.py b/library/check_flavors.py index ae5862099..a140f421f 100644 --- a/library/check_flavors.py +++ b/library/check_flavors.py @@ -139,14 +139,15 @@ def validate_roles_and_flavors(roles_info, flavors): if not custom_resource_class: errors.append(resource_class_missing.format( flavor_name)) - if not custom_resource_class_val: + if key not in ["DISK_GB", "MEMORY_MB", "VCPU"] and \ + not custom_resource_class_val: errors.append(resource_class_value_incorrect. format(flavor_name)) disk = resource_specs.get("DISK_GB", None) memory = resource_specs.get("MEMORY_MB", None) vcpu = resource_specs.get("VCPU", None) - if any(int(resource) != 0 for resource in [disk, memory, - vcpu]): + if any(int(resource) != 0 for resource in [disk, + memory, vcpu]): errors.append(disable_standard_scheduling. format(flavor_name)) diff --git a/library/verify_profiles.py b/library/verify_profiles.py index 58e81e6f3..1ff0bf8ba 100644 --- a/library/verify_profiles.py +++ b/library/verify_profiles.py @@ -109,7 +109,7 @@ def verify_profiles(nodes, flavors): assigned_nodes = [uu for uu, caps in free_node_caps.items() if caps.get('profile') == profile] - required_count = scale - len(assigned_nodes) + required_count = int(scale) - len(assigned_nodes) if required_count < 0: warnings.append('%d nodes with profile %s won\'t be used ' diff --git a/releasenotes/notes/consider_existing_resources-addc5b2527d9db1b.yaml b/releasenotes/notes/consider_existing_resources-addc5b2527d9db1b.yaml new file mode 100644 index 000000000..b710b9199 --- /dev/null +++ b/releasenotes/notes/consider_existing_resources-addc5b2527d9db1b.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Existing resources "DISK_GB", "MEMORY_MB", "VCPU" were not considered to + be available in case of custom_resource_class_val == False, also use correct + types for resource comparison and required_count calculation.