Merge remote-tracking branch 'origin/zfssa-5-canary' into update-csi-1.8.0

This commit is contained in:
Paul Monday 2023-05-05 11:20:46 -06:00
commit e3a2e0d0b0
14 changed files with 1706 additions and 87 deletions

View File

@ -5,18 +5,18 @@ as a backend for block storage (iSCSI volumes) and file storage (NFS).
| CSI Plugin Version | Supported CSI Versions | Supported Kubernetes Versions | Persistence | Supported Access Modes | Dynamic Provisioning | Raw Block Support |
| --- | --- | --- | --- | --- | --- | --- |
| v1.0.0 | v1.0+ | v1.17.X+ | Persistent | Read/Write Once (for Block), ReadWriteMany (for File) | Yes | Yes |
| v1.1.0 | v1.0+ | v1.20.X+ | Persistent | Read/Write Once (for Block), ReadWriteMany (for File) | Yes | Yes |
## Requirements
* Kubernetes v1.17 or above.
* A Container runtime implementing the Kubernetes Container Runtime Interface. This plugin was tested with CRI-O v1.17.
* Kubernetes v1.20 or above (Oracle Linux Cloud Native Environment 1.3)
* A Container runtime implementing the Kubernetes Container Runtime Interface (ex. CRI-O)
* An Oracle ZFS Storage Appliance running Appliance Kit Version 8.8 or above. This plugin may work with previous
versions but it is not tested with them. It is possible to use this
driver with the [Oracle ZFS Storage Simulator](https://www.oracle.com/downloads/server-storage/sun-unified-storage-sun-simulator-downloads.html)
* Access to both a management path and a data path for the target Oracle
ZFS Storage Appiance (or simulator). The management and data path
can be the same address.
ZFS Storage Appiance (or simulator). The management and data path
can be the same address.
* A suitable container image build environment (podman or docker are accounted
for in the makefile)

View File

@ -1 +1 @@
1.0.0
1.1.0

View File

@ -0,0 +1,4 @@
apiVersion: v1
name: zfssa-csi
version: 1.1.0
description: Deploys Oracle ZFS Storage Appliance CSI Plugin.

View File

@ -0,0 +1,9 @@
apiVersion: v1
stringData:
zfssa.yaml: |
username: {{ .Values.zfssaInformation.username }}
password: {{ .Values.zfssaInformation.password }}
kind: Secret
metadata:
name: oracle.zfssa.csi.node
namespace: {{ .Values.deployment.namespace }}

View File

@ -0,0 +1,8 @@
apiVersion: v1
data:
zfssa.crt: {{ .Values.zfssaInformation.cert }}
kind: Secret
metadata:
name: oracle.zfssa.csi.node.certs
type: Opaque

View File

@ -0,0 +1,84 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: zfssa-csi
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: zfssa-csi-role
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update", "create", "delete", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments/status"]
verbs: ["patch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["patch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch", "delete", "get"]
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csinodeinfos"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "list", "watch", "create", "update"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["create", "get", "list", "watch", "update", "delete"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: [ "snapshot.storage.k8s.io" ]
resources: [ "volumesnapshotcontents/status" ]
verbs: [ "update" ]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["create", "list", "watch", "delete"]
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csidrivers"]
verbs: ["create", "delete"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "create", "update"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: zfssa-csi-role-binding
subjects:
- kind: ServiceAccount
name: zfssa-csi
namespace: {{ .Values.deployment.namespace }}
roleRef:
kind: ClusterRole
name: zfssa-csi-role
apiGroup: rbac.authorization.k8s.io

View File

@ -0,0 +1,139 @@
# Service defined here, plus serviceName below in StatefulSet,
# are needed only because of condition explained in
# https://github.com/kubernetes/kubernetes/issues/69608
---
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: zfssa-csi-driver
namespace: {{ .Values.deployment.namespace }}
spec:
attachRequired: true
podInfoOnMount: true
volumeLifecycleModes:
- Persistent
---
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: zfssa-csi-nodeplugin
namespace: {{ .Values.deployment.namespace }}
spec:
selector:
matchLabels:
app: zfssa-csi-nodeplugin
template:
metadata:
labels:
app: zfssa-csi-nodeplugin
spec:
serviceAccount: zfssa-csi
hostNetwork: true
containers:
- name: node-driver-registrar
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiNodeDriverRegistrar.name }}:{{ .Values.images.csiNodeDriverRegistrar.tag }}
args:
- --v=5
- --csi-address=/plugin/csi.sock
- --kubelet-registration-path=/var/lib/kubelet/plugins/com.oracle.zfssabs/csi.sock
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
# This is necessary only for systems with SELinux, where
# non-privileged sidecar containers cannot access unix domain socket
# created by privileged CSI driver container.
privileged: true
env:
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
volumeMounts:
- name: socket-dir
mountPath: {{ .Values.paths.pluginDir.mountPath }}
- name: registration-dir
mountPath: /registration
- name: zfssabs
image: {{ .Values.image.zfssaBase }}{{ .Values.images.zfssaCsiDriver.name }}:{{ .Values.images.zfssaCsiDriver.tag }}
args:
- "--drivername=zfssa-csi-driver.oracle.com"
- "--v=5"
- "--endpoint=$(CSI_ENDPOINT)"
- "--nodeid=$(NODE_NAME)"
env:
- name: CSI_ENDPOINT
value: unix://plugin/csi.sock
- name: LOG_LEVEL
value: "5"
- name: ZFSSA_TARGET
value: {{ .Values.zfssaInformation.target }}
- name: ZFSSA_INSECURE
value: "False"
- name: NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
privileged: true
volumeMounts:
- name: socket-dir
mountPath: {{ .Values.paths.pluginDir.mountPath }}
- name: mountpoint-dir
mountPath: /var/lib/kubelet/pods
mountPropagation: Bidirectional
- name: plugins-dir
mountPath: /var/lib/kubelet/plugins
mountPropagation: Bidirectional
- name: dev-dir
mountPath: /dev
- name: zfssa-credentials
mountPath: "/mnt/zfssa"
readOnly: true
- name: certs
mountPath: "/mnt/certs"
readOnly: true
volumes:
- name: socket-dir
hostPath:
path: {{ .Values.paths.pluginDir.hostPath }}
type: DirectoryOrCreate
- name: mountpoint-dir
hostPath:
path: /var/lib/kubelet/pods
type: DirectoryOrCreate
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry
type: Directory
- name: plugins-dir
hostPath:
path: /var/lib/kubelet/plugins
type: Directory
- name: dev-dir
hostPath:
path: /dev
type: Directory
- name: zfssa-credentials
secret:
secretName: oracle.zfssa.csi.node
items:
- key: zfssa.yaml
path: zfssa.yaml
- name: certs
secret:
secretName: oracle.zfssa.csi.node.certs
items:
- key: zfssa.crt
path: zfssa.crt

