Skip to content

Commit 64f96df

Browse files
committed
scheduler: Use schedulable masters if no compute hosts defined.
This change makes use of a new configuration item on the scheduler CR that specifies that control plane hosts should be able to run workloads. This option is off by default, but will now be turned on if there are no compute machine pools with non-zero replicas defined. This change also removes a validation and warning when no compute hosts are defined, as an install with this configuration will now complete successfully.
1 parent 1392583 commit 64f96df

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

pkg/asset/manifests/scheduler.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import (
55

66
"github.com/ghodss/yaml"
77
"github.com/pkg/errors"
8+
"github.com/sirupsen/logrus"
89

910
configv1 "github.com/openshift/api/config/v1"
1011
"github.com/openshift/installer/pkg/asset"
12+
"github.com/openshift/installer/pkg/asset/installconfig"
1113
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1214
)
1315

@@ -30,7 +32,9 @@ func (*Scheduler) Name() string {
3032
// Dependencies returns all of the dependencies directly needed to generate
3133
// the asset.
3234
func (*Scheduler) Dependencies() []asset.Asset {
33-
return []asset.Asset{}
35+
return []asset.Asset{
36+
&installconfig.InstallConfig{},
37+
}
3438
}
3539

3640
// Generate generates the scheduler config and its CRD.
@@ -49,6 +53,26 @@ func (s *Scheduler) Generate(dependencies asset.Parents) error {
4953
},
5054
}
5155

56+
installConfig := &installconfig.InstallConfig{}
57+
dependencies.Get(installConfig)
58+
computeReplicas := int64(0)
59+
for _, pool := range installConfig.Config.Compute {
60+
if pool.Replicas != nil {
61+
computeReplicas += *pool.Replicas
62+
}
63+
}
64+
if computeReplicas == 0 {
65+
// A schedulable host is required for a successful install to complete.
66+
// If the install config has 0 replicas for compute hosts, it's one of two cases:
67+
// 1. An IPI deployment with no compute hosts. The deployment can not succeed
68+
// without MastersSchedulable = true.
69+
// 2. A UPI deployment. The deployment may add compute hosts, but to ensure the
70+
// the highest probability of a successful deployment, we default to
71+
// schedulable masters.
72+
logrus.Warningf("Making control-plane schedulable by setting MastersSchedulabe to true for Scheduler cluster settings")
73+
config.Spec.MastersSchedulable = true
74+
}
75+
5276
configData, err := yaml.Marshal(config)
5377
if err != nil {
5478
return errors.Wrapf(err, "failed to create %s manifests from InstallConfig", s.Name())

pkg/types/validation/installconfig.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
dockerref "github.com/containers/image/docker/reference"
1010
"github.com/pkg/errors"
11-
"github.com/sirupsen/logrus"
1211
"k8s.io/apimachinery/pkg/util/validation/field"
1312

1413
"github.com/openshift/installer/pkg/types"
@@ -183,7 +182,6 @@ func validateControlPlane(platform *types.Platform, pool *types.MachinePool, fld
183182
func validateCompute(platform *types.Platform, pools []types.MachinePool, fldPath *field.Path) field.ErrorList {
184183
allErrs := field.ErrorList{}
185184
poolNames := map[string]bool{}
186-
foundPositiveReplicas := false
187185
for i, p := range pools {
188186
poolFldPath := fldPath.Index(i)
189187
if p.Name != "worker" {
@@ -193,14 +191,8 @@ func validateCompute(platform *types.Platform, pools []types.MachinePool, fldPat
193191
allErrs = append(allErrs, field.Duplicate(poolFldPath.Child("name"), p.Name))
194192
}
195193
poolNames[p.Name] = true
196-
if p.Replicas != nil && *p.Replicas > 0 {
197-
foundPositiveReplicas = true
198-
}
199194
allErrs = append(allErrs, ValidateMachinePool(platform, &p, poolFldPath)...)
200195
}
201-
if !foundPositiveReplicas {
202-
logrus.Warnf("There are no compute nodes specified. The cluster will not fully initialize without compute nodes.")
203-
}
204196
return allErrs
205197
}
206198

0 commit comments

Comments
 (0)