Skip to content

Commit

Permalink
Merge pull request #82 from wnxn/remove-csi-common
Browse files Browse the repository at this point in the history
refactor code struct and remove csi-common
  • Loading branch information
Wiley Wang authored Jul 17, 2019
2 parents c4eb096 + 2454248 commit 40db967
Show file tree
Hide file tree
Showing 39 changed files with 1,689 additions and 4,000 deletions.
13 changes: 4 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
name = "k8s.io/kubernetes"
version = "1.14.1"

[[constraint]]
name = "github.com/kubernetes-csi/drivers"
version = "1.0.2"

[[constraint]]
name = "github.com/container-storage-interface/spec"
version = "1.1.0"
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DISK_IMAGE_NAME=dockerhub.qingcloud.com/csiplugin/csi-qingcloud
DISK_IMAGE_VERSION=canary
DISK_PLUGIN_NAME=qingcloud-disk-csi-driver
ROOT_PATH=$(pwd)
PACKAGE_LIST=./cmd/disk ./pkg/disk ./pkg/server ./pkg/server/instance ./pkg/server/volume ./pkg/server/zone
PACKAGE_LIST=./cmd/... ./pkg/...

disk:
if [ ! -d ./vendor ]; then dep ensure; fi
Expand Down Expand Up @@ -54,12 +54,12 @@ fmt:
go fmt ${PACKAGE_LIST}

fmt-deep: fmt
gofmt -s -w -l ${PACKAGE_LIST}
gofmt -s -w -l ./pkg/cloudprovider/ ./pkg/common/ ./pkg/disk/driver ./pkg/disk/rpcserver

sanity-test:
${ROOT_PATH}/csi-sanity --csi.endpoint /var/lib/kubelet/plugins/disk.csi.qingcloud.com/csi.sock --csi.testvolumesize 107374182400

clean:
go clean -r -x
rm -rf ./_output
rm -rf deploy/disk/docker/${DISK_PLUGIN_NAME}
rm -rf deploy/disk/docker/${DISK_PLUGIN_NAME}
55 changes: 47 additions & 8 deletions cmd/disk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ package main

import (
"flag"
"github.com/yunify/qingcloud-csi/pkg/disk"
"github.com/yunify/qingcloud-csi/pkg/server"
"github.com/golang/glog"
"github.com/yunify/qingcloud-csi/pkg/cloudprovider"
"github.com/yunify/qingcloud-csi/pkg/disk/driver"
"github.com/yunify/qingcloud-csi/pkg/disk/rpcserver"
"os"
"time"
)

const (
version = "v1.1.0"
defaultProvisionName = "disk.csi.qingcloud.com"
defaultConfigPath = "/etc/config/config.yaml"
)

func init() {
Expand All @@ -29,11 +38,13 @@ func init() {

var (
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
driverName = flag.String("drivername", "csi-qingcloud", "name of the driver")
nodeID = flag.String("nodeid", "", "node id")
config = flag.String("config", "/etc/config/config.yaml", "server config file path")
driverName = flag.String("drivername", defaultProvisionName, "name of the driver")
nodeId = flag.String("nodeid", "",
"If driver cannot get instance ID from /etc/qingcloud/instance-id, we would use this flag.")
configPath = flag.String("config", defaultConfigPath, "server config file path")
maxVolume = flag.Int64("maxvolume", 10,
"Maximum number of volumes that controller can publish to the node.")
timeout = flag.Duration("timeout", time.Second*60, "timeout duration for retrying, default 60s")
)

func main() {
Expand All @@ -43,7 +54,35 @@ func main() {
}

func handle() {
cloud := server.NewServerConfig(*nodeID, *config, *maxVolume)
driver := disk.GetDiskDriver()
driver.Run(*driverName, *nodeID, *endpoint, cloud)
// Get Instance Id
instanceId, err := driver.GetInstanceIdFromFile(driver.DefaultInstanceIdFilePath)
if err != nil {
glog.Warningf("Failed to get instance id from file, use --nodeId flag. error: %s", err)
instanceId = *nodeId
}
// Get qingcloud config object
cfg, err := cloudprovider.ReadConfigFromFile(*configPath)
if err != nil {
glog.Fatal(err)
}
cloud, err := cloudprovider.NewCloudManager(cfg)
if err != nil {
glog.Fatal(err)
}

// Set DiskDriverInput
diskDriverInput := &driver.InitDiskDriverInput{
Name: *driverName,
Version: version,
NodeId: instanceId,
MaxVolume: *maxVolume,
VolumeCap: driver.DefaultVolumeAccessModeType,
ControllerCap: driver.DefaultControllerServiceCapability,
NodeCap: driver.DefaultNodeServiceCapability,
PluginCap: driver.DefaultPluginCapability,
}

driver := driver.GetDiskDriver()
driver.InitDiskDriver(diskDriverInput)
rpcserver.Run(driver, cloud, *endpoint)
}
6 changes: 0 additions & 6 deletions deploy/disk/kubernetes/base/node-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ spec:
- name: server-config
mountPath: /etc/config
volumes:
# make sure mount propagate feature gate is enabled
- name: kubelet-dir
hostPath:
# In AppCenter, must set path field as below.
# path: /data/var/lib/kubelet
path: /var/lib/kubelet
- name: socket-dir
hostPath:
path: /var/lib/kubelet/plugins/disk.csi.qingcloud.com/
Expand Down
Loading

0 comments on commit 40db967

Please sign in to comment.