Skip to content

Commit 7fb01c4

Browse files
derekbitshuo-wu
authored andcommitted
crd: introduce disk driver in node.spec.diskSpec
Longhorn 7672 Signed-off-by: Derek Su <[email protected]>
1 parent d2aac8e commit 7fb01c4

File tree

7 files changed

+37
-0
lines changed

7 files changed

+37
-0
lines changed

controller/controller_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ func newNode(name, namespace string, allowScheduling bool, status longhorn.Condi
519519
TestDiskID1: {
520520
Type: longhorn.DiskTypeFilesystem,
521521
Path: TestDefaultDataPath,
522+
DiskDriver: longhorn.DiskDriverNone,
522523
AllowScheduling: true,
523524
StorageReserved: 0,
524525
},

controller/independent_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ func (s *TestSuite) TestBackingImageCleanup(c *C) {
2424
TestDiskID1: {
2525
Type: longhorn.DiskTypeFilesystem,
2626
Path: TestDefaultDataPath + "1",
27+
DiskDriver: longhorn.DiskDriverNone,
2728
AllowScheduling: true,
2829
},
2930
TestDiskID2: {
3031
Type: longhorn.DiskTypeFilesystem,
3132
Path: TestDefaultDataPath + "2",
33+
DiskDriver: longhorn.DiskDriverNone,
3234
AllowScheduling: true,
3335
},
3436
TestDiskID3: {
3537
Type: longhorn.DiskTypeFilesystem,
3638
Path: TestDefaultDataPath + "3",
39+
DiskDriver: longhorn.DiskDriverNone,
3740
AllowScheduling: true,
3841
},
3942
},

controller/node_controller_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ func (s *NodeControllerSuite) TestDisableDiskOnFilesystemChange(c *C) {
747747
TestDiskID1: {
748748
Type: longhorn.DiskTypeFilesystem,
749749
Path: TestDefaultDataPath,
750+
DiskDriver: longhorn.DiskDriverNone,
750751
AllowScheduling: true,
751752
StorageReserved: 0,
752753
},

k8s/crds.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,12 @@ spec:
21232123
properties:
21242124
allowScheduling:
21252125
type: boolean
2126+
diskDriver:
2127+
enum:
2128+
- ""
2129+
- auto
2130+
- aio
2131+
type: string
21262132
diskType:
21272133
enum:
21282134
- filesystem
@@ -2208,6 +2214,12 @@ spec:
22082214
type: object
22092215
nullable: true
22102216
type: array
2217+
diskDriver:
2218+
type: string
2219+
diskName:
2220+
type: string
2221+
diskPath:
2222+
type: string
22112223
diskType:
22122224
type: string
22132225
diskUUID:

k8s/pkg/apis/longhorn/v1beta2/node.go

+17
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ const (
5555
DiskTypeBlock = DiskType("block")
5656
)
5757

58+
type DiskDriver string
59+
60+
const (
61+
DiskDriverNone = DiskDriver("")
62+
DiskDriverAuto = DiskDriver("auto")
63+
DiskDriverAio = DiskDriver("aio")
64+
)
65+
5866
type SnapshotCheckStatus struct {
5967
// +optional
6068
LastPeriodicCheckedAt metav1.Time `json:"lastPeriodicCheckedAt"`
@@ -66,6 +74,9 @@ type DiskSpec struct {
6674
Type DiskType `json:"diskType"`
6775
// +optional
6876
Path string `json:"path"`
77+
// +kubebuilder:validation:Enum="";auto;aio
78+
// +optional
79+
DiskDriver DiskDriver `json:"diskDriver"`
6980
// +optional
7081
AllowScheduling bool `json:"allowScheduling"`
7182
// +optional
@@ -92,8 +103,14 @@ type DiskStatus struct {
92103
// +optional
93104
DiskUUID string `json:"diskUUID"`
94105
// +optional
106+
DiskName string `json:"diskName"`
107+
// +optional
108+
DiskPath string `json:"diskPath"`
109+
// +optional
95110
Type DiskType `json:"diskType"`
96111
// +optional
112+
DiskDriver DiskDriver `json:"diskDriver"`
113+
// +optional
97114
FSType string `json:"filesystemType"`
98115
}
99116

scheduler/replica_scheduler_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ func newDisk(path string, allowScheduling bool, storageReserved int64) longhorn.
159159
return longhorn.DiskSpec{
160160
Type: longhorn.DiskTypeFilesystem,
161161
Path: path,
162+
DiskDriver: longhorn.DiskDriverNone,
162163
AllowScheduling: allowScheduling,
163164
StorageReserved: storageReserved,
164165
}

types/types.go

+2
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ func CreateDefaultDisk(dataPath string, storageReservedPercentage int64) (map[st
999999
DefaultDiskPrefix + util.RandomID(): {
10001000
Type: longhorn.DiskTypeBlock,
10011001
Path: dataPath,
1002+
DiskDriver: longhorn.DiskDriverAuto,
10021003
AllowScheduling: true,
10031004
EvictionRequested: false,
10041005
StorageReserved: 0,
@@ -1021,6 +1022,7 @@ func CreateDefaultDisk(dataPath string, storageReservedPercentage int64) (map[st
10211022
DefaultDiskPrefix + diskStat.DiskID: {
10221023
Type: longhorn.DiskTypeFilesystem,
10231024
Path: diskStat.Path,
1025+
DiskDriver: longhorn.DiskDriverNone,
10241026
AllowScheduling: true,
10251027
EvictionRequested: false,
10261028
StorageReserved: diskStat.StorageMaximum * storageReservedPercentage / 100,

0 commit comments

Comments
 (0)