From 83f7d6615303a4ffb3e31651561bea50fa96a6c0 Mon Sep 17 00:00:00 2001 From: Cyrill Troxler Date: Mon, 20 Nov 2023 09:08:09 +0100 Subject: [PATCH] fix: handle error when listing machines Signed-off-by: Cyrill Troxler --- .../cloudprovider/rancher/rancher_nodegroup.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cluster-autoscaler/cloudprovider/rancher/rancher_nodegroup.go b/cluster-autoscaler/cloudprovider/rancher/rancher_nodegroup.go index 8060c7930a19..5e0c27312532 100644 --- a/cluster-autoscaler/cloudprovider/rancher/rancher_nodegroup.go +++ b/cluster-autoscaler/cloudprovider/rancher/rancher_nodegroup.go @@ -344,9 +344,12 @@ func (ng *nodeGroup) listMachines() ([]unstructured.Unstructured, error) { LabelSelector: fmt.Sprintf("%s=%s-%s", machineDeploymentNameLabelKey, ng.provider.config.ClusterName, ng.name), }, ) + if err != nil { + return nil, fmt.Errorf("could not list machines: %w", err) + } ng.machines = machinesList.Items - return machinesList.Items, err + return machinesList.Items, nil } func (ng *nodeGroup) machineByName(name string) (*unstructured.Unstructured, error) {