nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: metal3-io/baremetal-operator
Pull request #849 (2021-04-08 13:31:44)

Fix adoption in ExternallyProvisioned state
In 269ff1eef216af719251daa4a33bc294409d1945 we stopped potentially
making use of the image from the Spec in the provisioner when there is
no image in the Status, except for the Provisioning state where we want
to register with the image we are provisioning even though it hasn't
completed yet.

We also need to make an exception for the ExternallyProvisioned state,
because in that state the image details are never copied to the Status.

This relies on the change in c0373bbfa38d3169d1b994cf0f0429396f12e651,
which ensures that the image data can be added to the Node once the Host
reaches the ExternallyProvisioned state. Prior to this, the image data
was only added when the Node was created, so we would have had to pass
the image details starting with the first call to
ValidateManagementAccess() in the Registration state.


Patch:
diff --git a/controllers/metal3.io/baremetalhost_controller.go b/controllers/metal3.io/baremetalhost_controller.go
index 6f651016..1cfeb741 100644
--- a/controllers/metal3.io/baremetalhost_controller.go
+++ b/controllers/metal3.io/baremetalhost_controller.go
@@ -541,9 +541,11 @@ func getCurrentImage(host *metal3v1alpha1.BareMetalHost) *metal3v1alpha1.Image {
 	}
 
 	// If we are in the process of provisioning an image, return that image
-	if host.Status.Provisioning.State == metal3v1alpha1.StateProvisioning &&
-		host.Spec.Image != nil && host.Spec.Image.URL != "" {
-		return host.Spec.Image.DeepCopy()
+	switch host.Status.Provisioning.State {
+	case metal3v1alpha1.StateProvisioning, metal3v1alpha1.StateExternallyProvisioned:
+		if host.Spec.Image != nil && host.Spec.Image.URL != "" {
+			return host.Spec.Image.DeepCopy()
+		}
 	}
 	return nil
 }


Test patch:
diff --git a/controllers/metal3.io/baremetalhost_controller_test.go b/controllers/metal3.io/baremetalhost_controller_test.go
index a62b4587..277b1e9c 100644
--- a/controllers/metal3.io/baremetalhost_controller_test.go
+++ b/controllers/metal3.io/baremetalhost_controller_test.go
@@ -1548,6 +1548,27 @@ func TestGetImageDeprovisioning(t *testing.T) {
 	assert.Exactly(t, host.Status.Provisioning.Image, *img)
 }
 
+func TestGetImageExternallyPprovisioned(t *testing.T) {
+	host := metal3v1alpha1.BareMetalHost{
+		Spec: metal3v1alpha1.BareMetalHostSpec{
+			Image: &metal3v1alpha1.Image{
+				URL: "http://example.test/image",
+			},
+		},
+		Status: metal3v1alpha1.BareMetalHostStatus{
+			Provisioning: metal3v1alpha1.ProvisionStatus{
+				State: metal3v1alpha1.StateExternallyProvisioned,
+			},
+		},
+	}
+
+	img := getCurrentImage(&host)
+
+	assert.NotNil(t, img)
+	assert.NotSame(t, host.Spec.Image, img)
+	assert.Exactly(t, *host.Spec.Image, *img)
+}
+
 func TestUpdateRAID(t *testing.T) {
 	host := metal3v1alpha1.BareMetalHost{
 		Spec: metal3v1alpha1.BareMetalHostSpec{
Repository: metal3-io/baremetal-operator
Pull request #913 (2021-06-10 12:32:39)

Extend docs for "baremetalhost.metal3.io/detached" annotation
Currently it's not clear that the `baremetalhost.metal3.io/detached`
annotation ignores the value. This PR makes it clear in the API
documentation that the annotation is not a boolean value so that setting
it as `"false"` may not have an expected result.

Supersedes: #912 


Patch:
diff --git a/docs/api.md b/docs/api.md
index 72de94cd..0aa97024 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -520,3 +520,6 @@ to be updated unlike the `paused` anotation. While in this state the
 OperationalStatus field will be `detached` but the provisioning state will
 be unmodified.  This API only has any effect for BareMetalHost resources
 that are in either `Provisioned` or `ExternallyProvisioned` state.
+
+Please note only the existence of the annotation is important to treat the BMH
+as detached and the value of the annotation is always ignored.
diff --git a/pkg/bmc/irmc.go b/pkg/bmc/irmc.go
index 4ad5b127..f6c45c9b 100644
--- a/pkg/bmc/irmc.go
+++ b/pkg/bmc/irmc.go
@@ -83,7 +83,7 @@ func (a *iRMCAccessDetails) PowerInterface() string {
 }
 
 func (a *iRMCAccessDetails) RAIDInterface() string {
-	return "no-raid"
+	return "irmc"
 }
 
 func (a *iRMCAccessDetails) VendorInterface() string {


Test patch:
diff --git a/pkg/provisioner/ironic/prepare_test.go b/pkg/provisioner/ironic/prepare_test.go
index bdf7c223..fe3c9468 100644
--- a/pkg/provisioner/ironic/prepare_test.go
+++ b/pkg/provisioner/ironic/prepare_test.go
@@ -158,7 +158,7 @@ func TestPrepare(t *testing.T) {
 			host.Status.Provisioning.ID = nodeUUID
 			prepData := provisioner.PrepareData{}
 			if tc.existRaidConfig {
-				host.Spec.BMC.Address = "idrac://test.bmc/"
+				host.Spec.BMC.Address = "irmc://test.bmc/"
 				prepData.RAIDConfig = &metal3v1alpha1.RAIDConfig{
 					HardwareRAIDVolumes: []metal3v1alpha1.HardwareRAIDVolume{
 						{