Skip to content

Commit bc5e556

Browse files
Merge pull request #731 from openshift-cherrypick-robot/cherry-pick-730-to-release-4.17
[release-4.17] OCPBUGS-42426: fix: make sure that wipes are recorded by node
2 parents acd82df + bd9ec46 commit bc5e556

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

internal/controllers/constants/constants.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const (
4141
WorkloadPartitioningManagementAnnotation = "target.workload.openshift.io/management"
4242
ManagementAnnotationVal = `{"effect": "PreferredDuringScheduling"}`
4343

44-
// DevicesWipedAnnotation is an annotation that marks when a device has been wiped
45-
DevicesWipedAnnotation = "devices.lvms.openshift.io/wiped"
44+
// DevicesWipedAnnotationPrefix is an annotation prefix that marks when a device has been wiped on a certain node
45+
DevicesWipedAnnotationPrefix = "wiped.devices.lvms.openshift.io/"
4646

4747
// labels and values
4848

internal/controllers/vgmanager/wipe_devices.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (r *Reconciler) wipeDevices(
5858
if volumeGroup.Annotations == nil {
5959
volumeGroup.Annotations = make(map[string]string)
6060
}
61-
volumeGroup.Annotations[constants.DevicesWipedAnnotation] = fmt.Sprintf(
61+
volumeGroup.Annotations[constants.DevicesWipedAnnotationPrefix+r.NodeName] = fmt.Sprintf(
6262
"the devices of this volume group have been wiped at %s by lvms according to policy. This marker"+
6363
"serves as indicator that the devices have been wiped before and should not be wiped again."+
6464
"removal of this annotation is unsupported and may lead to data loss due to additional wiping.",
@@ -92,7 +92,7 @@ func (r *Reconciler) shouldWipeDevicesOnVolumeGroup(vg *lvmv1alpha1.LVMVolumeGro
9292
// If the devices have not been wiped before, they should be wiped.
9393
var wipedBefore bool
9494
if vg.Annotations != nil {
95-
_, wipedBefore = vg.Annotations[constants.DevicesWipedAnnotation]
95+
_, wipedBefore = vg.Annotations[constants.DevicesWipedAnnotationPrefix+r.NodeName]
9696
}
9797

9898
return !wipedBefore

internal/controllers/vgmanager/wipe_devices_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func TestWipeDevices(t *testing.T) {
167167
t.Run(tt.name, func(t *testing.T) {
168168
ctx := log.IntoContext(context.Background(), testr.New(t))
169169
r := &Reconciler{
170+
NodeName: "test",
170171
Wipefs: mockWipefs,
171172
Dmsetup: mockDmsetup,
172173
SymlinkResolveFn: func(path string) (string, error) { return path, nil },
@@ -187,7 +188,8 @@ func TestWipeDevices(t *testing.T) {
187188
}
188189

189190
if tt.wipedBefore {
190-
volumeGroup.Annotations = map[string]string{constants.DevicesWipedAnnotation: time.Now().Format(time.RFC3339)}
191+
volumeGroup.Annotations = map[string]string{
192+
constants.DevicesWipedAnnotationPrefix + r.NodeName: time.Now().Format(time.RFC3339)}
191193
}
192194

193195
wiped, err := r.wipeDevices(ctx, volumeGroup, tt.blockDevices, symlinkResolver.NewWithResolver(r.SymlinkResolveFn))

0 commit comments

Comments
 (0)