Skip to content

Commit

Permalink
Implement option to disable node taints
Browse files Browse the repository at this point in the history
  • Loading branch information
js185692 committed Dec 17, 2024
1 parent 22131dc commit 2b46385
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewAgentCommand() *cobra.Command {
var drbdStatusInterval, reconcileInterval, resyncInterval, operationsTimeout, failOverTimeout time.Duration
var deletionGraceSeconds int64
var nodeName, healthzBindAddress, satellitePodLabel string
var failOverUnsafePods bool
var failOverUnsafePods, disableNodeTaints bool

cmd := &cobra.Command{
Use: "node-agent",
Expand Down Expand Up @@ -52,6 +52,7 @@ func NewAgentCommand() *cobra.Command {
NodeName: nodeName,
FailOverUnsafePods: failOverUnsafePods,
SatellitePodSelector: selector,
DisableNodeTaints: disableNodeTaints,
})
if err != nil {
return err
Expand Down Expand Up @@ -90,6 +91,7 @@ func NewAgentCommand() *cobra.Command {
cmd.Flags().StringVar(&healthzBindAddress, "health-bind-address", ":8000", "the address to bind to for the /healthz endpoint")
cmd.Flags().StringVar(&satellitePodLabel, "satellite-pod-label", "app.kubernetes.io/component=linstor-satellite", "the connection name reported by DRBD is one of the Pods with this label")
cmd.Flags().BoolVar(&failOverUnsafePods, "fail-over-unsafe-pods", false, "fail over Pods that use storage with unknown fail over properties")
cmd.Flags().BoolVar(&disableNodeTaints, "disable-node-taints", false, "prevent nodes from being tainted")
return cmd
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type Options struct {
// SatellitePodSelector selects the Pods that should be considered LINSTOR Satellites.
// If the DRBD connection name matches on of these Pods, the Kubernetes Node name is taken from these Pods.
SatellitePodSelector labels.Selector
// DisableNodeTaints prevents the nodes in a cluster from being tainted.
DisableNodeTaints bool
}

// Timeout returns the operations timeout.
Expand Down Expand Up @@ -567,8 +569,8 @@ func hasPersistentVolumeClaimRef(pv *corev1.PersistentVolume) bool {
// TaintNode adds the specific taint to the node.
//
// Returns false, nil if the taint was already present.
func TaintNode(ctx context.Context, client kubernetes.Interface, node *corev1.Node, taint corev1.Taint) (bool, error) {
if node == nil {
func TaintNode(ctx context.Context, client kubernetes.Interface, node *corev1.Node, taint corev1.Taint, disableNodeTaints bool) (bool, error) {
if disableNodeTaints || node == nil {
return false, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/reconcile_failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (f *failoverReconciler) evictPods(ctx context.Context, res *DrbdResourceSta
Key: metadata.NodeLostQuorumTaint,
Effect: corev1.TaintEffectNoSchedule,
TimeAdded: &taintTime,
})
}, f.opt.DisableNodeTaints)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/reconcile_force_io_error_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (f *forceIoErrorReconciler) RunForResource(ctx context.Context, req *Reconc
Key: metadata.NodeForceIoErrorTaint,
Effect: corev1.TaintEffectNoSchedule,
TimeAdded: &taintTime,
})
}, f.opt.DisableNodeTaints)
if err != nil {
return err
}
Expand Down

0 comments on commit 2b46385

Please sign in to comment.