From c58a22a2b15ec721b24de5dfddbce618a05c768a Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 31 Jan 2019 14:47:36 +0000 Subject: [PATCH] Default Ironic node properties are bogus Unless you add a 'properties' field under the 'ironic_config' for a node spec, ironic nodes are registered with silly default properties (originating in the os_ironic module) which cause validation to fail: cpus:1, memory_mb: 1, local_gb: 1 We have enough info to add sensible defaults based on the VM configuration, so let's do that. Change-Id: I43fbe726d1d787d96be811f3ecd4234ea3b6bac3 Story: 2004908 Task: 29258 --- ansible/roles/ironic-enrolment/tasks/node.yml | 15 +++++++++++++-- .../default-properties-a59636e41be05d66.yaml | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/default-properties-a59636e41be05d66.yaml diff --git a/ansible/roles/ironic-enrolment/tasks/node.yml b/ansible/roles/ironic-enrolment/tasks/node.yml index 5bc086b..5b73b0a 100644 --- a/ansible/roles/ironic-enrolment/tasks/node.yml +++ b/ansible/roles/ironic-enrolment/tasks/node.yml @@ -87,10 +87,21 @@ --{{ iface }}-interface {{ node.ironic_config[iface + '_interface'] }} {% endif %} {% endfor %} - {% for key, val in ( - node.ironic_config.properties | default({})).iteritems() %} + {% for key, val in properties.iteritems() %} --property '{{ key }}={{ val }}' {% endfor %} + vars: + properties: "{{ default_properties | combine(custom_properties) }}" + custom_properties: "{{ node.ironic_config.get('properties', {}) }}" + # Although properties are not required for scheduling, the os_ironic module + # adds silly defaults that cause the validation API call to fail, + # preventing deployment. We add them here because the os_ironic module + # uses unusual names (cpus, ram, disk_size) for scheduling properties, + # and doesn't support setting other properties. + default_properties: + cpus: "{{ node.vcpus }}" + memory_mb: "{{ node.memory_mb }}" + local_gb: "{{ node.volumes[0].capacity | size_string_to_gb if node.volumes | length > 0 else 0 }}" - name: Add Ironic node traits command: >- diff --git a/releasenotes/notes/default-properties-a59636e41be05d66.yaml b/releasenotes/notes/default-properties-a59636e41be05d66.yaml new file mode 100644 index 0000000..19359ba --- /dev/null +++ b/releasenotes/notes/default-properties-a59636e41be05d66.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Adds support for setting default properties on ironic nodes. This avoids an + issue where nodes are registered with the standard scheduling properties + all set to 1, causing ironic validation failures. See `story 2004908 + `__ for details.