Skip to content

Commit

Permalink
A drive whose Usage is REMOVED will not be selected in any storage gr…
Browse files Browse the repository at this point in the history
…oup and its exising sg label takes no effect

Signed-off-by: Shi, Crane <[email protected]>
  • Loading branch information
CraneShiEMC committed Jul 3, 2023
1 parent 3ed69d8 commit e4ad183
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/crcontrollers/storagegroup/storagegroupcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ func (c *Controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
log := c.log.WithFields(logrus.Fields{"method": "Reconcile", "name": name})

drive := &drivecrd.Drive{}
if err := c.client.ReadCR(ctx, name, "", drive); err == nil {
// A drive whose Usage is REMOVED will not be selected in any storage group and its exising sg label takes no effect
if err := c.client.ReadCR(ctx, name, "", drive); err == nil && drive.Spec.Usage != apiV1.DriveUsageRemoved {
return c.syncDriveStorageGroupLabel(ctx, drive)
} else if !k8serrors.IsNotFound(err) {
} else if err != nil && !k8serrors.IsNotFound(err) {
log.Errorf("error in reading %s as drive object: %v", name, err)
}

Expand Down Expand Up @@ -427,6 +428,12 @@ func (c *Controller) handleStorageGroupCreationOrUpdate(ctx context.Context, log
var candidateDrives []*drivecrd.Drive
for _, d := range drivesList.Items {
drive := d

// A drive whose Usage is REMOVED will not be selected in any storage group and its exising sg label takes no effect
if drive.Spec.Usage == apiV1.DriveUsageRemoved {
continue
}

existingStorageGroup, exists := drive.Labels[apiV1.StorageGroupLabelKey]
if exists {
if existingStorageGroup == sg.Name {
Expand Down

0 comments on commit e4ad183

Please sign in to comment.