From 60a602f17014cf52c0556668858a4c8222a1ebd5 Mon Sep 17 00:00:00 2001 From: Mat Kowalski Date: Thu, 26 Oct 2023 11:33:33 +0200 Subject: [PATCH] gce: fix test for non-existing instance in cloud This commit fixes a GCE instance test for a scenario where instance does not exist in the cloud. In the `gce_instances.go` we have a code that handles such a scenario and strips off the error, i.e. ``` if providerID, err = cloudprovider.GetInstanceProviderID(ctx, g, types.NodeName(node.Name)); err != nil { if err == cloudprovider.InstanceNotFound { return false, nil } return false, err } ``` but nevertheless the test was expecing a non-empty error string. This issue got exposed when implementation of `GetInstanceProviderID` in the `cloud-provider/cloud.go` changed to return `InstanceNotFound` as-is and not as a custom string. Signed-off-by: Mat Kowalski --- .../k8s.io/legacy-cloud-providers/gce/gce_instances_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_instances_test.go b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_instances_test.go index 91a1c3ad024..4496f232800 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_instances_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_instances_test.go @@ -21,7 +21,6 @@ package gce import ( "context" - "fmt" "testing" "github.com/stretchr/testify/assert" @@ -55,7 +54,7 @@ func TestInstanceExists(t *testing.T) { name: "node not exist", nodeName: "test-node-2", exist: false, - expectedErr: fmt.Errorf("failed to get instance ID from cloud provider: instance not found"), + expectedErr: nil, }, }