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

Revert "operator: always delete terminated pending nodes (#2545)" #2596

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r *PendingNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request)

if done {
logr.Info("Reached goal", "pendingNodeGoal", pendingNode.Spec.Goal, "cspNodeState", nodeState)
if pendingNode.Spec.Goal == updatev1alpha1.NodeGoalLeave || nodeState == updatev1alpha1.NodeStateTerminated {
if pendingNode.Spec.Goal == updatev1alpha1.NodeGoalLeave {
// delete self after pending node has been terminated successfully
if err := r.deletePendingNode(ctx, req.NamespacedName); err != nil {
return ctrl.Result{}, err
Expand Down Expand Up @@ -213,17 +213,13 @@ func (r *PendingNodeReconciler) findObjectsForNode(ctx context.Context, rawNode
// - joining node: CSP reports the node instance as running and node has joined kubernetes cluster.
// - leaving node: CSP reports node instance as terminated.
func (r *PendingNodeReconciler) reachedGoal(ctx context.Context, pendingNode updatev1alpha1.PendingNode, nodeState updatev1alpha1.CSPNodeState) (bool, error) {
// Always return if the node is terminated so the resource can be cleaned up.
if nodeState == updatev1alpha1.NodeStateTerminated {
return true, nil
}
if pendingNode.Spec.Goal == updatev1alpha1.NodeGoalJoin {
if err := r.Get(ctx, types.NamespacedName{Name: pendingNode.Spec.NodeName}, &corev1.Node{}); err != nil {
return false, client.IgnoreNotFound(err)
}
return nodeState == updatev1alpha1.NodeStateReady, nil
}
return false, nil
return nodeState == updatev1alpha1.NodeStateTerminated, nil
}

// deletePendingNode deletes a PendingNode resource.
Expand Down