github.com/openshift/installer@v1.4.17/pkg/types/defaults/machinepools.go (about)

     1  package defaults
     2  
     3  import (
     4  	"github.com/openshift/installer/pkg/types"
     5  	"github.com/openshift/installer/pkg/version"
     6  )
     7  
     8  // SetMachinePoolDefaults sets the defaults for the machine pool.
     9  func SetMachinePoolDefaults(p *types.MachinePool, platform string) {
    10  	defaultReplicaCount := int64(3)
    11  	if p.Name == types.MachinePoolEdgeRoleName {
    12  		defaultReplicaCount = 0
    13  	}
    14  	if p.Replicas == nil {
    15  		p.Replicas = &defaultReplicaCount
    16  	}
    17  	if p.Hyperthreading == "" {
    18  		p.Hyperthreading = types.HyperthreadingEnabled
    19  	}
    20  	if p.Architecture == "" {
    21  		p.Architecture = version.DefaultArch()
    22  	}
    23  }
    24  
    25  // hasEdgePoolConfig checks if the Edge compute pool has been defined on install-config.
    26  func hasEdgePoolConfig(pools []types.MachinePool) bool {
    27  	edgePoolDefined := false
    28  	for _, compute := range pools {
    29  		if compute.Name == types.MachinePoolEdgeRoleName {
    30  			edgePoolDefined = true
    31  		}
    32  	}
    33  	return edgePoolDefined
    34  }
    35  
    36  // CreateEdgeMachinePoolDefaults create the edge compute pool when it is not already defined.
    37  func CreateEdgeMachinePoolDefaults(pools []types.MachinePool, platform string, replicas int64) *types.MachinePool {
    38  	if hasEdgePoolConfig(pools) {
    39  		return nil
    40  	}
    41  	pool := &types.MachinePool{
    42  		Name:     types.MachinePoolEdgeRoleName,
    43  		Replicas: &replicas,
    44  	}
    45  	SetMachinePoolDefaults(pool, platform)
    46  	return pool
    47  }