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

WIP: Hot node patch #4277

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions internal/kubeutils.go
Expand Up @@ -12,6 +12,7 @@ import (
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
corev1lister "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/util/retry"
"k8s.io/klog/v2"
)

// UpdateNodeRetry calls f to update a node object in Kubernetes.
Expand Down Expand Up @@ -44,6 +45,7 @@ func UpdateNodeRetry(client corev1client.NodeInterface, lister corev1lister.Node
return fmt.Errorf("failed to create patch for node %q: %w", nodeName, err)
}

klog.Infof("UpdateNodeRetry patch %s: %s", nodeName, string(patchBytes))
node, err = client.Patch(context.TODO(), nodeName, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{})
return err
}); err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/drain/drain_controller.go
Expand Up @@ -516,6 +516,7 @@ func (ctrl *Controller) setNodeAnnotations(nodeName string, annotations map[stri
return fmt.Errorf("node %s: failed to create patch for: %v", nodeName, err)
}

klog.Infof("setNodeAnnotations patch %s: %s", nodeName, string(patchBytes))
_, err = ctrl.kubeClient.CoreV1().Nodes().Patch(context.TODO(), nodeName, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{})
return err
}); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/node/node_controller.go
Expand Up @@ -307,6 +307,7 @@ func (ctrl *Controller) makeMastersUnSchedulable(currentMasters []*corev1.Node)
// makeMasterNodeUnSchedulable makes master node unschedulable by removing worker label and adding `NoSchedule`
// master taint to the master node
func (ctrl *Controller) makeMasterNodeUnSchedulable(node *corev1.Node) error {
klog.Infof("makeMasterNodeUnSchedulable %s", node.Name)
_, err := internal.UpdateNodeRetry(ctrl.kubeClient.CoreV1().Nodes(), ctrl.nodeLister, node.Name, func(node *corev1.Node) {
// Remove worker label
newLabels := node.Labels
Expand Down Expand Up @@ -337,6 +338,7 @@ func (ctrl *Controller) makeMasterNodeUnSchedulable(node *corev1.Node) error {
// makeMasterNodeSchedulable makes master node schedulable by removing NoSchedule master taint and
// adding worker label
func (ctrl *Controller) makeMasterNodeSchedulable(node *corev1.Node) error {
klog.Infof("makeMasterNodeSchedulable %s", node.Name)
_, err := internal.UpdateNodeRetry(ctrl.kubeClient.CoreV1().Nodes(), ctrl.nodeLister, node.Name, func(node *corev1.Node) {
// Add worker label
newLabels := node.Labels
Expand Down Expand Up @@ -1024,6 +1026,7 @@ func (ctrl *Controller) updateCandidateNode(nodeName string, pool *mcfgv1.Machin
if err != nil {
return fmt.Errorf("failed to create patch for node %q: %w", nodeName, err)
}
klog.Infof("updateCandidateNode patch %s: %s", nodeName, string(patchBytes))
_, err = ctrl.kubeClient.CoreV1().Nodes().Patch(context.TODO(), nodeName, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{})
return err
})
Expand Down Expand Up @@ -1214,6 +1217,7 @@ func (ctrl *Controller) setUpdateInProgressTaint(ctx context.Context, nodeName s
if err != nil {
return fmt.Errorf("failed to create patch for node %q: %v", nodeName, err)
}
klog.Infof("setUpdateInProgressTaint patch %s: %s", nodeName, string(patchBytes))
_, err = ctrl.kubeClient.CoreV1().Nodes().Patch(ctx, nodeName, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{})
return err
})
Expand Down Expand Up @@ -1253,6 +1257,7 @@ func (ctrl *Controller) removeUpdateInProgressTaint(ctx context.Context, nodeNam
if err != nil {
return fmt.Errorf("failed to create patch for node %q: %w", nodeName, err)
}
klog.Infof("setUpdateInProgressTaint patch %s: %s", nodeName, string(patchBytes))
_, err = ctrl.kubeClient.CoreV1().Nodes().Patch(ctx, nodeName, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{})
return err
})
Expand Down
Expand Up @@ -26,7 +26,6 @@ contents:
staticPodPath: /etc/kubernetes/manifests
systemCgroups: /system.slice
nodeStatusUpdateFrequency: 10s
nodeStatusReportFrequency: 5m
featureGates:
AlibabaPlatform: true
AzureWorkloadIdentity: true
Expand Down
Expand Up @@ -26,7 +26,6 @@ contents:
staticPodPath: /etc/kubernetes/manifests
systemCgroups: /system.slice
nodeStatusUpdateFrequency: 10s
nodeStatusReportFrequency: 5m
featureGates:
AlibabaPlatform: true
AzureWorkloadIdentity: true
Expand Down