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

Liveness Probe for csi driver #41

Open
wants to merge 4 commits into
base: developing
Choose a base branch
from
Open
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
18 changes: 16 additions & 2 deletions src/csi/driver/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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

}
6 changes: 5 additions & 1 deletion src/csi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type CSIConfig struct {
}

type CSISecret struct {
Secrets map[string]interface{} `json:"secrets"`
Secrets map[string]interface{} `json:"secrets"`
}

func init() {
Expand Down Expand Up @@ -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)
}
Expand Down
17 changes: 13 additions & 4 deletions src/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
99 changes: 99 additions & 0 deletions yamls/deploy/huawei-csi-controller-probe.yaml
Original file line number Diff line number Diff line change
@@ -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: k8s.gcr.io/sig-storage/livenessprobe:v2.4.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:*.*.*
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