View File

@ -0,0 +1,90 @@
---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: zfssa-csi-provisioner
namespace: {{ .Values.deployment.namespace }}
spec:
serviceName: "zfssa-csi-provisioner"
replicas: 1
selector:
matchLabels:
app: zfssa-csi-provisioner
template:
metadata:
labels:
app: zfssa-csi-provisioner
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- zfssa-csi-nodeplugin
topologyKey: kubernetes.io/hostname
serviceAccountName: zfssa-csi
containers:
- name: zfssa-csi-snapshotter
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiSnapshotter.name }}:{{ .Values.images.csiSnapshotter.tag }}
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--leader-election=false"
env:
- name: ADDRESS
value: /plugin/csi.sock
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: socket-dir
mountPath: /plugin
- name: zfssa-csi-resizer
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiResizer.name }}:{{ .Values.images.csiResizer.tag }}
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--leader-election"
env:
- name: ADDRESS
value: /plugin/csi.sock
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: socket-dir
mountPath: /plugin
- name: zfssa-csi-provisioner
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiProvisioner.name }}:{{ .Values.images.csiProvisioner.tag }}
args:
- -v=5
- --csi-address=/plugin/csi.sock
- --timeout=30s
- --feature-gates=Topology=true
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
# This is necessary only for systems with SELinux, where
# non-privileged sidecar containers cannot access unix domain socket
# created by privileged CSI driver container.
privileged: true
volumeMounts:
- name: socket-dir
mountPath: /plugin
- name: zfssa-csi-attacher
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiAttacher.name }}:{{ .Values.images.csiAttacher.tag }}
args:
- --v=5
- --csi-address=/plugin/csi.sock
# securityContext:
# This is necessary only for systems with SELinux, where
# non-privileged sidecar containers cannot access unix domain socket
# created by privileged CSI driver container.
# privileged: true
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: socket-dir
mountPath: {{ .Values.paths.pluginDir.mountPath }}
volumes:
- name: socket-dir
hostPath:
path: {{ .Values.paths.pluginDir.hostPath }}
type: DirectoryOrCreate

