Skip to content

Commit

Permalink
types: allow custom names for control and compute pools
Browse files Browse the repository at this point in the history
After openshift#1157 there is no need to restrict what name is used for the
controlPlane Machines or compute MachineSets. By removing this
restriction, multiple compute MachineSets can be defined at install
time.
  • Loading branch information
montaguethomas committed Jul 13, 2021
1 parent a5c73e9 commit d008e7d
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pkg/asset/cluster/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func tagSharedIAMRoles(ctx context.Context, clusterID string, installConfig *ins
iamRoleNames = append(iamRoleNames, &iamRole)
}
}
if mp := installConfig.Config.WorkerMachinePool(); mp != nil {
for _, mp := range installConfig.Config.Compute {
awsMP := &awstypes.MachinePool{}
awsMP.Set(installConfig.Config.AWS.DefaultMachinePlatform)
awsMP.Set(mp.Platform.AWS)
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
}

workerIAMRoleName := ""
if mp := installConfig.Config.WorkerMachinePool(); mp != nil {
if mp := &installConfig.Config.Compute[0]; mp != nil {
awsMP := &aws.MachinePool{}
awsMP.Set(installConfig.Config.AWS.DefaultMachinePlatform)
awsMP.Set(mp.Platform.AWS)
Expand Down
3 changes: 1 addition & 2 deletions pkg/types/defaults/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ func SetInstallConfigDefaults(c *types.InstallConfig) {
}

if c.ControlPlane == nil {
c.ControlPlane = &types.MachinePool{}
c.ControlPlane = &types.MachinePool{Name: "master"}
}
c.ControlPlane.Name = "master"
SetMachinePoolDefaults(c.ControlPlane, c.Platform.Name())
if len(c.Compute) == 0 {
c.Compute = []types.MachinePool{{Name: "worker"}}
Expand Down
14 changes: 1 addition & 13 deletions pkg/types/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const (
// InstallConfigVersion is the version supported by this package.
// If you bump this, you must also update the list of convertable values in
// pkg/types/conversion/installconfig.go
InstallConfigVersion = "v1"
workerMachinePoolName = "worker"
InstallConfigVersion = "v1"
)

var (
Expand Down Expand Up @@ -361,14 +360,3 @@ type BootstrapInPlace struct {
// InstallationDisk is the target disk drive for coreos-installer
InstallationDisk string `json:"installationDisk"`
}

// WorkerMachinePool retrieves the worker MachinePool from InstallConfig.Compute
func (c *InstallConfig) WorkerMachinePool() *MachinePool {
for _, machinePool := range c.Compute {
if machinePool.Name == workerMachinePoolName {
return &machinePool
}
}

return nil
}
2 changes: 0 additions & 2 deletions pkg/types/machinepools.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const (
// MachinePool is a pool of machines to be installed.
type MachinePool struct {
// Name is the name of the machine pool.
// For the control plane machine pool, the name will always be "master".
// For the compute machine pools, the only valid name is "worker".
Name string `json:"name"`

// Replicas is the machine count for the machine pool.
Expand Down
10 changes: 0 additions & 10 deletions pkg/types/validation/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ import (
"github.com/openshift/installer/pkg/validate"
)

const (
masterPoolName = "master"
)

// list of known plugins that require hostPrefix to be set
var pluginsUsingHostPrefix = sets.NewString(string(operv1.NetworkTypeOpenShiftSDN), string(operv1.NetworkTypeOVNKubernetes))

Expand Down Expand Up @@ -386,9 +382,6 @@ func validateClusterNetwork(n *types.Networking, cn *types.ClusterNetworkEntry,

func validateControlPlane(platform *types.Platform, pool *types.MachinePool, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if pool.Name != masterPoolName {
allErrs = append(allErrs, field.NotSupported(fldPath.Child("name"), pool.Name, []string{masterPoolName}))
}
if pool.Replicas != nil && *pool.Replicas == 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("replicas"), pool.Replicas, "number of control plane replicas must be positive"))
}
Expand All @@ -401,9 +394,6 @@ func validateCompute(platform *types.Platform, control *types.MachinePool, pools
poolNames := map[string]bool{}
for i, p := range pools {
poolFldPath := fldPath.Index(i)
if p.Name != "worker" {
allErrs = append(allErrs, field.NotSupported(poolFldPath.Child("name"), p.Name, []string{"worker"}))
}
if poolNames[p.Name] {
allErrs = append(allErrs, field.Duplicate(poolFldPath.Child("name"), p.Name))
}
Expand Down

0 comments on commit d008e7d

Please sign in to comment.