Skip to content

Commit d13c3c5

Browse files
Merge pull request #2755 from dtantsur/no-inspector
⚠️ Completely remove support for ironic-inspector
2 parents 52371b9 + c19f778 commit d13c3c5

File tree

6 files changed

+54
-155
lines changed

6 files changed

+54
-155
lines changed

pkg/provisioner/ironic/hardwaredetails/hardwaredetails.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ import (
99
"github.com/go-logr/logr"
1010
"github.com/gophercloud/gophercloud/v2/openstack/baremetal/inventory"
1111
"github.com/gophercloud/gophercloud/v2/openstack/baremetal/v1/nodes"
12-
"github.com/gophercloud/gophercloud/v2/openstack/baremetalintrospection/v1/introspection"
1312
metal3api "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
1413
)
1514

1615
// GetHardwareDetails converts Ironic introspection data into BareMetalHost HardwareDetails.
1716
func GetHardwareDetails(data *nodes.InventoryData, logger logr.Logger) *metal3api.HardwareDetails {
18-
ironicData, inspectorData, err := data.PluginData.GuessFormat()
17+
ironicData, err := data.PluginData.AsStandardData()
1918
if err != nil {
2019
logger.Error(err, "cannot get plugin data from inventory, some fields will not be available")
2120
}
@@ -24,7 +23,7 @@ func GetHardwareDetails(data *nodes.InventoryData, logger logr.Logger) *metal3ap
2423
details.Firmware = getFirmwareDetails(data.Inventory.SystemVendor.Firmware)
2524
details.SystemVendor = getSystemVendorDetails(data.Inventory.SystemVendor)
2625
details.RAMMebibytes = data.Inventory.Memory.PhysicalMb
27-
details.NIC = getNICDetails(data.Inventory.Interfaces, ironicData, inspectorData)
26+
details.NIC = getNICDetails(data.Inventory.Interfaces, ironicData)
2827
details.Storage = getStorageDetails(data.Inventory.Disks)
2928
details.CPU = getCPUDetails(&data.Inventory.CPU)
3029
details.Hostname = data.Inventory.Hostname
@@ -54,20 +53,11 @@ func getVLANs(lldp map[string]interface{}) (vlans []metal3api.VLAN, vlanid metal
5453
return
5554
}
5655

57-
func getNICDetails(ifdata []inventory.InterfaceType,
58-
ironicData *inventory.StandardPluginData,
59-
inspectorData *introspection.Data) []metal3api.NIC {
56+
func getNICDetails(ifdata []inventory.InterfaceType, ironicData inventory.StandardPluginData) []metal3api.NIC {
6057
var nics []metal3api.NIC
6158
for _, intf := range ifdata {
62-
var lldp map[string]interface{}
63-
var pxeEnabled bool
64-
if ironicData != nil {
65-
pxeEnabled = ironicData.AllInterfaces[intf.Name].PXEEnabled
66-
lldp = ironicData.ParsedLLDP[intf.Name]
67-
} else {
68-
pxeEnabled = inspectorData.AllInterfaces[intf.Name].PXE
69-
lldp = inspectorData.AllInterfaces[intf.Name].LLDPProcessed
70-
}
59+
pxeEnabled := ironicData.AllInterfaces[intf.Name].PXEEnabled
60+
lldp := ironicData.ParsedLLDP[intf.Name]
7161

7262
vlans, vlanid := getVLANs(lldp)
7363
// We still store one nic even if both ips are unset

pkg/provisioner/ironic/hardwaredetails/hardwaredetails_test.go

Lines changed: 43 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"testing"
66

77
"github.com/gophercloud/gophercloud/v2/openstack/baremetal/inventory"
8-
"github.com/gophercloud/gophercloud/v2/openstack/baremetalintrospection/v1/introspection"
98
metal3api "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
109
"github.com/stretchr/testify/assert"
1110
)
@@ -129,7 +128,7 @@ func TestGetVLANsMalformed(t *testing.T) {
129128
}
130129
}
131130

132-
func TestGetNICDetailsInspector(t *testing.T) {
131+
func TestGetNICDetails(t *testing.T) {
133132
ironicData := inventory.StandardPluginData{
134133
AllInterfaces: map[string]inventory.ProcessedInterfaceType{
135134
"eth0": {
@@ -147,21 +146,6 @@ func TestGetNICDetailsInspector(t *testing.T) {
147146
},
148147
},
149148
}
150-
inspectorData := introspection.Data{
151-
AllInterfaces: map[string]introspection.BaseInterfaceType{
152-
"eth0": {
153-
PXE: true,
154-
LLDPProcessed: map[string]interface{}{
155-
"switch_port_vlans": []map[string]interface{}{
156-
{
157-
"id": 1,
158-
},
159-
},
160-
"switch_port_untagged_vlan_id": 1,
161-
},
162-
},
163-
},
164-
}
165149
interfaces := []inventory.InterfaceType{
166150
{
167151
Name: "eth0",
@@ -182,69 +166,49 @@ func TestGetNICDetailsInspector(t *testing.T) {
182166
MACAddress: "00:11:22:33:44:77"},
183167
}
184168

185-
cases := []struct {
186-
name string
187-
ironicData *inventory.StandardPluginData
188-
inspectorData *introspection.Data
189-
}{
190-
{
191-
name: "with-ironic",
192-
ironicData: &ironicData,
193-
inspectorData: nil,
194-
},
195-
{
196-
name: "with-inspector",
197-
ironicData: nil,
198-
inspectorData: &inspectorData,
199-
},
200-
}
201-
for _, tc := range cases {
202-
t.Run(tc.name, func(t *testing.T) {
203-
nics := getNICDetails(interfaces, tc.ironicData, tc.inspectorData)
169+
nics := getNICDetails(interfaces, ironicData)
204170

205-
// 5 expected because eth46 results in two items
206-
assert.Len(t, nics, 5)
207-
if (!reflect.DeepEqual(nics[0], metal3api.NIC{
208-
Name: "eth0",
209-
MAC: "00:11:22:33:44:55",
210-
IP: "192.0.2.1",
211-
PXE: true,
212-
VLANs: []metal3api.VLAN{
213-
{ID: 1},
214-
},
215-
VLANID: 1,
216-
})) {
217-
t.Errorf("Unexpected NIC data")
218-
}
219-
if (!reflect.DeepEqual(nics[1], metal3api.NIC{
220-
Name: "eth1",
221-
MAC: "66:77:88:99:aa:bb",
222-
IP: "2001:db8::1",
223-
SpeedGbps: 1,
224-
})) {
225-
t.Errorf("Unexpected NIC data")
226-
}
227-
if (!reflect.DeepEqual(nics[2], metal3api.NIC{
228-
Name: "eth46",
229-
MAC: "00:11:22:33:44:66",
230-
IP: "192.0.2.2",
231-
})) {
232-
t.Errorf("Unexpected NIC data")
233-
}
234-
if (!reflect.DeepEqual(nics[3], metal3api.NIC{
235-
Name: "eth46",
236-
MAC: "00:11:22:33:44:66",
237-
IP: "2001:db8::2",
238-
})) {
239-
t.Errorf("Unexpected NIC data")
240-
}
241-
if (!reflect.DeepEqual(nics[4], metal3api.NIC{
242-
Name: "ethNoIp",
243-
MAC: "00:11:22:33:44:77",
244-
})) {
245-
t.Errorf("Unexpected NIC data")
246-
}
247-
})
171+
// 5 expected because eth46 results in two items
172+
assert.Len(t, nics, 5)
173+
if (!reflect.DeepEqual(nics[0], metal3api.NIC{
174+
Name: "eth0",
175+
MAC: "00:11:22:33:44:55",
176+
IP: "192.0.2.1",
177+
PXE: true,
178+
VLANs: []metal3api.VLAN{
179+
{ID: 1},
180+
},
181+
VLANID: 1,
182+
})) {
183+
t.Errorf("Unexpected NIC data")
184+
}
185+
if (!reflect.DeepEqual(nics[1], metal3api.NIC{
186+
Name: "eth1",
187+
MAC: "66:77:88:99:aa:bb",
188+
IP: "2001:db8::1",
189+
SpeedGbps: 1,
190+
})) {
191+
t.Errorf("Unexpected NIC data")
192+
}
193+
if (!reflect.DeepEqual(nics[2], metal3api.NIC{
194+
Name: "eth46",
195+
MAC: "00:11:22:33:44:66",
196+
IP: "192.0.2.2",
197+
})) {
198+
t.Errorf("Unexpected NIC data")
199+
}
200+
if (!reflect.DeepEqual(nics[3], metal3api.NIC{
201+
Name: "eth46",
202+
MAC: "00:11:22:33:44:66",
203+
IP: "2001:db8::2",
204+
})) {
205+
t.Errorf("Unexpected NIC data")
206+
}
207+
if (!reflect.DeepEqual(nics[4], metal3api.NIC{
208+
Name: "ethNoIp",
209+
MAC: "00:11:22:33:44:77",
210+
})) {
211+
t.Errorf("Unexpected NIC data")
248212
}
249213
}
250214

pkg/provisioner/ironic/inspecthardware.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,16 @@ package ironic
33
import (
44
"fmt"
55
"net/http"
6-
"slices"
76
"strings"
87

98
"github.com/gophercloud/gophercloud/v2"
10-
"github.com/gophercloud/gophercloud/v2/openstack/baremetal/v1/drivers"
119
"github.com/gophercloud/gophercloud/v2/openstack/baremetal/v1/nodes"
1210
metal3api "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
13-
"github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc"
1411
"github.com/metal3-io/baremetal-operator/pkg/provisioner"
1512
"github.com/metal3-io/baremetal-operator/pkg/provisioner/ironic/clients"
1613
"github.com/metal3-io/baremetal-operator/pkg/provisioner/ironic/hardwaredetails"
1714
)
1815

19-
func (p *ironicProvisioner) getInspectInterface(bmcAccess bmc.AccessDetails) (string, error) {
20-
driver, err := drivers.GetDriverDetails(p.ctx, p.client, bmcAccess.Driver()).Extract()
21-
if err != nil {
22-
return "", fmt.Errorf("cannot load information about driver %s: %w", bmcAccess.Driver(), err)
23-
}
24-
25-
if slices.Contains(driver.EnabledInspectInterfaces, "agent") {
26-
return "agent", nil
27-
}
28-
29-
return "inspector", nil // backward compatibility
30-
}
31-
3216
func (p *ironicProvisioner) abortInspection(ironicNode *nodes.Node) (result provisioner.Result, started bool, details *metal3api.HardwareDetails, err error) {
3317
// Set started to let the controller know about the change
3418
p.log.Info("aborting inspection to force reboot of preprovisioning image")

pkg/provisioner/ironic/register.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import (
1515
"sigs.k8s.io/yaml"
1616
)
1717

18+
const (
19+
defaultInspectInterface = "agent"
20+
)
21+
1822
func bmcAddressMatches(ironicNode *nodes.Node, driverInfo map[string]interface{}) bool {
1923
newAddress := make(map[string]interface{})
2024
ironicAddress := make(map[string]interface{})
@@ -234,19 +238,14 @@ func (p *ironicProvisioner) Register(data provisioner.ManagementAccessData, cred
234238
}
235239

236240
func (p *ironicProvisioner) enrollNode(data provisioner.ManagementAccessData, bmcAccess bmc.AccessDetails, driverInfo map[string]interface{}) (ironicNode *nodes.Node, retry bool, err error) {
237-
inspectInterface, err := p.getInspectInterface(bmcAccess)
238-
if err != nil {
239-
return nil, true, err
240-
}
241-
242241
nodeCreateOpts := nodes.CreateOpts{
243242
Driver: bmcAccess.Driver(),
244243
BIOSInterface: bmcAccess.BIOSInterface(),
245244
BootInterface: bmcAccess.BootInterface(),
246245
Name: ironicNodeName(p.objectMeta),
247246
DriverInfo: driverInfo,
248247
DeployInterface: p.deployInterface(data),
249-
InspectInterface: inspectInterface,
248+
InspectInterface: defaultInspectInterface,
250249
ManagementInterface: bmcAccess.ManagementInterface(),
251250
PowerInterface: bmcAccess.PowerInterface(),
252251
RAIDInterface: bmcAccess.RAIDInterface(),

pkg/provisioner/ironic/register_test.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -108,44 +108,6 @@ func TestRegisterCreateNode(t *testing.T) {
108108
assert.Equal(t, "agent", createdNode.InspectInterface)
109109
}
110110

111-
func TestRegisterCreateNodeOldInspection(t *testing.T) {
112-
// Create a host without a bootMACAddress and with a BMC that
113-
// does not require one.
114-
host := makeHost()
115-
host.Spec.BootMACAddress = ""
116-
host.Spec.Image = nil
117-
host.Status.Provisioning.ID = "" // so we don't lookup by uuid
118-
119-
var createdNode *nodes.Node
120-
121-
createCallback := func(node nodes.Node) {
122-
createdNode = &node
123-
}
124-
125-
ironic := testserver.NewIronic(t).CreateNodes(createCallback).NoNode(host.Namespace + nameSeparator + host.Name).NoNode(host.Name)
126-
ironic.AddDefaultResponse("/v1/nodes/node-0", "PATCH", http.StatusOK, "{}")
127-
ironic.AddDefaultResponse("/v1/drivers/test", "GET", 200, `
128-
{"enabled_inspect_interfaces": ["inspector", "no-inspect"]}
129-
`)
130-
ironic.Start()
131-
defer ironic.Stop()
132-
133-
auth := clients.AuthConfig{Type: clients.NoAuth}
134-
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, nullEventPublisher, ironic.Endpoint(), auth)
135-
if err != nil {
136-
t.Fatalf("could not create provisioner: %s", err)
137-
}
138-
139-
result, provID, err := prov.Register(provisioner.ManagementAccessData{}, false, false)
140-
if err != nil {
141-
t.Fatalf("error from Register: %s", err)
142-
}
143-
assert.Empty(t, result.ErrorMessage)
144-
assert.NotEmpty(t, createdNode.UUID)
145-
assert.Equal(t, createdNode.UUID, provID)
146-
assert.Equal(t, "inspector", createdNode.InspectInterface)
147-
}
148-
149111
func TestRegisterExistingNode(t *testing.T) {
150112
// Create a host without a bootMACAddress and with a BMC that
151113
// does not require one.

pkg/provisioner/ironic/testserver/ironic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (m *IronicMock) WithDrivers() *IronicMock {
106106
m.ResponseWithCode("/v1/drivers/test", `
107107
{
108108
"enabled_deploy_interfaces": ["direct", "ramdisk", "custom-agent"],
109-
"enabled_inspect_interfaces": ["agent", "inspector", "no-inspect"]
109+
"enabled_inspect_interfaces": ["agent", "no-inspect"]
110110
}
111111
`, http.StatusOK)
112112
return m

0 commit comments

Comments
 (0)