Skip to content

Commit

Permalink
Merge pull request #345 from suleymanakbas91/reserved
Browse files Browse the repository at this point in the history
OCPBUGS-14040: Filter out reserved disks
  • Loading branch information
openshift-merge-robot authored May 25, 2023
2 parents c014fe7 + 71a3a64 commit 9376f90
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/vgmanager/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
notReadOnly = "notReadOnly"
notSuspended = "notSuspended"
noBiosBootInPartLabel = "noBiosBootInPartLabel"
noReservedInPartLabel = "noReservedInPartLabel"
noFilesystemSignature = "noFilesystemSignature"
noBindMounts = "noBindMounts"
noChildren = "noChildren"
Expand Down Expand Up @@ -54,6 +55,11 @@ var FilterMap = map[string]func(internal.BlockDevice, internal.Executor) (bool,
return !biosBootInPartLabel, nil
},

noReservedInPartLabel: func(dev internal.BlockDevice, _ internal.Executor) (bool, error) {
reservedInPartLabel := strings.Contains(strings.ToLower(dev.PartLabel), "reserved")
return !reservedInPartLabel, nil
},

noFilesystemSignature: func(dev internal.BlockDevice, _ internal.Executor) (bool, error) {
matched := dev.FSType == ""
return matched, nil
Expand Down
15 changes: 15 additions & 0 deletions pkg/vgmanager/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,18 @@ func TestNoBiosBootInPartLabel(t *testing.T) {
}
}
}

func TestNoReservedInPartLabel(t *testing.T) {
testcases := []filterTestCase{
{label: "tc 1", device: internal.BlockDevice{Name: "dev1", PartLabel: ""}, expected: true},
{label: "tc 2", device: internal.BlockDevice{Name: "dev2", PartLabel: "abc"}, expected: true},
{label: "tc 3", device: internal.BlockDevice{Name: "dev3", PartLabel: "reserved"}, expected: false},
{label: "tc 4", device: internal.BlockDevice{Name: "dev4", PartLabel: "RESERVED"}, expected: false},
{label: "tc 5", device: internal.BlockDevice{Name: "dev5", PartLabel: "Reserved"}, expected: false},
}
for _, tc := range testcases {
result, err := FilterMap[noReservedInPartLabel](tc.device, nil)
assert.NoError(t, err)
assert.Equal(t, tc.expected, result)
}
}

0 comments on commit 9376f90

Please sign in to comment.