Skip to content

Commit

Permalink
add migration flag for smb (#2029)
Browse files Browse the repository at this point in the history
* add migration flag for smb

* dont clear default mountOpts
  • Loading branch information
stavros-k authored Jan 12, 2024
1 parent df964fd commit 212e344
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 20 deletions.
2 changes: 1 addition & 1 deletion library/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: common
description: A library chart for iX Official Catalog
type: library
version: 1.2.7
version: 1.2.8
appVersion: v1
annotations:
title: Common Library Chart
Expand Down
9 changes: 7 additions & 2 deletions library/common/templates/app_functions/_storageEntry.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
{{- $username := "" -}}
{{- $password := "" -}}
{{- $medium := "" -}}
{{- $mountOpts := (list
(dict "key" "noperm")
) -}}

{{- if $storage.readOnly -}}
{{- $readOnly = true -}}
Expand Down Expand Up @@ -56,6 +59,9 @@
{{- $domain = $storage.smbConfig.domain | quote -}}
{{- $username = $storage.smbConfig.username | quote -}}
{{- $password = $storage.smbConfig.password | quote -}}
{{- if $storage.smbConfig.mountOptions -}}
{{- $mountOpts = $storage.smbConfig.mountOptions -}}
{{- end -}}
{{- if $storage.smbConfig.size -}}
{{- $size = (printf "%vGi" $storage.smbConfig.size) -}}
{{- end -}}
Expand Down Expand Up @@ -88,7 +94,6 @@ domain: {{ $domain }}
username: {{ $username }}
password: {{ $password }}
{{- if eq $storage.type "smb-pv-pvc" }}
mountOptions:
- key: noperm
mountOptions: {{ $mountOpts | toYaml | nindent 2 }}
{{- end }}
{{- end -}}
6 changes: 3 additions & 3 deletions library/ix-dev/test/syncthing/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: file://../../../common
version: 1.2.7
digest: sha256:d69abe6772f86bc5c22cd95bf4505685ca88a1f5f99d78e2cf58cb66bb945e07
generated: "2024-01-09T19:51:36.548222782+02:00"
version: 1.2.8
digest: sha256:6798e8f5a66aa1f06247a6b75c10b03b6d7777b129251995e2e4249c89b0eaef
generated: "2024-01-11T19:04:53.665949067+02:00"
4 changes: 2 additions & 2 deletions library/ix-dev/test/syncthing/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Syncthing is a continuous file synchronization program.
annotations:
title: Syncthing
type: application
version: 1.2.1
version: 1.2.2
apiVersion: v2
appVersion: '1.27.0'
kubeVersion: '>=1.16.0-0'
Expand All @@ -14,7 +14,7 @@ maintainers:
dependencies:
- name: common
repository: file://../../../common
version: 1.2.7
version: 1.2.8
home: https://syncthing.net/
icon: https://media.sys.truenas.net/apps/syncthing/icons/icon.svg
sources:
Expand Down
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions library/ix-dev/test/syncthing/questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,22 @@ questions:
type: dict
show_if: [["type", "=", "smb-pv-pvc"]]
attrs:
- variable: migrationMode
label: Migration Mode
description: |
Enabling this will force the following:</br>
- Read Only Mount, regardless of the value of the Read Only checkbox.</br>
- SMB Mount Options will be set to "vers=3.0", "cifsacl", "noperm" </br>
This option is used to migrate data from third party </br>
NAS platforms onto TrueNAS SCALE.</br>
Keep in mind that the ACL preservation is not guaranteed when:</br>
- Non-AD environment</br>
- ACL or remote server contains local users</br>
schema:
type: boolean
default: false
- variable: server
label: Server
description: The server for the SMB share.
Expand Down
22 changes: 10 additions & 12 deletions library/ix-dev/test/syncthing/templates/_persistence.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
persistence:
home:
enabled: true
{{- include "syncthing.storage.ci.migration" (dict "storage" .Values.syncthingStorage.home) }}
{{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.syncthingStorage.home) | nindent 4 }}
targetSelector:
syncthing:
Expand Down Expand Up @@ -36,9 +35,18 @@ persistence:
{{- end -}}

{{- range $idx, $storage := .Values.syncthingStorage.additionalStorages }}
{{- if eq $storage.type "smb-pv-pvc" -}}
{{- if $storage.smbConfig.migrationMode -}}
{{- $_ := set $storage "readOnly" true -}}
{{- $_ := set $storage.smbConfig "mountOptions" (list
(dict "key" "noperm")
(dict "key" "cifsacl")
(dict "key" "vers" "value" "3.0")
) -}}
{{- end -}}
{{- end }}
{{ printf "sync-%v" (int $idx) }}:
enabled: true
{{- include "syncthing.storage.ci.migration" (dict "storage" $storage) }}
{{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
targetSelector:
syncthing:
Expand Down Expand Up @@ -69,13 +77,3 @@ scaleCertificate:
id: {{ .Values.syncthingNetwork.certificateID }}
{{- end -}}
{{- end -}}

{{/* TODO: Remove on the next version bump, eg 1.2.0+ */}}
{{- define "syncthing.storage.ci.migration" -}}
{{- $storage := .storage -}}

{{- if $storage.hostPath -}}
{{- $_ := set $storage "hostPathConfig" dict -}}
{{- $_ := set $storage.hostPathConfig "hostPath" $storage.hostPath -}}
{{- end -}}
{{- end -}}

0 comments on commit 212e344

Please sign in to comment.