Browse Source

Fix cluster resize

There are two fixes included in this patch:

1. List nodes correctly. We have renamed minion to node, which
   cause the filter doesn't work correctly.
2. The response from magnumclient resize method is not a json,
   so we need to convert it to dict before return. Rolling upgrade
   has the same issue.

Task: 39810
Story: 2007697

Change-Id: I7a03dfea2c84a423f15cfbe4194a8492f72dbd35
(cherry picked from commit 96312eaf09)
changes/67/740467/2 6.0.1
Feilong Wang 1 year ago
committed by Bharat Kunwar
parent
commit
4a561a9374
  1. 12
      magnum_ui/api/rest/magnum.py

12
magnum_ui/api/rest/magnum.py

@ -227,12 +227,14 @@ class ClusterResize(generic.View):
return HttpResponseNotFound()
stack = heat.stack_get(request, cluster["stack_id"])
search_opts = {"name": "%s-minion" % stack.stack_name}
search_opts = {"name": "%s-" % stack.stack_name}
servers = api.nova.server_list(request, search_opts=search_opts)[0]
worker_nodes = []
for server in servers:
worker_nodes.append({"name": server.name, "id": server.id})
if (server.name.startswith("%s-minion" % stack.stack_name) or
server.name.startswith("%s-node" % stack.stack_name)):
worker_nodes.append({"name": server.name, "id": server.id})
return {"cluster": change_to_id(cluster),
"worker_nodes": worker_nodes}
@ -240,7 +242,6 @@ class ClusterResize(generic.View):
@rest_utils.ajax(data_required=True)
def post(self, request, cluster_id):
"""Resize a cluster"""
nodes_to_remove = request.DATA.get("nodes_to_remove", None)
nodegroup = request.DATA.get("nodegroup", None)
node_count = request.DATA.get("node_count")
@ -249,7 +250,8 @@ class ClusterResize(generic.View):
try:
return magnum.cluster_resize(
request, cluster_id, node_count,
nodes_to_remove=nodes_to_remove, nodegroup=nodegroup)
nodes_to_remove=nodes_to_remove,
nodegroup=nodegroup).to_dict()
except AttributeError as e:
# If cluster is not found magnum-client throws Attribute error
# catch and respond with 404
@ -271,7 +273,7 @@ class ClusterUpgrade(generic.View):
return magnum.cluster_upgrade(
request, cluster_id, cluster_template,
max_batch_size=max_batch_size, nodegroup=nodegroup)
max_batch_size=max_batch_size, nodegroup=nodegroup).to_dict()
@urls.register

Loading…
Cancel
Save