From c79fd595be5ba120a211ab430c7bfb6b9d58ed67 Mon Sep 17 00:00:00 2001 From: Pravin Ranjan Date: Mon, 13 Sep 2021 03:30:16 -0400 Subject: [PATCH 1/4] Adding Probe support --- src/csi/driver/identity.go | 18 ++++++++++++++++-- src/csi/main.go | 6 +++++- src/utils/utils.go | 17 +++++++++++++---- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/csi/driver/identity.go b/src/csi/driver/identity.go index b6868e09..7746d128 100644 --- a/src/csi/driver/identity.go +++ b/src/csi/driver/identity.go @@ -2,9 +2,12 @@ package driver import ( "context" + "fmt" + "utils" "utils/log" "github.com/container-storage-interface/spec/lib/go/csi" + "github.com/golang/protobuf/ptypes/wrappers" ) func (d *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { @@ -32,6 +35,17 @@ func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCa } func (d *Driver) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { - log.Infof("Probe plugin %v", *d) - return &csi.ProbeResponse{}, nil + + log.Infof("Probe the csi-driver plugin %v", *d) + bootstrap := utils.GetBootStrap() + + if !bootstrap { + return &csi.ProbeResponse{}, fmt.Errorf("Bootstarp is false") + } + resp := &csi.ProbeResponse{ + Ready: &wrappers.BoolValue{Value: bootstrap}, + } + + return resp, nil + } diff --git a/src/csi/main.go b/src/csi/main.go index 4cd9a617..16ad557d 100644 --- a/src/csi/main.go +++ b/src/csi/main.go @@ -64,7 +64,7 @@ type CSIConfig struct { } type CSISecret struct { - Secrets map[string]interface{} `json:"secrets"` + Secrets map[string]interface{} `json:"secrets"` } func init() { @@ -208,6 +208,10 @@ func main() { csi.RegisterNodeServer(server, d) log.Infof("Starting Huawei CSI driver, listening on %s", *endpoint) + + // set the bootstarp value as true bcz here csi driver would be ready + utils.SetBootStrap(true) + if err := server.Serve(listener); err != nil { log.Fatalf("Start Huawei CSI driver error: %v", err) } diff --git a/src/utils/utils.go b/src/utils/utils.go index 265fe361..e03680b3 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -38,15 +38,24 @@ const ( V5Version = "V500" ) +var bootstrap bool var maskObject = []string{"user", "password", "iqn", "tgt", "tgtname", "initiatorname"} type VolumeMetrics struct { - Available *resource.Quantity - Capacity *resource.Quantity + Available *resource.Quantity + Capacity *resource.Quantity InodesUsed *resource.Quantity - Inodes *resource.Quantity + Inodes *resource.Quantity InodesFree *resource.Quantity - Used *resource.Quantity + Used *resource.Quantity +} + +func GetBootStrap() bool { + return bootstrap +} + +func SetBootStrap(value bool) { + bootstrap = value } func PathExist(path string) (bool, error) { From b112211876b369e37f62103ad7a7ceff2c4d8f91 Mon Sep 17 00:00:00 2001 From: Pravin Ranjan Date: Mon, 13 Sep 2021 07:46:24 -0400 Subject: [PATCH 2/4] adding yaml file for deployment --- yamls/deploy/huawei-csi-controller-probe.yaml | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 yamls/deploy/huawei-csi-controller-probe.yaml diff --git a/yamls/deploy/huawei-csi-controller-probe.yaml b/yamls/deploy/huawei-csi-controller-probe.yaml new file mode 100644 index 00000000..d5122ff5 --- /dev/null +++ b/yamls/deploy/huawei-csi-controller-probe.yaml @@ -0,0 +1,99 @@ +--- +kind: Deployment +apiVersion: apps/v1 +metadata: + name: huawei-csi-controller + namespace: kube-system +spec: + replicas: 1 + selector: + matchLabels: + app: huawei-csi-controller + template: + metadata: + labels: + app: huawei-csi-controller + spec: + serviceAccount: huawei-csi-controller + hostNetwork: true + containers: + - name: liveness-probe + image: quay.io/k8scsi/livenessprobe:v1.1.0 + args: + - --csi-address=/var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "IfNotPresent" + volumeMounts: + - mountPath: /var/lib/csi/sockets/pluginproxy/ + name: socket-dir + + - name: csi-provisioner + image: quay.io/k8scsi/csi-provisioner:v1.6.0 + args: + - "--csi-address=$(ADDRESS)" + - "--timeout=6h" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "IfNotPresent" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + + - name: csi-attacher + image: quay.io/k8scsi/csi-attacher:v1.2.1 + args: + - "--csi-address=$(ADDRESS)" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "IfNotPresent" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + + - name: huawei-csi-driver + image: huawei-csi:pravin-test + args: + - "--endpoint=$(CSI_ENDPOINT)" + - "--controller" + - "--containerized" + - "--driver-name=csi.huawei.com" + env: + - name: CSI_ENDPOINT + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "IfNotPresent" + ports: + - containerPort: 9808 + name: healthz + protocol: TCP + # The probe + livenessProbe: + failureThreshold: 5 + httpGet: + path: /healthz + port: healthz + initialDelaySeconds: 10 + timeoutSeconds: 3 + periodSeconds: 10 + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: log + mountPath: /var/log + - name: config-map + mountPath: /etc/huawei + - name: secret + mountPath: /etc/huawei/secret + volumes: + - name: socket-dir + emptyDir: + - name: log + hostPath: + path: /var/log/ + type: Directory + - name: config-map + configMap: + name: huawei-csi-configmap + - name: secret + secret: + secretName: huawei-csi-secret From d1b62ecfedb1c96ba4c61d7143896305518c5326 Mon Sep 17 00:00:00 2001 From: Pravin Ranjan Date: Mon, 13 Sep 2021 07:56:51 -0400 Subject: [PATCH 3/4] adding yaml file for deployment --- yamls/deploy/huawei-csi-controller-probe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yamls/deploy/huawei-csi-controller-probe.yaml b/yamls/deploy/huawei-csi-controller-probe.yaml index d5122ff5..a14f4912 100644 --- a/yamls/deploy/huawei-csi-controller-probe.yaml +++ b/yamls/deploy/huawei-csi-controller-probe.yaml @@ -52,7 +52,7 @@ spec: mountPath: /var/lib/csi/sockets/pluginproxy/ - name: huawei-csi-driver - image: huawei-csi:pravin-test + image: huawei-csi:*.*.* args: - "--endpoint=$(CSI_ENDPOINT)" - "--controller" From 94c0788737212cec27b7f714c9f09a0cde6b5682 Mon Sep 17 00:00:00 2001 From: Pravin Ranjan Date: Mon, 13 Sep 2021 21:07:21 -0400 Subject: [PATCH 4/4] liveness probe update version --- yamls/deploy/huawei-csi-controller-probe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yamls/deploy/huawei-csi-controller-probe.yaml b/yamls/deploy/huawei-csi-controller-probe.yaml index a14f4912..3e1ab0a7 100644 --- a/yamls/deploy/huawei-csi-controller-probe.yaml +++ b/yamls/deploy/huawei-csi-controller-probe.yaml @@ -18,7 +18,7 @@ spec: hostNetwork: true containers: - name: liveness-probe - image: quay.io/k8scsi/livenessprobe:v1.1.0 + image: k8s.gcr.io/sig-storage/livenessprobe:v2.4.0 args: - --csi-address=/var/lib/csi/sockets/pluginproxy/csi.sock imagePullPolicy: "IfNotPresent"