Limit cluster update properties

Magnum only allows the node count of cluster being updated. And
in mangum ui, cluster and cluster template are sharing same
function to generating the patch json dict, which is causing lots
of bugs before. So let's define a set for cluster update allowed
properties and use it to restrict the patch json dict.

Task: 26699
Story: 2003865

Change-Id: I2f0126fbf2f7396dda504b988ee11659824fcde8
(cherry picked from commit 895e5095c3)
This commit is contained in:
Feilong Wang 2018-09-25 16:17:44 +12:00 committed by John Garbutt
parent 707b25e636
commit ed5b700bd2
1 changed files with 6 additions and 0 deletions

View File

@ -35,6 +35,7 @@ CLUSTER_TEMPLATE_CREATE_ATTRS = cluster_templates.CREATION_ATTRIBUTES
CLUSTER_CREATE_ATTRS = clusters.CREATION_ATTRIBUTES
CERTIFICATE_CREATE_ATTRS = certificates.CREATION_ATTRIBUTES
QUOTA_CREATION_ATTRIBUTES = quotas.CREATION_ATTRIBUTES
CLUSTER_UPDATE_ALLOWED_PROPERTIES = set(['/node_count'])
def _cleanup_params(attrs, create, **params):
@ -138,6 +139,11 @@ def cluster_template_update(request, id, **kwargs):
old = magnumclient(request).cluster_templates.get(id).to_dict()
old = _cleanup_params(CLUSTER_TEMPLATE_CREATE_ATTRS, False, **old)
patch = _create_patches(old, new)
# NOTE(flwang): Now Magnum only support updating the node count for
# cluster upddate action. So let's simplify it by only passing the
# /node_count dict which can avoid many potential bugs.
patch = [d for d in patch if d['path']
in CLUSTER_UPDATE_ALLOWED_PROPERTIES]
return magnumclient(request).cluster_templates.update(id, patch)