From 1058228e0670be55c98d1b76d2b76d7996621651 Mon Sep 17 00:00:00 2001 From: Jesse Nelson Date: Thu, 2 Nov 2023 08:50:35 -0500 Subject: [PATCH] check for error first Signed-off-by: Jesse Nelson --- pkg/mgmt/zfsnode/start.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/mgmt/zfsnode/start.go b/pkg/mgmt/zfsnode/start.go index 8fb164bf4..20cf6bdad 100644 --- a/pkg/mgmt/zfsnode/start.go +++ b/pkg/mgmt/zfsnode/start.go @@ -90,12 +90,12 @@ func Start(controllerMtx *sync.RWMutex, stopCh <-chan struct{}) error { k8sNodeCandidate, err := kubeClient.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{ LabelSelector: topologySelector, }) - if k8sNodeCandidate == nil || len(k8sNodeCandidate.Items) != 1 { - return fmt.Errorf("unable to retrieve a single node by %s for %s", zfs.ZFSTopologyKey, zfs.NodeID) - } if err != nil { return errors.Wrapf(err, "error trying to find node with label %s having value %s", zfs.ZFSTopologyKey, zfs.NodeID) } + if k8sNodeCandidate == nil || len(k8sNodeCandidate.Items) != 1 { + return fmt.Errorf("unable to retrieve a single node by %s for %s", zfs.ZFSTopologyKey, zfs.NodeID) + } k8sNode = k8sNodeCandidate.Items[0] }