From f7e4cbe0df5b6b9638d5e3eda26291abe11565f2 Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Wed, 25 Sep 2024 01:39:58 +0800 Subject: [PATCH] controller: consider the new provision field - improve the whole handling with the new provision field Signed-off-by: Vicente Cheng --- pkg/controller/blockdevice/controller.go | 1 + pkg/controller/blockdevice/scanner.go | 3 ++- pkg/provisioner/longhornv1.go | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/controller/blockdevice/controller.go b/pkg/controller/blockdevice/controller.go index 8ef4c184..98f81e21 100644 --- a/pkg/controller/blockdevice/controller.go +++ b/pkg/controller/blockdevice/controller.go @@ -319,6 +319,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 } diff --git a/pkg/controller/blockdevice/scanner.go b/pkg/controller/blockdevice/scanner.go index fc09570c..d4e7c9c5 100644 --- a/pkg/controller/blockdevice/scanner.go +++ b/pkg/controller/blockdevice/scanner.go @@ -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) @@ -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. diff --git a/pkg/provisioner/longhornv1.go b/pkg/provisioner/longhornv1.go index 2c25ca97..e5b390c6 100644 --- a/pkg/provisioner/longhornv1.go +++ b/pkg/provisioner/longhornv1.go @@ -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 }