From 384ba0fe1b6449efe616041f57664f61f63bbd28 Mon Sep 17 00:00:00 2001 From: maelk Date: Tue, 7 Jul 2020 08:28:14 +0300 Subject: [PATCH] Update Baremetal Operator for the new unmanaged state --- baremetal/metal3machine_manager.go | 3 ++- baremetal/metal3machine_manager_test.go | 17 +++++++++++++---- go.mod | 2 +- go.sum | 2 ++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/baremetal/metal3machine_manager.go b/baremetal/metal3machine_manager.go index 975f0d76ab..7524f564e6 100644 --- a/baremetal/metal3machine_manager.go +++ b/baremetal/metal3machine_manager.go @@ -517,7 +517,8 @@ func (m *MachineManager) Delete(ctx context.Context) error { switch host.Status.Provisioning.State { case bmh.StateRegistrationError, bmh.StateRegistering, bmh.StateMatchProfile, bmh.StateInspecting, - bmh.StateReady, bmh.StateAvailable, bmh.StateNone: + bmh.StateReady, bmh.StateAvailable, bmh.StateNone, + bmh.StateUnmanaged: // Host is not provisioned waiting = false case bmh.StateExternallyProvisioned: diff --git a/baremetal/metal3machine_manager_test.go b/baremetal/metal3machine_manager_test.go index dee3ad97a2..5b2cfdb3c7 100644 --- a/baremetal/metal3machine_manager_test.go +++ b/baremetal/metal3machine_manager_test.go @@ -1282,10 +1282,8 @@ var _ = Describe("Metal3Machine manager", func() { } host := bmh.BareMetalHost{} - if tc.Host != nil { - err := c.Get(context.TODO(), key, &host) - Expect(err).NotTo(HaveOccurred()) - } + err := c.Get(context.TODO(), key, &host) + Expect(err).NotTo(HaveOccurred()) name := "" expectedName := "" @@ -1398,6 +1396,17 @@ var _ = Describe("Metal3Machine manager", func() { ExpectedResult: &RequeueAfterError{RequeueAfter: time.Second * 30}, Secret: newSecret(), }), + Entry("Unmanaged host should not be waited on", testCaseDelete{ + Host: newBareMetalHost("myhost", bmhSpecNoImg(), + bmh.StateUnmanaged, bmhPowerStatus(), true, false, + ), + Machine: newMachine("mymachine", "", nil), + BMMachine: newMetal3Machine("mybmmachine", nil, bmmSecret(), nil, + bmmObjectMetaWithValidAnnotations(), + ), + ExpectSecretDeleted: true, + Secret: newSecret(), + }), Entry("Consumer ref should be removed from externally provisioned host", testCaseDelete{ Host: newBareMetalHost("myhost", bmhSpecNoImg(), diff --git a/go.mod b/go.mod index c4b0a2d0d9..622f542628 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/mailru/easyjson v0.7.1 // indirect github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect github.com/mdempsky/maligned v0.0.0-20180708014732-6e39bd26a8c8 // indirect - github.com/metal3-io/baremetal-operator v0.0.0-20200617072321-b35c5e9bceba + github.com/metal3-io/baremetal-operator v0.0.0-20200707051855-4d4d033a8059 github.com/onsi/ginkgo v1.12.0 github.com/onsi/gomega v1.9.0 github.com/openshift/api v3.9.1-0.20190924102528-32369d4db2ad+incompatible // indirect diff --git a/go.sum b/go.sum index c3b38700d1..65318eba7f 100644 --- a/go.sum +++ b/go.sum @@ -771,6 +771,8 @@ github.com/metal3-io/baremetal-operator v0.0.0-20200318114549-c3da1db56f43/go.mo github.com/metal3-io/baremetal-operator v0.0.0-20200402123356-c863ac5a6630 h1:n/FW9YW7qY8/J0YSq/SnXJ6RuLV4Jb3YHeZWQBJdYp8= github.com/metal3-io/baremetal-operator v0.0.0-20200617072321-b35c5e9bceba h1:1vQVRm3NqHu6vH9KT44oilN0YNtchlR/lROPGp+ACQY= github.com/metal3-io/baremetal-operator v0.0.0-20200617072321-b35c5e9bceba/go.mod h1:DOgBIuBcXuTD8uub0jL7h6gBdIBt3CFrwz6K2FtfMBA= +github.com/metal3-io/baremetal-operator v0.0.0-20200707051855-4d4d033a8059 h1:Ek7eFJ4t3TS3aosP/FHGhQX9DEm2Z53tnNnHwE/A2Kc= +github.com/metal3-io/baremetal-operator v0.0.0-20200707051855-4d4d033a8059/go.mod h1:DOgBIuBcXuTD8uub0jL7h6gBdIBt3CFrwz6K2FtfMBA= github.com/mholt/certmagic v0.6.2-0.20190624175158-6a42ef9fe8c2/go.mod h1:g4cOPxcjV0oFq3qwpjSA30LReKD8AoIfwAY9VvG35NY= github.com/miekg/dns v0.0.0-20181005163659-0d29b283ac0f/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=