Skip to content

Commit

Permalink
Fix missing case of BuildRAIDCleanSteps
Browse files Browse the repository at this point in the history
When `hardwareRAIDVolumes` is nil and the target node doesn't have a RAID
controller. We shouldn't delete the RAID configuration on that node in
that case, otherwise the `ironic` node will enter the clean failed state
because of `delete_configuration` clean step failure. So in this case, hardware
RAID operations will be skipped.

Signed-off-by: Zou Yu <zouy.fnst@cn.fujitsu.com>
(cherry picked from commit 32ba3e9)
  • Loading branch information
Hellcatlk committed Aug 6, 2021
1 parent 1759c5e commit 2a60349
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/provisioner/ironic/raid.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,14 @@ func BuildRAIDCleanSteps(raidInterface string, target *metal3v1alpha1.RAIDConfig
}

// Hardware RAID
// Ignore SoftwareRAIDVolumes
if target != nil {
target.SoftwareRAIDVolumes = nil
// If hardware RAID configuration is nil,
// keep old hardware RAID configuration
if target == nil || target.HardwareRAIDVolumes == nil {
return
}

// Ignore SoftwareRAIDVolumes
target.SoftwareRAIDVolumes = nil
if actual != nil {
actual.SoftwareRAIDVolumes = nil
}
Expand All @@ -232,7 +236,7 @@ func BuildRAIDCleanSteps(raidInterface string, target *metal3v1alpha1.RAIDConfig
)

// If hardware raid configuration is empty, only need to clear old configuration
if target == nil || len(target.HardwareRAIDVolumes) == 0 {
if len(target.HardwareRAIDVolumes) == 0 {
return
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/provisioner/ironic/raid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ func TestBuildRAIDCleanSteps(t *testing.T) {
expected []nodes.CleanStep
expectedError bool
}{
{
name: "keep hardware RAID",
raidInterface: "irmc",
target: nil,
},
{
name: "keep hardware RAID",
raidInterface: "irmc",
target: &metal3v1alpha1.RAIDConfig{},
},
{
name: "configure hardware RAID",
raidInterface: "irmc",
Expand Down

0 comments on commit 2a60349

Please sign in to comment.