diff --git a/pkg/node/volumemgr.go b/pkg/node/volumemgr.go index fac40e58f..d9e36e064 100644 --- a/pkg/node/volumemgr.go +++ b/pkg/node/volumemgr.go @@ -1109,6 +1109,11 @@ func (m *VolumeManager) createEventsForDriveUpdates(updates *driveUpdates) { if updDrive.CurrentState.Spec.Status != updDrive.PreviousState.Spec.Status { m.createEventForDriveStatusChange( updDrive.CurrentState, updDrive.PreviousState.Spec.Status, updDrive.CurrentState.Spec.Status) + } else if updDrive.CurrentState.Spec.Status == apiV1.DriveStatusOffline { + 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 { @@ -1168,6 +1173,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) { diff --git a/pkg/node/volumemgr_test.go b/pkg/node/volumemgr_test.go index b6a40fb9d..fede7c388 100644 --- a/pkg/node/volumemgr_test.go +++ b/pkg/node/volumemgr_test.go @@ -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) {