Skip to content

Commit

Permalink
Merge branch 'main' of github.com:terricain/truenas-scale-csi
Browse files Browse the repository at this point in the history
  • Loading branch information
terricain committed Sep 15, 2024
2 parents 13b9c6c + 6c605f1 commit 34834a9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions charts/truenas-scale-csi/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ description: A TrueNAS Scale CSI provider

type: application
# Chart version
version: "1.0.0"
version: "1.1.0"

# Version of the container
appVersion: "1.0.0"
appVersion: "1.1.0"

home: https://github.com/terricain/truenas-scale-csi

Expand Down
3 changes: 3 additions & 0 deletions charts/truenas-scale-csi/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ spec:
{{- if .Values.settings.ignoreTLS }}
- "--ignore-tls"
{{- end }}
- "--driver-name=$(DRIVER_NAME)"
env:
- name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
Expand Down Expand Up @@ -77,6 +78,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DRIVER_NAME
value: {{ include "truenas-scale-csi.csiDriverName" . | quote }}
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
Expand Down
7 changes: 5 additions & 2 deletions charts/truenas-scale-csi/templates/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ spec:
- "--node-id=$(NODE_ID)"
- "-v={{ .Values.settings.verbosity }}"
- "--type=$(CSI_TYPE)"
- "--driver-name=$(DRIVER_NAME)"
env:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
Expand All @@ -113,6 +114,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DRIVER_NAME
value: {{ include "truenas-scale-csi.csiDriverName" . | quote }}
volumeMounts:
- name: socket-dir
mountPath: /csi
Expand All @@ -126,7 +129,7 @@ spec:
mountPropagation: "HostToContainer"
{{- if eq .Values.settings.type "iscsi" }}
- name: iscsi-csi-run-dir
mountPath: /var/run/iscsi.truenas-scale.terricain.github.com
mountPath: /var/run/{{ include "truenas-scale-csi.csiDriverName" . -}}
{{- end }}
- name: tmp
mountPath: /tmp
Expand Down Expand Up @@ -155,5 +158,5 @@ spec:
{{- if eq .Values.settings.type "iscsi" }}
- name: iscsi-csi-run-dir
hostPath:
path: /var/run/iscsi.truenas-scale.terricain.github.com
path: /var/run/{{ include "truenas-scale-csi.csiDriverName" . -}}
{{- end }}
18 changes: 10 additions & 8 deletions cmd/truenas-csi-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func main() {
iscsiStoragePath = fs.String("iscsi-storage-path", "", "iSCSI StoragePool/Dataset path")
portalID = fs.Int("portal", -1, "Portal ID")
ignoreTLS = fs.Bool("ignore-tls", false, "Ignore TLS errors")
driverName = fs.String("driver-name", "", "CSI Driver name")
)
loggingConfig := logsapi.NewLoggingConfiguration()

Expand Down Expand Up @@ -93,12 +94,13 @@ func main() {
portalID32 := int32(*portalID)

if *endpoint == "" {
if isNFS {
*endpoint = "unix:///var/run/" + driver.NFSDriverName + "/csi.sock"
} else {
*endpoint = "unix:///var/run/" + driver.ISCSIDriverName + "/csi.sock"
}
klog.V(5).InfoS("[Debug] Endpoint setting", "endpoint", *endpoint)
klog.Error("--endpoint must be specified")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}

if *driverName == "" {
klog.Error("--driver-name must be specified")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}

var drv *driver.Driver
Expand All @@ -109,14 +111,14 @@ func main() {
accessToken := os.Getenv("TRUENAS_TOKEN")

klog.V(5).Info("initiating controller driver")
if drv, err = driver.NewDriver(*endpoint, *truenasURL, accessToken, *nfsStoragePath, *iscsiStoragePath, portalID32, *controller, *nodeID, isNFS, enableDebugLogging, *ignoreTLS); err != nil {
if drv, err = driver.NewDriver(*endpoint, *truenasURL, accessToken, *nfsStoragePath, *iscsiStoragePath, portalID32, *controller, *nodeID, isNFS, enableDebugLogging, *ignoreTLS, *driverName); err != nil {
klog.ErrorS(err, "failed to init CSI driver")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
} else {
// Node mode doesnt require qnap access
klog.V(5).Info("initiating node driver")
if drv, err = driver.NewDriver(*endpoint, *truenasURL, "", *nfsStoragePath, *iscsiStoragePath, portalID32, *controller, *nodeID, isNFS, enableDebugLogging, *ignoreTLS); err != nil {
if drv, err = driver.NewDriver(*endpoint, *truenasURL, "", *nfsStoragePath, *iscsiStoragePath, portalID32, *controller, *nodeID, isNFS, enableDebugLogging, *ignoreTLS, *driverName); err != nil {
klog.ErrorS(err, "failed to init CSI driver")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type Driver struct {
ready bool
}

func NewDriver(endpoint, baseURL, accessToken, nfsStoragePath, iscsiStoragePath string, portalID int32, isController bool, nodeID string, isNFS, debugLogging bool, ignoreTLS bool) (*Driver, error) {
func NewDriver(endpoint, baseURL, accessToken, nfsStoragePath, iscsiStoragePath string, portalID int32, isController bool, nodeID string, isNFS, debugLogging bool, ignoreTLS bool, driverName string) (*Driver, error) {
u, err := url.Parse(baseURL)
if err != nil {
return nil, fmt.Errorf("unable to parse address: %w", err)
Expand All @@ -112,11 +112,6 @@ func NewDriver(endpoint, baseURL, accessToken, nfsStoragePath, iscsiStoragePath
config.HTTPClient = tc
client := tnclient.NewAPIClient(config)

driverName := NFSDriverName
if !isNFS {
driverName = ISCSIDriverName
}

return &Driver{
name: driverName,
baseURL: baseURL,
Expand Down

0 comments on commit 34834a9

Please sign in to comment.