From a2d4b2b1d3a70b441fb5ea3036dbda93c1624321 Mon Sep 17 00:00:00 2001 From: Madhav Puri Date: Wed, 16 Dec 2015 03:48:48 -0800 Subject: [PATCH] align cluster-manager to recent ansible changes - replaced online-master-addr with etcd specific variables - fixed role assignment logic to skip worker nodes Signed-off-by: Madhav Puri --- management/src/clusterm/manager/consts.go | 11 ++++++----- management/src/clusterm/manager/events.go | 13 ++++++++++--- management/src/configuration/ansible.go | 10 ++++++++++ management/src/configuration/configuration.go | 7 ++++++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/management/src/clusterm/manager/consts.go b/management/src/clusterm/manager/consts.go index d7143a2..9ec09d1 100644 --- a/management/src/clusterm/manager/consts.go +++ b/management/src/clusterm/manager/consts.go @@ -26,9 +26,10 @@ const ( ) const ( - ansibleMasterGroupName = "service-master" - ansibleWorkerGroupName = "service-worker" - ansibleNodeNameHostVar = "node_name" - ansibleNodeAddrHostVar = "node_addr" - ansibleOnlineMasterAddrHostVar = "online_master_addr" + ansibleMasterGroupName = "service-master" + ansibleWorkerGroupName = "service-worker" + ansibleNodeNameHostVar = "node_name" + ansibleNodeAddrHostVar = "node_addr" + ansibleEtcdMasterAddrHostVar = "etcd_master_addr" + ansibleEtcdMasterNameHostVar = "etcd_master_name" ) diff --git a/management/src/clusterm/manager/events.go b/management/src/clusterm/manager/events.go index bcf1c74..f052ded 100644 --- a/management/src/clusterm/manager/events.go +++ b/management/src/clusterm/manager/events.go @@ -242,7 +242,8 @@ func (e *nodeConfigure) process() error { hostInfo := e.mgr.nodes[e.nodeName].cInfo.(*configuration.AnsibleHost) nodeGroup := ansibleMasterGroupName - onlineMasterAddr := "" + masterAddr := "" + masterName := "" // update the online master address if this is second node that is being commissioned. // Also set the group for second or later nodes to be worker, as right now services like // swarm and netmaster can only have one master node and also we don't yet have a vip @@ -257,12 +258,18 @@ func (e *nodeConfigure) process() error { // skip hosts that are not yet provisioned or not in discovered state continue } + if node.cInfo.GetGroup() != ansibleMasterGroupName { + //skip the hosts that are not in master group + continue + } // found our node - onlineMasterAddr = node.mInfo.GetMgmtAddress() + masterAddr = node.mInfo.GetMgmtAddress() + masterName = node.cInfo.GetTag() nodeGroup = ansibleWorkerGroupName } hostInfo.SetGroup(nodeGroup) - hostInfo.SetVar(ansibleOnlineMasterAddrHostVar, onlineMasterAddr) + hostInfo.SetVar(ansibleEtcdMasterAddrHostVar, masterAddr) + hostInfo.SetVar(ansibleEtcdMasterNameHostVar, masterName) outReader, errCh := e.mgr.configuration.Configure( configuration.SubsysHosts([]*configuration.AnsibleHost{hostInfo}), e.extraVars) if err := logOutputAndReturnStatus(outReader, errCh); err != nil { diff --git a/management/src/configuration/ansible.go b/management/src/configuration/ansible.go index 643058e..99a7288 100644 --- a/management/src/configuration/ansible.go +++ b/management/src/configuration/ansible.go @@ -42,6 +42,16 @@ func NewAnsibleHost(tag, addr, group string, vars map[string]string) *AnsibleHos } } +// GetTag return the ansible inventory name/tag for the host +func (h *AnsibleHost) GetTag() string { + return h.tag +} + +// GetGroup return the ansible inventory group/role for the host +func (h *AnsibleHost) GetGroup() string { + return h.group +} + // SetVar sets a host variable value func (h *AnsibleHost) SetVar(key, val string) { h.vars[key] = val diff --git a/management/src/configuration/configuration.go b/management/src/configuration/configuration.go index b5c56c1..25c19a7 100644 --- a/management/src/configuration/configuration.go +++ b/management/src/configuration/configuration.go @@ -14,7 +14,12 @@ type Subsys interface { } // SubsysHost denotes a host in configuration subsystem -type SubsysHost interface{} +type SubsysHost interface { + // GetTag returns the name/tag associated with the host in configuration sub-system + GetTag() string + //GetGroup returns the group/role associated with the host in configuration sub-system + GetGroup() string +} // SubsysHosts denotes a collection of hosts in configuration subsystem type SubsysHosts interface{}