Skip to content

Commit

Permalink
This PR ensures that the installer prints out a message and exits wit…
Browse files Browse the repository at this point in the history
…h an error message if the number of worker replicas doesn't match the replicas requested in the install config.

The error is non-fatal and the cluster will be operational except for a message that prints the inconsistency between requested worker replicas and what was available after the installation.
  • Loading branch information
kirankt committed Sep 14, 2020
1 parent 8fea4de commit 1258aae
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions cmd/openshift-install/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,44 @@ func waitForConsole(ctx context.Context, config *rest.Config) (string, error) {
return url, nil
}

// checkComputeReplicas checks the number of requested replicas of worker nodes
func checkComputeReplicas(config *rest.Config, directory string) (err error) {
client, err := kubernetes.NewForConfig(config)
if err != nil {
return errors.Wrap(err, "creating a Kubernetes client")
}

nodes, err := client.CoreV1().Nodes().List(metav1.ListOptions{})
if err != nil {
return errors.Wrap(err, "failed to get node list")
}

assetStore, err := assetstore.NewStore(directory)
if err != nil {
return errors.Wrap(err, "failed to create asset store")
}

ic := &installconfig.InstallConfig{}
if err := assetStore.Fetch(ic); err != nil {
return errors.Wrapf(err, "failed to fetch %s", ic.Name())
}

var computeReplicas, controlPlaneReplicas int64
if ic.Config.Platform.Name() == baremetal.Name {
for _, compute := range ic.Config.Compute {
computeReplicas += *compute.Replicas
}
controlPlaneReplicas += *ic.Config.ControlPlane.Replicas

foundReplicas := int64(len(nodes.Items)) - controlPlaneReplicas
if foundReplicas != computeReplicas {
err := errors.New("incorrect number of compute replicas found")
return errors.Wrapf(err, "specified %d compute replicas but found %d", computeReplicas, foundReplicas)
}
}
return nil
}

// logComplete prints info upon completion
func logComplete(directory, consoleURL string) error {
absDir, err := filepath.Abs(directory)
Expand All @@ -489,6 +527,7 @@ func logComplete(directory, consoleURL string) error {
logrus.Infof("To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=%s'", kubeconfig)
logrus.Infof("Access the OpenShift web-console here: %s", consoleURL)
logrus.Infof("Login to the console with user: %q, and password: %q", "kubeadmin", pw)

return nil
}

Expand All @@ -506,5 +545,9 @@ func waitForInstallComplete(ctx context.Context, config *rest.Config, directory
return err
}

if err = checkComputeReplicas(config, rootOpts.dir); err != nil {
logrus.Warnf("Warning: incorrect number of compute replicas found. Some workers may still be provisioning, please check their status: %s", err)
}

return logComplete(rootOpts.dir, consoleURL)
}

0 comments on commit 1258aae

Please sign in to comment.