@@ -22,6 +22,7 @@ import (
2222 apis "github.com/openebs/node-disk-manager/api/v1alpha1"
2323 "github.com/openebs/node-disk-manager/blockdevice"
2424 "github.com/openebs/node-disk-manager/db/kubernetes"
25+ "github.com/openebs/node-disk-manager/pkg/features"
2526 "github.com/openebs/node-disk-manager/pkg/partition"
2627
2728 "k8s.io/apimachinery/pkg/api/errors"
@@ -111,18 +112,29 @@ func (pe *ProbeEvent) addBlockDevice(bd blockdevice.BlockDevice, bdAPIList *apis
111112 len (bd .DependentDevices .Holders ) > 0 {
112113 klog .V (4 ).Infof ("device: %s has holders/partitions. %+v" , bd .DevPath , bd .DependentDevices )
113114 } else {
114- klog .Infof ("starting to create partition on device: %s" , bd .DevPath )
115115 d := partition.Disk {
116116 DevPath : bd .DevPath ,
117117 DiskSize : bd .Capacity .Storage ,
118118 LogicalBlockSize : uint64 (bd .DeviceAttributes .LogicalBlockSize ),
119119 }
120- if err := d .CreateSinglePartition (); err != nil {
121- klog .Errorf ("error creating partition for %s, %v" , bd .DevPath , err )
122- return err
120+
121+ if features .FeatureGates .IsEnabled (features .PartitionTableUUID ) {
122+ klog .Infof ("starting to create partition table on device: %s" , bd .DevPath )
123+ if err := d .CreatePartitionTable (); err != nil {
124+ klog .Errorf ("error create partition table for %s, %v" , bd .DevPath , err )
125+ return err
126+ }
127+ klog .Infof ("created new partition table in %s" , bd .DevPath )
128+ return ErrNeedRescan
129+ } else {
130+ klog .Infof ("starting to create partition on device: %s" , bd .DevPath )
131+ if err := d .CreateSinglePartition (); err != nil {
132+ klog .Errorf ("error creating partition for %s, %v" , bd .DevPath , err )
133+ return err
134+ }
135+ klog .Infof ("created new partition in %s" , bd .DevPath )
136+ return nil
123137 }
124- klog .Infof ("created new partition in %s" , bd .DevPath )
125- return nil
126138 }
127139 } else {
128140 bd .UUID = uuid
0 commit comments