Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast-forward devel to peer-pods-tech-preview #315

Merged
merged 3 commits into from
May 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 18 additions & 7 deletions controllers/openshift_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ func (r *KataConfigOpenShiftReconciler) processKataConfigDeleteRequest() (ctrl.R
r.Log.Info("Couldn't get node selector for unlabelling nodes", "err", err)
return ctrl.Result{Requeue: true}, nil
}
err = r.unlabelNodes(kataNodeSelector)
labelingChanged, err := r.unlabelNodes(kataNodeSelector)

if err != nil {
if k8serrors.IsConflict(err) {
Expand Down Expand Up @@ -895,13 +895,23 @@ func (r *KataConfigOpenShiftReconciler) processKataConfigDeleteRequest() (ctrl.R
r.Log.Error(err, "Error found deleting machine config. If the machine config exists after installation it can be safely deleted manually.",
"mc", mc.Name)
}
}

isConvergedCluster, _ := r.checkConvergedCluster()

// Conditions to detect whether we need to wait for the MCO to start
// reconciliation differ based on whether the cluster is converged.
// If so then it's the fact we've just deleted the extension MC, if not
// then it's the node-role labeling change (if there's none it means
// we're deleting a KataConfig on a cluster where no nodes matched the
// kataConfigPoolSelector and thus there will be no change for the MCO
// to reconciliate).
if (isConvergedCluster && !isMcDeleted) || (!isConvergedCluster && labelingChanged) {
r.Log.Info("Starting to wait for MCO to start reconciliation")
r.kataConfig.Status.WaitingForMcoToStart = true
r.kataConfig.Status.UnInstallationStatus.InProgress.IsInProgress = corev1.ConditionTrue
}

isConvergedCluster, _ := r.checkConvergedCluster()

// When nodes migrate from a source pool to a target pool the source
// pool is drained immediately and the nodes then slowly join the target
// pool. Thus the operation duration is dominated by the target pool
Expand Down Expand Up @@ -1621,15 +1631,15 @@ func (r *KataConfigOpenShiftReconciler) updateNodeLabels() (labelingChanged bool
return labelingChanged, nil
}

func (r *KataConfigOpenShiftReconciler) unlabelNodes(nodeSelector labels.Selector) (err error) {
func (r *KataConfigOpenShiftReconciler) unlabelNodes(nodeSelector labels.Selector) (labelingChanged bool, err error) {
nodeList := &corev1.NodeList{}
listOpts := []client.ListOption{
client.MatchingLabelsSelector{Selector: nodeSelector},
}

if err := r.Client.List(context.TODO(), nodeList, listOpts...); err != nil {
r.Log.Error(err, "Getting list of nodes failed")
return err
return false, err
}

for _, node := range nodeList.Items {
Expand All @@ -1638,11 +1648,12 @@ func (r *KataConfigOpenShiftReconciler) unlabelNodes(nodeSelector labels.Selecto
err = r.Client.Update(context.TODO(), &node)
if err != nil {
r.Log.Error(err, "Error when removing labels from node", "node", node)
return err
return labelingChanged, err
}
labelingChanged = true
}
}
return nil
return labelingChanged, nil
}

func (r *KataConfigOpenShiftReconciler) getConditionReason(conditions []mcfgv1.MachineConfigPoolCondition, conditionType mcfgv1.MachineConfigPoolConditionType) string {
Expand Down