Skip to content

Commit

Permalink
controller: consider the new provision field
Browse files Browse the repository at this point in the history
    - improve the whole handling with the new provision field

Signed-off-by: Vicente Cheng <[email protected]>
(cherry picked from commit 1877a4e)
  • Loading branch information
Vicente-Cheng committed Sep 26, 2024
1 parent 89efb11 commit dc1e70a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/controller/blockdevice/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ func (c *Controller) updateDeviceStatus(device *diskv1.BlockDevice, devPath stri
logrus.Infof("Auto provisioning block device %s", device.Name)
device.Spec.FileSystem.ForceFormatted = true
device.Spec.FileSystem.Provisioned = true
device.Spec.Provision = true
}
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/blockdevice/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (s *Scanner) SaveBlockDevice(bd *diskv1.BlockDevice, autoProvisioned bool)
if autoProvisioned {
bd.Spec.FileSystem.ForceFormatted = true
bd.Spec.FileSystem.Provisioned = true
bd.Spec.Provision = true
}
logrus.Infof("Add new block device %s with device: %s", bd.Name, bd.Spec.DevPath)
return s.Blockdevices.Create(bd)
Expand All @@ -301,7 +302,7 @@ func (s *Scanner) SaveBlockDevice(bd *diskv1.BlockDevice, autoProvisioned bool)
// - disk hasn't yet been force formatted
// - disk matches auto-provisioned patterns
func (s *Scanner) NeedsAutoProvision(oldBd *diskv1.BlockDevice, autoProvisionPatternMatches bool) bool {
return !oldBd.Spec.FileSystem.Provisioned && autoProvisionPatternMatches && oldBd.Status.DeviceStatus.FileSystem.LastFormattedAt == nil
return !oldBd.Spec.FileSystem.Provisioned && !oldBd.Spec.Provision && autoProvisionPatternMatches && oldBd.Status.DeviceStatus.FileSystem.LastFormattedAt == nil
}

// isDevPathChanged returns true if the device path has changed.
Expand Down
5 changes: 3 additions & 2 deletions pkg/provisioner/longhornv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ func needUpdateMountPoint(bd *diskv1.BlockDevice, filesystem *block.FileSystemIn
return NeedMountUpdateNoOp
}

logrus.Debugf("Checking mount operation with FS.Provisioned %v, FS.Mountpoint %s", bd.Spec.FileSystem.Provisioned, filesystem.MountPoint)
if bd.Spec.FileSystem.Provisioned {
provisioned := bd.Spec.FileSystem.Provisioned || bd.Spec.Provision
logrus.Debugf("Checking mount operation with FS.Provisioned %v, FS.Mountpoint %s", provisioned, filesystem.MountPoint)
if provisioned {
if filesystem.MountPoint == "" {
return NeedMountUpdateMount
}
Expand Down

0 comments on commit dc1e70a

Please sign in to comment.