Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Use ironic inventory API instead of calling ironic-inspector #1355

Merged
merged 6 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions cmd/get-hardware-details/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ package main
import (
"encoding/json"
"fmt"
"net"
"net/url"
"os"
"strings"

"github.com/gophercloud/gophercloud/openstack/baremetalintrospection/v1/introspection"
"github.com/gophercloud/gophercloud/openstack/baremetal/v1/nodes"
"k8s.io/klog/v2"

"github.com/metal3-io/baremetal-operator/pkg/provisioner/ironic/clients"
"github.com/metal3-io/baremetal-operator/pkg/provisioner/ironic/hardwaredetails"
Expand All @@ -34,22 +37,38 @@ func main() {
InsecureSkipVerify: ironicInsecure,
}

inspector, err := clients.InspectorClient(opts.Endpoint, opts.AuthConfig, tlsConf)
endpoint := opts.Endpoint
parsedEndpoint, err := url.Parse(endpoint)
if err != nil {
fmt.Printf("could not get inspector client: %s", err)
fmt.Printf("invalid ironic endpoint: %s", err)
os.Exit(1)
}

introData := introspection.GetIntrospectionData(inspector, opts.NodeID)
// Previously, this command accepted the Inspector endpoint. But since
// we're transitioning to not using Inspector directly, it now requires
// the Ironic endpoint. Try to handle the transition by checking for
// the well-known Inspector port and replacing it with the Ironic port.
if parsedEndpoint.Port() == "5050" {
dtantsur marked this conversation as resolved.
Show resolved Hide resolved
parsedEndpoint.Host = net.JoinHostPort(parsedEndpoint.Hostname(), "6385")
endpoint = parsedEndpoint.String()
}

ironic, err := clients.IronicClient(endpoint, opts.AuthConfig, tlsConf)
if err != nil {
fmt.Printf("could not get ironic client: %s", err)
os.Exit(1)
}

introData := nodes.GetInventory(ironic, opts.NodeID)
data, err := introData.Extract()
if err != nil {
fmt.Printf("could not get introspection data: %s", err)
fmt.Printf("could not get inspection data: %s", err)
os.Exit(1)
}

json, err := json.MarshalIndent(hardwaredetails.GetHardwareDetails(data), "", "\t")
json, err := json.MarshalIndent(hardwaredetails.GetHardwareDetails(data, klog.NewKlogr()), "", "\t")
if err != nil {
fmt.Printf("could not convert introspection data: %s", err)
fmt.Printf("could not convert inspection data: %s", err)
os.Exit(1)
}

Expand All @@ -58,7 +77,7 @@ func main() {

func getOptions() (o options) {
if len(os.Args) != 3 {
fmt.Println("Usage: get-hardware-details <inspector URI> <node UUID>")
fmt.Println("Usage: get-hardware-details <ironic URI> <node UUID>")
dtantsur marked this conversation as resolved.
Show resolved Hide resolved
os.Exit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ When an external Ironic is used, the following requirements must be met:
* Either HTTP basic or no-auth authentication must be used (Keystone is not
supported).

* API version 1.74 (Xena release cycle) or newer must be available.
* API version 1.81 (2023.1 "Antelope" release cycle) or newer must be available.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/go-logr/logr v1.2.4
github.com/google/safetext v0.0.0-20230106111101-7156a760e523
github.com/gophercloud/gophercloud v1.6.0
github.com/gophercloud/gophercloud v1.5.1-0.20230912084133-c79ed6d3b371
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit uncomfortable with this. Is the goal to merge it with the development commit or wait for gophercloud v2 to be released?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V2 may take more time to get releases. What's the cause of your discomfort? For better or worse, using git commits is a normal thing in the Go world. The last time I tried to hurry gophercloud folks about a release they went "wtf, just use a git hash".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be landing in v2 only? Do you have any guess when would that be? AFAIK when we need to test commits that has landed in dev branches but not ready for release yet, we use pseudo-versions with git hashes. Use of pseudo version signals module is still under development and not stable. But since go has now stricter rules now to generate pseudo-numbers, it can be used incase we cannot wait for proper release to exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is going to v2 only because this work involved breaking changes. I don't know when that happens, we can ask on slack.

I think I'm using what you're describing here. Since the last release before splitting the 1.* branch was 1.5.0, it assumes the new version will 1.5.1-something (which is wrong, but go tell go!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the cause of your discomfort?

I'm mainly worried about the upgrade path and the potential for API changes that would impact us. It is probably not an issue but I would not want to just skip over it without thinking it through. So how do we expect the upgrade will look like?

We start with a scenario where a user is running an older version of BMO/Ironic relying on the older API and gophercloud. What would be required to upgrade? My understanding is something like this:

  1. Upgrade Ironic to a version that supports microversion 1.81. (Is something else needed here to "refresh" the inventory, I guess not?)
  2. Upgrade BMO.

This seems easy enough, but definitely worth a mention in the release notes for BMO.

Now my worry is that there would be some migration steps needed to go from gophercloud v1 to v2 and we end up somewhere in the middle. Do you see any situation where some kind of patch would be needed to support the bump to v2? (I know of projects where bugs have made it impossible to upgrade from e.g. 0.3.1 to 0.4.0. Instead users were required to first upgrade to the latest patch release, e.g. 0.3.4 and from there on to 0.4.0.) For example, could there be a required upgrade path for gophercloud to do v1.7.1 -> v2.0.0 and we miss it because we do not have the v1.7.1 patch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you seem to be conflating the Ironic upgrade and the Gophercloud upgrade.

Gophercloud is just an HTTP library. 2.0.0 will see some Go API changes, but these are easy to address on any bump. For better or worse, Go does not update anything automatically (we will need to keep an eye on dependabot, of course). This is why I'm not sure what you mean by "we don't have the v1.7.1 patch". Gophercloud has no local state.

Ironic upgrade is a bit different. Historically, we have taken bumping microversions very lightly. Now Steven has raised a valid point that some of our consumers may not always use the latest-and-greatest versions. Fair. We need to start having some sort of upgrade docs per release (which I assume don't exist now).

In any case, what are the suggested action items here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation, that makes sense!
It seems like there is not much reason to worry. We just need to document the Ironic version bump so users notice it.
Perhaps we can bring this up at the community meeting today also to make sure developers are aware of it, in case there are any concerns?

github.com/metal3-io/baremetal-operator/apis v0.2.0
github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.2.0
github.com/onsi/gomega v1.27.10
Expand Down Expand Up @@ -62,7 +62,7 @@ require (
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
Expand Down
13 changes: 4 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ github.com/google/safetext v0.0.0-20230106111101-7156a760e523 h1:i4NsbmB9pD5+Ggp
github.com/google/safetext v0.0.0-20230106111101-7156a760e523/go.mod h1:mJNEy0r5YPHC7ChQffpOszlGB4L1iqjXWpIEKcFpr9s=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gophercloud/gophercloud v1.6.0 h1:JwJN1bauRnWPba5ueWs9IluONHteXPWjjK+MvfM4krY=
github.com/gophercloud/gophercloud v1.6.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM=
github.com/gophercloud/gophercloud v1.5.1-0.20230912084133-c79ed6d3b371 h1:/4TDrmUM3o52/9J3Pn4mZ3VP7CYiFkDKRNuWyxLkpp4=
github.com/gophercloud/gophercloud v1.5.1-0.20230912084133-c79ed6d3b371/go.mod h1:vYRGjRkTeMAwdvQFTVuPGfRWv4dc3J2QHy9H3bHD6Pc=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
Expand Down Expand Up @@ -156,7 +156,6 @@ go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
Expand All @@ -177,7 +176,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand All @@ -196,19 +194,16 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
Expand Down
11 changes: 1 addition & 10 deletions pkg/provisioner/ironic/adopt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

"github.com/gophercloud/gophercloud/openstack/baremetal/v1/nodes"
"github.com/gophercloud/gophercloud/openstack/baremetalintrospection/v1/introspection"
"github.com/stretchr/testify/assert"

"github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc"
Expand Down Expand Up @@ -128,19 +127,11 @@ func TestAdopt(t *testing.T) {
defer tc.ironic.Stop()
}

inspector := testserver.NewInspector(t).Ready().WithIntrospection(nodeUUID, introspection.Introspection{
Finished: false,
})
inspector.Start()
defer inspector.Stop()

host := makeHost()
host.Status.Provisioning.ID = nodeUUID
publisher := func(reason, message string) {}
auth := clients.AuthConfig{Type: clients.NoAuth}
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, publisher,
tc.ironic.Endpoint(), auth, inspector.Endpoint(), auth,
)
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, publisher, tc.ironic.Endpoint(), auth)
if err != nil {
t.Fatalf("could not create provisioner: %s", err)
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/provisioner/ironic/bios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,13 @@ func TestGetFirmwareSettings(t *testing.T) {
tc.ironic.Start()
defer tc.ironic.Stop()

inspector := testserver.NewInspector(t).Start()
defer inspector.Stop()

host := makeHost()
host.Name = "node-1"
host.Status.Provisioning.ID = nodeUUID

auth := clients.AuthConfig{Type: clients.NoAuth}

prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, nullEventPublisher,
tc.ironic.Endpoint(), auth, inspector.Endpoint(), auth,
)
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, nullEventPublisher, tc.ironic.Endpoint(), auth)
if err != nil {
t.Fatalf("could not create provisioner: %s", err)
}
Expand Down
15 changes: 3 additions & 12 deletions pkg/provisioner/ironic/clients/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ func readAuthFile(filename string) (string, error) {
return strings.TrimSpace(string(content)), err
}

func load(clientType string) (auth AuthConfig, err error) {
authPath := path.Join(authRoot(), clientType)
// LoadAuth loads the Ironic configuration from the environment
func LoadAuth() (auth AuthConfig, err error) {
authPath := path.Join(authRoot(), "ironic")

if _, err := os.Stat(authPath); err != nil {
if os.IsNotExist(err) {
Expand Down Expand Up @@ -69,16 +70,6 @@ func load(clientType string) (auth AuthConfig, err error) {
return
}

// LoadAuth loads the Ironic and Inspector configuration from the environment
func LoadAuth() (ironicAuth, inspectorAuth AuthConfig, err error) {
ironicAuth, err = load("ironic")
if err != nil {
return
}
inspectorAuth, err = load("ironic-inspector")
return
}

// ConfigFromEndpointURL returns an endpoint and an auth config from an
// endpoint URL that may contain HTTP basic auth credentials.
func ConfigFromEndpointURL(endpointURL string) (endpoint string, auth AuthConfig, err error) {
Expand Down
29 changes: 2 additions & 27 deletions pkg/provisioner/ironic/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/baremetal/httpbasic"
"github.com/gophercloud/gophercloud/openstack/baremetal/noauth"
httpbasicintrospection "github.com/gophercloud/gophercloud/openstack/baremetalintrospection/httpbasic"
noauthintrospection "github.com/gophercloud/gophercloud/openstack/baremetalintrospection/noauth"
"go.etcd.io/etcd/client/pkg/v3/transport"
)

Expand Down Expand Up @@ -95,31 +93,8 @@ func IronicClient(ironicEndpoint string, auth AuthConfig, tls TLSConfig) (client

// Ensure we have a microversion high enough to get the features
// we need. Update docs/configuration.md when updating the version.
// Version 1.74 allows retrival of the BIOS Registry
client.Microversion = "1.74"
// Version 1.81 allows retrival of Node inventory
client.Microversion = "1.81"
dtantsur marked this conversation as resolved.
Show resolved Hide resolved

return updateHTTPClient(client, tls)
}

// InspectorClient creates a client for Ironic Inspector
func InspectorClient(inspectorEndpoint string, auth AuthConfig, tls TLSConfig) (client *gophercloud.ServiceClient, err error) {
switch auth.Type {
case NoAuth:
client, err = noauthintrospection.NewBareMetalIntrospectionNoAuth(
noauthintrospection.EndpointOpts{
IronicInspectorEndpoint: inspectorEndpoint,
})
case HTTPBasicAuth:
client, err = httpbasicintrospection.NewBareMetalIntrospectionHTTPBasic(httpbasicintrospection.EndpointOpts{
IronicInspectorEndpoint: inspectorEndpoint,
IronicInspectorUser: auth.Username,
IronicInspectorUserPassword: auth.Password,
})
default:
err = fmt.Errorf("Unknown auth type %s", auth.Type)
}
if err != nil {
return
}
return updateHTTPClient(client, tls)
}
11 changes: 1 addition & 10 deletions pkg/provisioner/ironic/configdrive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"testing"

"github.com/gophercloud/gophercloud/openstack/baremetal/v1/nodes"
"github.com/gophercloud/gophercloud/openstack/baremetalintrospection/v1/introspection"
"github.com/stretchr/testify/assert"

"github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
Expand Down Expand Up @@ -130,19 +129,11 @@ func TestEmpty(t *testing.T) {
ironic.Start()
defer ironic.Stop()

inspector := testserver.NewInspector(t).Ready().WithIntrospection(nodeUUID, introspection.Introspection{
Finished: false,
})
inspector.Start()
defer inspector.Stop()

host := makeHost()
host.Status.Provisioning.ID = nodeUUID
publisher := func(reason, message string) {}
auth := clients.AuthConfig{Type: clients.NoAuth}
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, publisher,
ironic.Endpoint(), auth, inspector.Endpoint(), auth,
)
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, publisher, ironic.Endpoint(), auth)
if err != nil {
t.Fatalf("could not create provisioner: %s", err)
}
Expand Down
16 changes: 4 additions & 12 deletions pkg/provisioner/ironic/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ func deleteTest(t *testing.T, detach bool) {
nodeUUID := "33ce8659-7400-4c68-9535-d10766f07a58"

cases := []struct {
name string
ironic *testserver.IronicMock
inspector *testserver.InspectorMock
hostName string
name string
ironic *testserver.IronicMock
hostName string

expectedDirty bool
expectedRequestAfter time.Duration
Expand Down Expand Up @@ -177,11 +176,6 @@ func deleteTest(t *testing.T, detach bool) {
defer tc.ironic.Stop()
}

if tc.inspector != nil {
tc.inspector.Start()
defer tc.inspector.Stop()
}

host := makeHost()
host.Status.Provisioning.ID = nodeUUID

Expand All @@ -190,9 +184,7 @@ func deleteTest(t *testing.T, detach bool) {
}

auth := clients.AuthConfig{Type: clients.NoAuth}
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, nullEventPublisher,
tc.ironic.Endpoint(), auth, tc.inspector.Endpoint(), auth,
)
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, nullEventPublisher, tc.ironic.Endpoint(), auth)
if err != nil {
t.Fatalf("could not create provisioner: %s", err)
}
Expand Down
32 changes: 8 additions & 24 deletions pkg/provisioner/ironic/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,22 @@ const (
)

type ironicDependenciesChecker struct {
client *gophercloud.ServiceClient
inspector *gophercloud.ServiceClient
log logr.Logger
client *gophercloud.ServiceClient
log logr.Logger
}

func newIronicDependenciesChecker(client *gophercloud.ServiceClient, inspector *gophercloud.ServiceClient, log logr.Logger) *ironicDependenciesChecker {
func newIronicDependenciesChecker(client *gophercloud.ServiceClient, log logr.Logger) *ironicDependenciesChecker {
return &ironicDependenciesChecker{
client: client,
inspector: inspector,
log: log,
client: client,
log: log,
}
}

func (i *ironicDependenciesChecker) IsReady() (result bool, err error) {

ready, err := i.checkIronic()
if ready && err == nil {
ready = i.checkIronicInspector()
ready := i.checkEndpoint(i.client)
if ready {
ready, err = i.checkIronicConductor()
}

return ready, err
}

Expand All @@ -53,14 +49,6 @@ func (i *ironicDependenciesChecker) checkEndpoint(client *gophercloud.ServiceCli
return err == nil
}

func (i *ironicDependenciesChecker) checkIronic() (ready bool, err error) {
ready = i.checkEndpoint(i.client)
if ready {
ready, err = i.checkIronicConductor()
}
return ready, err
}

func (i *ironicDependenciesChecker) checkIronicConductor() (ready bool, err error) {

pager := drivers.ListDrivers(i.client, drivers.ListDriversOpts{
Expand All @@ -86,7 +74,3 @@ func (i *ironicDependenciesChecker) checkIronicConductor() (ready bool, err erro

return ready, err
}

func (i *ironicDependenciesChecker) checkIronicInspector() (ready bool) {
return i.checkEndpoint(i.inspector)
}
Loading