Skip to content

Commit

Permalink
[release-ocm-2.8] OCPBUGS-13081: Support by-path root device hints (#…
Browse files Browse the repository at this point in the history
…5385)

* OCPBUGS-13081: Support by-path root device hints

* Use by-path device link in BMH HardwareDetails

Align with the change in Metal³ to use the /dev/disks/by-path/ alias in
the 'name' field of a storage device, since this is stable across
reboots. The canonical /dev/sd paths are much less likely to be stable
with the RHEL 9 kernel than they were with RHEL 8.

---------

Co-authored-by: Zane Bitter <zbitter@redhat.com>
  • Loading branch information
openshift-cherrypick-robot and zaneb committed Jul 26, 2023
1 parent 60abd50 commit dd4be30
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
6 changes: 5 additions & 1 deletion internal/controller/controllers/bmh_agent_controller.go
Expand Up @@ -629,9 +629,13 @@ func (r *BMACReconciler) reconcileAgentInventory(log logrus.FieldLogger, bmh *bm

// Add storage
for _, d := range inventory.Disks {
device := d.Path
if d.ByPath != "" {
device = d.ByPath
}
// missing WWNVendorExtension, WWNWithExtension
disk := bmh_v1alpha1.Storage{
Name: d.Path,
Name: device,
HCTL: d.Hctl,
Model: d.Model,
SizeBytes: bmh_v1alpha1.Capacity(d.SizeBytes),
Expand Down
19 changes: 19 additions & 0 deletions internal/controller/controllers/bmh_agent_controller_test.go
Expand Up @@ -467,6 +467,7 @@ var _ = Describe("bmac reconcile", func() {
ID: "1",
InstallationEligibility: v1beta1.HostInstallationEligibility{Eligible: true},
Path: "/dev/sda",
ByPath: "/dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:0:0",
DriveType: string(models.DriveTypeSSD),
Bootable: true,
SizeBytes: int64(120) * 1000 * 1000 * 1000,
Expand All @@ -475,6 +476,7 @@ var _ = Describe("bmac reconcile", func() {
ID: "2",
InstallationEligibility: v1beta1.HostInstallationEligibility{Eligible: true},
Path: "/dev/sdb",
ByPath: "/dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:1:0",
DriveType: string(models.DriveTypeSSD),
Bootable: true,
},
Expand Down Expand Up @@ -708,6 +710,23 @@ var _ = Describe("bmac reconcile", func() {
Expect(updatedAgent.Spec.InstallationDiskID).To(Equal("1"))
})

It("should set the InstallationDiskID if the by-path RootDeviceHints were provided and match", func() {
updatedHost := &bmh_v1alpha1.BareMetalHost{}
err := c.Get(ctx, types.NamespacedName{Name: host.Name, Namespace: testNamespace}, updatedHost)
Expect(err).To(BeNil())
updatedHost.Spec.RootDeviceHints.DeviceName = "/dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:0:0"
updatedHost.Spec.RootDeviceHints.MinSizeGigabytes = 110
Expect(c.Update(ctx, updatedHost)).To(BeNil())

result, err := bmhr.Reconcile(ctx, newBMHRequest(host))
Expect(err).To(BeNil())
Expect(result).To(Equal(ctrl.Result{}))

updatedAgent := &v1beta1.Agent{}
err = c.Get(ctx, types.NamespacedName{Name: agent.Name, Namespace: agent.Namespace}, updatedAgent)
Expect(err).To(BeNil())
Expect(updatedAgent.Spec.InstallationDiskID).To(Equal("1"))
})
It("should not touch InstallationDiskID if the RootDeviceHints were not provided", func() {
updatedHost := &bmh_v1alpha1.BareMetalHost{}
err := c.Get(ctx, types.NamespacedName{Name: host.Name, Namespace: testNamespace}, updatedHost)
Expand Down
2 changes: 1 addition & 1 deletion internal/host/hostutil/host_utils.go
Expand Up @@ -190,7 +190,7 @@ func GetAcceptableDisksWithHints(disks []*models.Disk, hints *bmh_v1alpha1.RootD
}

if hints != nil {
if hints.DeviceName != "" && hints.DeviceName != disk.Path {
if hints.DeviceName != "" && hints.DeviceName != disk.Path && hints.DeviceName != disk.ByPath {
continue
}

Expand Down
6 changes: 5 additions & 1 deletion internal/ignition/ignition.go
Expand Up @@ -939,8 +939,12 @@ func (g *installerGenerator) modifyBMHFile(file *config_latest_types.File, bmh *
}
}
for i, disk := range inventory.Disks {
device := disk.Path
if disk.ByPath != "" {
device = disk.ByPath
}
hw.Storage[i] = bmh_v1alpha1.Storage{
Name: disk.Path,
Name: device,
Vendor: disk.Vendor,
SizeBytes: bmh_v1alpha1.Capacity(disk.SizeBytes),
Model: disk.Model,
Expand Down

0 comments on commit dd4be30

Please sign in to comment.