View File

@ -0,0 +1,42 @@
# Global docker image setting
image:
sidecarBase: k8s.gcr.io/sig-storage/
zfssaBase: iad.ocir.io/zs/store/csi/
pullPolicy: Always
# Define all the images that will be used during helm chart deployment
images:
csiNodeDriverRegistrar:
name: csi-node-driver-registrar
tag: "v2.0.0"
zfssaCsiDriver:
name: zfssa-csi-driver
tag: "v1.1.0"
csiProvisioner:
name: csi-provisioner
tag: "v2.0.5"
csiAttacher:
name: csi-attacher
tag: "v3.0.2"
csiResizer:
name: csi-resizer
tag: "v1.1.0"
csiSnapshotter:
name: csi-snapshotter
tag: "v3.0.3"
paths:
pluginDir:
hostPath: "/var/lib/kubelet/plugins/com.oracle.zfssabs"
mountPath: "/plugin"
deployment:
namespace: default
# ZFSSA-specific information
# It is desirable to provision a normal login user with required authorizations.
zfssaInformation:
username: text-string
password: text-string
target: text-string
cert: cert-base64-encoded

139
go.mod
View File

@ -1,53 +1,100 @@
module github.com/oracle/zfssa-csi-driver
go 1.13
require (
github.com/container-storage-interface/spec v1.2.0
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/golang/protobuf v1.4.0
github.com/kubernetes-csi/csi-lib-iscsi v0.0.0-20190415173011-c545557492f4
github.com/kubernetes-csi/csi-lib-utils v0.6.1
github.com/onsi/gomega v1.9.0 // indirect
github.com/prometheus/client_golang v1.2.1 // indirect
golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae // indirect
google.golang.org/grpc v1.23.1
gopkg.in/yaml.v2 v2.2.8
k8s.io/apimachinery v0.17.11
k8s.io/client-go v0.18.2
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.17.5
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f
)
go 1.17
replace (
k8s.io/api => k8s.io/api v0.17.5
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.17.5
k8s.io/apimachinery => k8s.io/apimachinery v0.17.6-beta.0
k8s.io/apiserver => k8s.io/apiserver v0.17.5
k8s.io/cli-runtime => k8s.io/cli-runtime v0.17.5
k8s.io/client-go => k8s.io/client-go v0.17.5
k8s.io/cloud-provider => k8s.io/cloud-provider v0.17.5
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.17.5
k8s.io/code-generator => k8s.io/code-generator v0.17.6-beta.0
k8s.io/component-base => k8s.io/component-base v0.17.5
k8s.io/cri-api => k8s.io/cri-api v0.17.13-rc.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.17.5
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.17.5
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.17.5
k8s.io/kube-proxy => k8s.io/kube-proxy v0.17.5
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.17.5
k8s.io/kubelet => k8s.io/kubelet v0.17.5
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.17.5
k8s.io/metrics => k8s.io/metrics v0.17.5
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.17.5
k8s.io/api => k8s.io/api v0.24.3
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.3
k8s.io/apimachinery => k8s.io/apimachinery v0.24.3
k8s.io/apiserver => k8s.io/apiserver v0.24.3
k8s.io/cli-runtime => k8s.io/cli-runtime v0.24.3
k8s.io/client-go => k8s.io/client-go v0.24.3
k8s.io/cloud-provider => k8s.io/cloud-provider v0.24.3
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.24.3
k8s.io/code-generator => k8s.io/code-generator v0.24.3
k8s.io/component-base => k8s.io/component-base v0.24.3
k8s.io/component-helpers => k8s.io/component-helpers v0.24.3
k8s.io/controller-manager => k8s.io/controller-manager v0.24.3
k8s.io/cri-api => k8s.io/cri-api v0.24.3
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.24.3
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.24.3
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.24.3
k8s.io/kube-proxy => k8s.io/kube-proxy v0.24.3
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.24.3
k8s.io/kubectl => k8s.io/kubectl v0.24.3
k8s.io/kubelet => k8s.io/kubelet v0.24.3
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.24.3
k8s.io/metrics => k8s.io/metrics v0.24.3
k8s.io/mount-utils => k8s.io/mount-utils v0.24.3
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.24.3
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.24.3
)
replace k8s.io/kubectl => k8s.io/kubectl v0.17.5
require (
github.com/container-storage-interface/spec v1.6.0
github.com/golang/protobuf v1.5.2
github.com/kubernetes-csi/csi-lib-iscsi v0.0.0-20220106022228-366f3190694e
github.com/kubernetes-csi/csi-lib-utils v0.11.0
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
google.golang.org/grpc v1.40.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.24.3
k8s.io/client-go v0.24.3
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.24.3
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
)
replace k8s.io/node-api => k8s.io/node-api v0.17.5
replace k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.17.5
replace k8s.io/sample-controller => k8s.io/sample-controller v0.17.5
require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/selinux v1.10.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.24.3 // indirect
k8s.io/apiserver v0.24.3 // indirect
k8s.io/cloud-provider v0.24.3 // indirect
k8s.io/component-base v0.24.3 // indirect
k8s.io/component-helpers v0.24.3 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/mount-utils v0.24.3 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

