On Mon, Nov 23, 2020 at 04:47:16PM +0800, Ren Wen wrote:
Return all nodes' ips when request state is "roles_ip".
Example: If roles of all nodes are: "server", "client", ... ips of all nodes are: "<ip01>", "<ip02>", ... Then return: sever=<ip01> client=<ip02> ...
If there are two same roles return, export will be coverd by the last?
Thanks, Xueliang
All nodes will export the return content as environment variables line by line.
src/scheduler/request_cluster_state.cr | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/scheduler/request_cluster_state.cr b/src/scheduler/request_cluster_state.cr index 5bbbad1..72e3810 100644 --- a/src/scheduler/request_cluster_state.cr +++ b/src/scheduler/request_cluster_state.cr @@ -52,11 +52,16 @@ class Sched "direct_macs" => direct_macs} update_cluster_state(cluster_id, job_id, job_info) when "roles_ip"
role = "server"
role_state = get_role_state(cluster_id, role)
raise "Missing #{role} state in cluster state" unless role_state
return "server=#{role_state["ip"]}\n" \
"direct_server_ips=#{role_state["direct_ips"]}"
cluster_state = get_cluster_state(cluster_id)
roles_ip = [] of String
cluster_state.each_value do |host_state|
roles = host_state["roles"]
direct_ips = host_state["direct_ips"]
roles_ip << "#{roles}=#{direct_ips}"
end
return roles_ip.join('\n')
end
# show cluster state
-- 2.23.0