Skip to content

Commit 8013b2c

Browse files
author
Abhay Verma
committed
fixes aws#423: Not fetching pod list if dry-run is set to true
1 parent 1d1c126 commit 8013b2c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/node/node.go

+8
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,10 @@ func (n Node) fetchKubernetesNode(nodeName string) (*corev1.Node, error) {
496496
}
497497

498498
func (n Node) fetchAllPods(nodeName string) (*corev1.PodList, error) {
499+
if n.nthConfig.DryRun {
500+
log.Info().Msgf("Would have retrieved running pod list on node %s, but dry-run flag was set", nodeName)
501+
return &corev1.PodList{}, nil
502+
}
499503
return n.drainHelper.Client.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{
500504
FieldSelector: "spec.nodeName=" + nodeName,
501505
})
@@ -514,6 +518,10 @@ func getDrainHelper(nthConfig config.Config) (*drain.Helper, error) {
514518
ErrOut: log.Logger,
515519
}
516520

521+
if nthConfig.DryRun {
522+
return drainHelper, nil
523+
}
524+
517525
clusterConfig, err := rest.InClusterConfig()
518526
if err != nil {
519527
return nil, err

0 commit comments

Comments
 (0)