From 64f96df25fe24adc53a391183f6e50a6ed7d86fc Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Tue, 16 Jul 2019 16:19:25 -0400 Subject: [PATCH] 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. --- pkg/asset/manifests/scheduler.go | 26 +++++++++++++++++++++++++- pkg/types/validation/installconfig.go | 8 -------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/pkg/asset/manifests/scheduler.go b/pkg/asset/manifests/scheduler.go index c1559e4fd3b..af9d605dbae 100644 --- a/pkg/asset/manifests/scheduler.go +++ b/pkg/asset/manifests/scheduler.go @@ -5,9 +5,11 @@ import ( "github.com/ghodss/yaml" "github.com/pkg/errors" + "github.com/sirupsen/logrus" configv1 "github.com/openshift/api/config/v1" "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/installconfig" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -30,7 +32,9 @@ func (*Scheduler) Name() string { // Dependencies returns all of the dependencies directly needed to generate // the asset. func (*Scheduler) Dependencies() []asset.Asset { - return []asset.Asset{} + return []asset.Asset{ + &installconfig.InstallConfig{}, + } } // Generate generates the scheduler config and its CRD. @@ -49,6 +53,26 @@ func (s *Scheduler) Generate(dependencies asset.Parents) error { }, } + installConfig := &installconfig.InstallConfig{} + dependencies.Get(installConfig) + computeReplicas := int64(0) + for _, pool := range installConfig.Config.Compute { + if pool.Replicas != nil { + computeReplicas += *pool.Replicas + } + } + if computeReplicas == 0 { + // A schedulable host is required for a successful install to complete. + // If the install config has 0 replicas for compute hosts, it's one of two cases: + // 1. An IPI deployment with no compute hosts. The deployment can not succeed + // without MastersSchedulable = true. + // 2. A UPI deployment. The deployment may add compute hosts, but to ensure the + // the highest probability of a successful deployment, we default to + // schedulable masters. + logrus.Warningf("Making control-plane schedulable by setting MastersSchedulabe to true for Scheduler cluster settings") + config.Spec.MastersSchedulable = true + } + configData, err := yaml.Marshal(config) if err != nil { return errors.Wrapf(err, "failed to create %s manifests from InstallConfig", s.Name()) diff --git a/pkg/types/validation/installconfig.go b/pkg/types/validation/installconfig.go index 17e3e081be0..fee8a1cf421 100644 --- a/pkg/types/validation/installconfig.go +++ b/pkg/types/validation/installconfig.go @@ -8,7 +8,6 @@ import ( dockerref "github.com/containers/image/docker/reference" "github.com/pkg/errors" - "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/util/validation/field" "github.com/openshift/installer/pkg/types" @@ -183,7 +182,6 @@ func validateControlPlane(platform *types.Platform, pool *types.MachinePool, fld func validateCompute(platform *types.Platform, pools []types.MachinePool, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} poolNames := map[string]bool{} - foundPositiveReplicas := false for i, p := range pools { poolFldPath := fldPath.Index(i) if p.Name != "worker" { @@ -193,14 +191,8 @@ func validateCompute(platform *types.Platform, pools []types.MachinePool, fldPat allErrs = append(allErrs, field.Duplicate(poolFldPath.Child("name"), p.Name)) } poolNames[p.Name] = true - if p.Replicas != nil && *p.Replicas > 0 { - foundPositiveReplicas = true - } allErrs = append(allErrs, ValidateMachinePool(platform, &p, poolFldPath)...) } - if !foundPositiveReplicas { - logrus.Warnf("There are no compute nodes specified. The cluster will not fully initialize without compute nodes.") - } return allErrs }