1186
go.sum Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ package service
import (
"errors"
"fmt"
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
@ -39,13 +40,16 @@ func InitClusterInterface() error {
// Returns the node name based on the passed in node ID.
//
func GetNodeName(nodeID string) (string, error) {
nodeInfo, err := clientset.CoreV1().Nodes().Get(nodeID, metav1.GetOptions{
TypeMeta: metav1.TypeMeta{
Kind: "",
APIVersion: "",
},
ResourceVersion: "1",
})
nodeInfo, err := clientset.CoreV1().Nodes().Get(
context.TODO(), nodeID,
metav1.GetOptions{
TypeMeta:
metav1.TypeMeta{
Kind: "",
APIVersion: "",
},
ResourceVersion: "1",
})
if err != nil {
return "", err
@ -57,14 +61,16 @@ func GetNodeName(nodeID string) (string, error) {
// Returns the list of nodes in the form of a slice containing their name.
//
func GetNodeList() ([]string, error) {
nodeList, err := clientset.CoreV1().Nodes().List(metav1.ListOptions{
TypeMeta: metav1.TypeMeta{
Kind: "",
APIVersion: "",
},
ResourceVersion: "1",
})
nodeList, err := clientset.CoreV1().Nodes().List(
context.TODO(),
metav1.ListOptions{
TypeMeta:
metav1.TypeMeta{
Kind: "",
APIVersion: "",
},
ResourceVersion: "1",
})
if err != nil {
return nil, err

View File

@ -168,6 +168,11 @@ func validateCreateVolumeReq(ctx context.Context, token *zfssarest.Token, req *c
return err
}
func (zd *ZFSSADriver) ControllerGetVolume(ctx context.Context, request *csi.ControllerGetVolumeRequest) (
*csi.ControllerGetVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "ControllerGetVolume is not implemented")
}
func (zd *ZFSSADriver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (
*csi.DeleteVolumeResponse, error) {

View File

@ -6,15 +6,15 @@
package service
import (
"github.com/oracle/zfssa-csi-driver/pkg/utils"
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/container-storage-interface/spec/lib/go/csi"
iscsi_lib "github.com/kubernetes-csi/csi-lib-iscsi/iscsi"
"k8s.io/utils/mount"
"github.com/oracle/zfssa-csi-driver/pkg/utils"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/utils/mount"
"os"
"os/exec"
"path"
@ -24,12 +24,12 @@ import (
// A subset of the iscsiadm
type IscsiAdmReturnValues int32
const(
ISCSI_SUCCESS IscsiAdmReturnValues = 0
ISCSI_ERR_SESS_NOT_FOUND = 2
ISCSI_ERR_TRANS_TIMEOUT = 8
ISCSI_ERR_ISCSID_NOTCONN = 20
ISCSI_ERR_NO_OBJS_FOUND = 21
const (
ISCSI_SUCCESS IscsiAdmReturnValues = 0
ISCSI_ERR_SESS_NOT_FOUND = 2
ISCSI_ERR_TRANS_TIMEOUT = 8
ISCSI_ERR_ISCSID_NOTCONN = 20
ISCSI_ERR_NO_OBJS_FOUND = 21
)
func GetISCSIInfo(ctx context.Context, vid *utils.VolumeId, req *csi.NodePublishVolumeRequest, targetIqn string,
@ -92,9 +92,9 @@ func GetISCSIInfo(ctx context.Context, vid *utils.VolumeId, req *csi.NodePublish
utils.GetLogCTRL(ctx, 5).Println("Final values", "iface", iface, "initiatorName", initiatorName)
i := iscsiDisk{
VolName: volName,
VolName: volName,
Portals: bkportal,
Iqn: iqn,
Iqn: iqn,
lun: assignedLunNumber,
Iface: iface,
chapDiscovery: chapDiscovery,
@ -160,9 +160,9 @@ func GetNodeISCSIInfo(vid *utils.VolumeId, req *csi.NodePublishVolumeRequest, ta
}
i := iscsiDisk{
VolName: volName,
VolName: volName,
Portals: bkportal,
Iqn: iqn,
Iqn: iqn,
lun: assignedLunNumber,
Iface: iface,
chapDiscovery: chapDiscovery,
@ -180,8 +180,7 @@ func buildISCSIConnector(iscsiInfo *iscsiDisk) *iscsi_lib.Connector {
VolumeName: iscsiInfo.VolName,
TargetIqn: iscsiInfo.Iqn,
TargetPortals: iscsiInfo.Portals,
Lun: iscsiInfo.lun,
Multipath: len(iscsiInfo.Portals) > 1,
Lun: iscsiInfo.lun,
}
if iscsiInfo.sessionSecret != (iscsi_lib.Secrets{}) {
@ -314,10 +313,9 @@ type iscsiDiskUnmounter struct {
mounter mount.Interface
}
type ISCSIUtil struct{}
func (util *ISCSIUtil) Rescan (ctx context.Context) (string, error) {
func (util *ISCSIUtil) Rescan(ctx context.Context) (string, error) {
cmd := exec.Command("iscsiadm", "-m", "session", "--rescan")
var stdout bytes.Buffer
var iscsiadmError error
@ -337,9 +335,9 @@ func (util *ISCSIUtil) Rescan (ctx context.Context) (string, error) {
formattedOutput := strings.Replace(string(stdout.Bytes()), "\n", "", -1)
iscsiadmError = fmt.Errorf("iscsiadm error: %s (%s)", formattedOutput, err.Error())
}
return string(stdout.Bytes()), iscsiadmError
}
return string(stdout.Bytes()), iscsiadmError
}
err = cmd.Wait()
if err != nil {
exitCode := err.(*exec.ExitError).ExitCode()
@ -459,7 +457,8 @@ func (util *ISCSIUtil) DetachDisk(ctx context.Context, c iscsiDiskUnmounter, tar
return err
}
err = iscsi_lib.Disconnect(connector.TargetIqn, connector.TargetPortals)
iscsi_lib.Disconnect(connector.TargetIqn, connector.TargetPortals)
if err := os.RemoveAll(targetPath); err != nil {
return err
}