Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin/feature/v0.9.1 fixd vgroup #40

Merged
merged 6 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions charts/templates/csi-config-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ data:
"diskSelector": [
{
"name": "hdd1" ,
"re": ["sdb","vdb"],
"re": ["vdb"],
"policy": "LVM",
"nodeLabel": "kubernetes.io/hostname"
},
{
"name": "hdd2",
"re": ["sdc","vdc"],
"re": ["vdc"],
"policy": "LVM",
"nodeLabel": "kubernetes.io/hostname"
},
{
"name": "ssd",
"re": ["loop*", "vd*"],
"name": "ssd1",
"re": ["loop*","vdd1"],
"policy": "RAW",
"nodeLabel": "kubernetes.io/hostname"
},
{
"name": "ssd",
"re": ["loop*", "vd*"],
"name": "ssd2",
"re": ["vdd2"],
"policy": "RAW",
"nodeLabel": "kubernetes.io/hostname"
}
Expand Down
9 changes: 0 additions & 9 deletions e2e/kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,5 @@ kind: Cluster
nodes:
- role: control-plane
- role: worker
extraMounts:
- containerPath: /dev
hostPath: /dev
- role: worker
extraMounts:
- containerPath: /dev
hostPath: /dev
- role: worker
extraMounts:
- containerPath: /dev
hostPath: /dev
2 changes: 1 addition & 1 deletion examples/kubernetes/deploymentspeedlimit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 17Gi
storage: 100Mi
storageClassName: csi-carina-sc
volumeMode: Filesystem
2 changes: 1 addition & 1 deletion examples/kubernetes/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 7Gi
storage: 100Mi
storageClassName: csi-carina-sc
volumeMode: Filesystem
16 changes: 15 additions & 1 deletion pkg/configuration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
configPath = "/etc/carina/"
SchedulerBinpack = "binpack"
Schedulerspreadout = "spreadout"
diskGroupType = "type"
)

var TestAssistDiskSelector []string
Expand Down Expand Up @@ -145,7 +146,20 @@ func NewDiskClass(diskSelectors []DiskSelectorItem) *DiskClass {
return &disk
}

// DiskSelector 支持正则表达式
func (disk *Disk) GetDiskGroups() (vgs []string) {
for _, d := range disk.DiskSelectors {
if d.Policy == "RAW" {
continue
}
if !utils.ContainsString(vgs, d.Name) {
vgs = append(vgs, d.Name)
}
}

return vgs
}

// 支持正则表达式
// 定时扫描本地磁盘,凡是匹配的将被加入到相应vg卷组
// 对于此配置的修改需要非常慎重,如果更改匹配条件,可能会移除正在使用的磁盘
func DiskSelector() []DiskSelectorItem {
Expand Down
29 changes: 22 additions & 7 deletions pkg/csidriver/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@ package driver
import (
"context"
"errors"
"io"
"os"
"path"
"path/filepath"
"strings"
"sync"

"github.com/carina-io/carina/pkg/configuration"
"github.com/carina-io/carina/pkg/csidriver/csi"
"github.com/carina-io/carina/pkg/csidriver/driver/k8s"
"github.com/carina-io/carina/pkg/csidriver/filesystem"
"github.com/carina-io/carina/pkg/devicemanager/types"
"github.com/carina-io/carina/pkg/devicemanager/volume"
"github.com/carina-io/carina/utils"
"github.com/carina-io/carina/utils/log"
"io"
"os"
"path"
"path/filepath"
"strings"
"sync"

"golang.org/x/sys/unix"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -605,8 +607,21 @@ func (s *nodeService) getLvFromContext(deviceGroup, volumeID string) (*types.LvI
}

func (s *nodeService) getBcacheDevice(volumeID string) (*types.BcacheDeviceInfo, error) {
diskClass := configuration.DiskConfig.GetDiskGroups()
vgs, err := s.volumeManager.GetCurrentVgStruct()
if err != nil {
return nil, err
}
if len(vgs) > 0 {
for _, v := range vgs {
if utils.ContainsString([]string{utils.DeviceVGHDD, utils.DeviceVGSSD}, v.VGName) && !utils.ContainsString(diskClass,v.VGName){
diskClass = append(diskClass, v.VGName)
}

}
}

for _, d := range []string{utils.DeviceVGHDD, utils.DeviceVGSSD} {
for _, d := range diskClass {
devicePath := filepath.Join("/dev", d, volumeID)
_, err := os.Stat(devicePath)
if err == nil {
Expand Down
17 changes: 15 additions & 2 deletions pkg/deviceplugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package deviceplugin

import (
"os"

"github.com/carina-io/carina/pkg/configuration"
"github.com/carina-io/carina/pkg/devicemanager/volume"
"github.com/carina-io/carina/pkg/deviceplugin/v1beta1"
"github.com/carina-io/carina/utils"
"github.com/carina-io/carina/utils/log"
"github.com/fsnotify/fsnotify"
"os"
// 依赖冲突,把整个proto目录挪移过来
//pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
)
Expand All @@ -43,7 +45,17 @@ restart:
}

log.Info("Retreiving plugins.")
for _, d := range []string{utils.DeviceVGSSD, utils.DeviceVGHDD} {
diskClass := configuration.DiskConfig.GetDiskGroups()
vgs, _ := volumeManager.GetCurrentVgStruct()
if len(vgs) > 0 {
for _, v := range vgs {
if utils.ContainsString([]string{utils.DeviceVGHDD, utils.DeviceVGSSD}, v.VGName) && !utils.ContainsString(diskClass, v.VGName) {
diskClass = append(diskClass, v.VGName)
}

}
}
for _, d := range diskClass {
c := make(chan struct{}, 5)
plugins = append(plugins, NewCarinaDevicePlugin(
utils.DeviceCapacityKeyPrefix+d,
Expand All @@ -66,6 +78,7 @@ restart:
}
started++
}

if started == 0 {
log.Info("No devices found, Waiting indefinitely.")
}
Expand Down
2 changes: 1 addition & 1 deletion skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ deploy:
chartPath: ./charts
setValues:
image.carina.repository: registry.cn-hangzhou.aliyuncs.com/antmoveh/carina
image.carina.tag: v0.9.0-45-g2674233-dirty
image.carina.tag: v0.9.0-70-gfa3f605-dirty
image.carina.pullPolicy: Always
imageStrategy:
helm:
Expand Down