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

[issue-1088] alerts for missing disks #1102

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions pkg/node/volumemgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,12 @@ func (m *VolumeManager) createEventsForDriveUpdates(updates *driveUpdates) {
m.createEventForDriveStatusChange(
updDrive.CurrentState, updDrive.PreviousState.Spec.Status, updDrive.CurrentState.Spec.Status)
}
if updDrive.CurrentState.Spec.Status == apiV1.DriveStatusOffline {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that we get two same events the one generated in line 1111 and this new one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For normal flow is should not be possible, however to to be 100% safe I've changed the code to handle this situation. Thank you!

if updDrive.CurrentState.Spec.Usage == apiV1.DriveUsageRemoved &&
updDrive.PreviousState.Spec.Usage == apiV1.DriveUsageRemoving {
m.createEventForMissingDriveRemoved(updDrive.CurrentState)
}
}
currentHealth := updDrive.CurrentState.Spec.Health
if currentHealth != updDrive.PreviousState.Spec.Health {
if _, ok := updDrive.CurrentState.Annotations[driveHealthOverrideAnnotation]; ok {
Expand Down Expand Up @@ -1168,6 +1174,12 @@ func (m *VolumeManager) createEventForDriveStatusChange(
statusMsgTemplate, currentStatus, prevStatus)
}

func (m *VolumeManager) createEventForMissingDriveRemoved(drive *drivecrd.Drive) {
event := eventing.DriveSuccessfullyRemoved
msgTemplate := "Drive successfully removed for a missing disk."
m.sendEventForDrive(drive, event, msgTemplate)
}

// createEventForDriveHealthOverridden creates DriveHealthOverridden with Warning type
func (m *VolumeManager) createEventForDriveHealthOverridden(
drive *drivecrd.Drive, realHealth, overriddenHealth string) {
Expand Down
19 changes: 19 additions & 0 deletions pkg/node/volumemgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,25 @@ func TestVolumeManager_createEventsForDriveUpdates(t *testing.T) {
assert.True(t, expectEvent(drive1CR, eventing.DriveSuccessfullyRemoved))
assert.True(t, expectEvent(drive1CR, eventing.DriveHealthUnknown))
})

t.Run("Drive removed for missing disk", func(t *testing.T) {
init()
previousDrive := drive1CR.DeepCopy()
modifiedDrive := drive1CR.DeepCopy()
previousDrive.Spec.Status = apiV1.DriveStatusOffline
previousDrive.Spec.Usage = apiV1.DriveUsageRemoving
modifiedDrive.Spec.Status = apiV1.DriveStatusOffline
modifiedDrive.Spec.Usage = apiV1.DriveUsageRemoved

upd := &driveUpdates{
Updated: []updatedDrive{{
PreviousState: previousDrive,
CurrentState: modifiedDrive}},
}
mgr.createEventsForDriveUpdates(upd)
assert.True(t, expectEvent(drive1CR, eventing.DriveSuccessfullyRemoved))
})

}

func TestVolumeManager_isShouldBeReconciled(t *testing.T) {
Expand Down
Loading