Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.17] OCPBUGS-42426: fix: make sure that wipes are recorded by node #731

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/controllers/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const (
WorkloadPartitioningManagementAnnotation = "target.workload.openshift.io/management"
ManagementAnnotationVal = `{"effect": "PreferredDuringScheduling"}`

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

// labels and values

Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/vgmanager/wipe_devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (r *Reconciler) wipeDevices(
if volumeGroup.Annotations == nil {
volumeGroup.Annotations = make(map[string]string)
}
volumeGroup.Annotations[constants.DevicesWipedAnnotation] = fmt.Sprintf(
volumeGroup.Annotations[constants.DevicesWipedAnnotationPrefix+r.NodeName] = fmt.Sprintf(
"the devices of this volume group have been wiped at %s by lvms according to policy. This marker"+
"serves as indicator that the devices have been wiped before and should not be wiped again."+
"removal of this annotation is unsupported and may lead to data loss due to additional wiping.",
Expand Down Expand Up @@ -92,7 +92,7 @@ func (r *Reconciler) shouldWipeDevicesOnVolumeGroup(vg *lvmv1alpha1.LVMVolumeGro
// If the devices have not been wiped before, they should be wiped.
var wipedBefore bool
if vg.Annotations != nil {
_, wipedBefore = vg.Annotations[constants.DevicesWipedAnnotation]
_, wipedBefore = vg.Annotations[constants.DevicesWipedAnnotationPrefix+r.NodeName]
}

return !wipedBefore
Expand Down
4 changes: 3 additions & 1 deletion internal/controllers/vgmanager/wipe_devices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func TestWipeDevices(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
ctx := log.IntoContext(context.Background(), testr.New(t))
r := &Reconciler{
NodeName: "test",
Wipefs: mockWipefs,
Dmsetup: mockDmsetup,
SymlinkResolveFn: func(path string) (string, error) { return path, nil },
Expand All @@ -187,7 +188,8 @@ func TestWipeDevices(t *testing.T) {
}

if tt.wipedBefore {
volumeGroup.Annotations = map[string]string{constants.DevicesWipedAnnotation: time.Now().Format(time.RFC3339)}
volumeGroup.Annotations = map[string]string{
constants.DevicesWipedAnnotationPrefix + r.NodeName: time.Now().Format(time.RFC3339)}
}

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