From 4f32a55d19e00b3d3eb0ce441889627bcd71a68c Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Thu, 19 Oct 2023 10:52:02 +0530 Subject: [PATCH] Do not put machine in failed state if VM is is topping or stopped state, and use ID from instance during deletion --- cloud/scope/machine_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cloud/scope/machine_test.go b/cloud/scope/machine_test.go index 5a7770a5..7fe3a80b 100644 --- a/cloud/scope/machine_test.go +++ b/cloud/scope/machine_test.go @@ -2393,6 +2393,7 @@ func TestInstanceDeletion(t *testing.T) { expectedEvent string eventNotExpected string matchError error + instance *core.Instance errorSubStringMatch bool testSpecificSetup func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) }{ @@ -2406,6 +2407,9 @@ func TestInstanceDeletion(t *testing.T) { PreserveBootVolume: common.Bool(false), })).Return(core.TerminateInstanceResponse{}, nil) }, + instance: &core.Instance{ + Id: common.String("test"), + }, }, { name: "delete instance error", @@ -2418,6 +2422,9 @@ func TestInstanceDeletion(t *testing.T) { PreserveBootVolume: common.Bool(false), })).Return(core.TerminateInstanceResponse{}, errors.New("could not terminate instance")) }, + instance: &core.Instance{ + Id: common.String("test"), + }, }, } @@ -2427,7 +2434,7 @@ func TestInstanceDeletion(t *testing.T) { defer teardown(t, g) setup(t, g) tc.testSpecificSetup(ms, computeClient) - err := ms.DeleteMachine(context.Background()) + err := ms.DeleteMachine(context.Background(), tc.instance) if tc.errorExpected { g.Expect(err).To(Not(BeNil())) if tc.errorSubStringMatch {