Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Kevin/5.5.x/max master nodes (#636)
Browse files Browse the repository at this point in the history
* remove hard requirement that prevents more than 3 masters (#560)

* fix typos
  • Loading branch information
Kevin Nisbet authored Sep 10, 2019
1 parent 7506c27 commit 59aaef8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
26 changes: 22 additions & 4 deletions lib/install/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,22 +627,40 @@ func (i *Installer) getInstallerTrustedCluster() (storage.TrustedCluster, error)

// splitServers splits the provided servers into masters and nodes
func splitServers(servers []storage.Server, app app.Application) (masters []storage.Server, nodes []storage.Server, err error) {
count := 0
numMasters := 0

// count the number of servers designated as master by the node profile
for _, server := range servers {
profile, err := app.Manifest.NodeProfiles.ByName(server.Role)
if err != nil {
return nil, nil, trace.Wrap(err)
}

if profile.ServiceRole == schema.ServiceRoleMaster {
numMasters++
}
}

// assign the servers to their roles
for _, server := range servers {
profile, err := app.Manifest.NodeProfiles.ByName(server.Role)
if err != nil {
return nil, nil, trace.Wrap(err)
}
switch profile.ServiceRole {
case schema.ServiceRoleMaster, "":
if count < defaults.MaxMasterNodes {
case "":
if numMasters < defaults.MaxMasterNodes {
server.ClusterRole = string(schema.ServiceRoleMaster)
masters = append(masters, server)
count++
numMasters++
} else {
server.ClusterRole = string(schema.ServiceRoleNode)
nodes = append(nodes, server)
}
case schema.ServiceRoleMaster:
server.ClusterRole = string(schema.ServiceRoleMaster)
masters = append(masters, server)
// don't increment numMasters as this server has already been counted above
case schema.ServiceRoleNode:
server.ClusterRole = string(schema.ServiceRoleNode)
nodes = append(nodes, server)
Expand Down
20 changes: 17 additions & 3 deletions lib/ops/opsservice/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,22 +873,36 @@ func checkLicenseCPU(p licenseapi.Payload, numCPU uint) error {
}

// setClusterRoles assigns cluster roles to servers.
// If a server has an explicit cluster role assigned, the function will make sure that
// the maximum number of masters is not exceeded.
func setClusterRoles(servers []storage.Server, app libapp.Application, masters int) error {
// count the number of servers designated as master by the node profile
for _, server := range servers {
profile, err := app.Manifest.NodeProfiles.ByName(server.Role)
if err != nil {
return trace.Wrap(err)
}

if profile.ServiceRole == schema.ServiceRoleMaster {
masters++
}
}

// assign the servers to their roles
for i, server := range servers {
profile, err := app.Manifest.NodeProfiles.ByName(server.Role)
if err != nil {
return trace.Wrap(err)
}
switch profile.ServiceRole {
case schema.ServiceRoleMaster, "":
case "":
if masters < defaults.MaxMasterNodes {
servers[i].ClusterRole = string(schema.ServiceRoleMaster)
masters++
} else {
servers[i].ClusterRole = string(schema.ServiceRoleNode)
}
case schema.ServiceRoleMaster:
servers[i].ClusterRole = string(schema.ServiceRoleMaster)
// don't increment masters as this server has already been counted above
case schema.ServiceRoleNode:
servers[i].ClusterRole = string(schema.ServiceRoleNode)
default:
Expand Down

0 comments on commit 59aaef8

Please sign in to comment.