diff --git a/helm/pv-migrate/Chart.yaml b/helm/pv-migrate/Chart.yaml index fb74929461aa7b24e09c2b980a0c9211742f44ac..0686ce66c80ac4302188019ebe0a4fe3d488981e 100644 --- a/helm/pv-migrate/Chart.yaml +++ b/helm/pv-migrate/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pv-migrate description: The helm chart of pv-migrate type: application -version: 0.2.0 -appVersion: 0.2.0 +version: 0.2.1 +appVersion: 0.2.1 home: https://github.com/utkuozdemir/pv-migrate keywords: - pv-migrate diff --git a/helm/pv-migrate/templates/rsync/job.yaml b/helm/pv-migrate/templates/rsync/job.yaml index b9999e51f9774ad40341351ecb88c38450a0b596..0118a480a43d81e3604c52ebfa108cb86a98d35d 100644 --- a/helm/pv-migrate/templates/rsync/job.yaml +++ b/helm/pv-migrate/templates/rsync/job.yaml @@ -55,10 +55,10 @@ spec: resources: {{- toYaml .Values.rsync.resources | nindent 12 }} volumeMounts: - {{- range .Values.rsync.pvcMounts }} - - mountPath: {{ .mountPath }} - name: {{ .name }} - readOnly: {{ default false .readOnly }} + {{- range $index, $mount := .Values.rsync.pvcMounts }} + - mountPath: {{ $mount.mountPath }} + name: vol-{{ $index }} + readOnly: {{ default false $mount.readOnly }} {{- end }} {{- if .Values.rsync.privateKeyMount }} - mountPath: {{ .Values.rsync.privateKeyMountPath }} @@ -79,11 +79,11 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - {{- range .Values.rsync.pvcMounts }} - - name: {{ .name }} + {{- range $index, $mount := .Values.rsync.pvcMounts }} + - name: vol-{{ $index }} persistentVolumeClaim: - claimName: {{ required ".Values.rsync.pvcMounts[*].pvcName is required!" .name }} - readOnly: {{ default false .readOnly }} + claimName: {{ required ".Values.rsync.pvcMounts[*].pvcName is required!" $mount.name }} + readOnly: {{ default false $mount.readOnly }} {{- end }} {{- if .Values.rsync.privateKeyMount }} - name: private-key diff --git a/helm/pv-migrate/templates/sshd/deployment.yaml b/helm/pv-migrate/templates/sshd/deployment.yaml index 6d85f5d43db36299a37ad00c50c65a4c413b8137..0d47c620f263faf17ccbecb3fa7e946e9d0ff1bb 100644 --- a/helm/pv-migrate/templates/sshd/deployment.yaml +++ b/helm/pv-migrate/templates/sshd/deployment.yaml @@ -40,10 +40,10 @@ spec: resources: {{- toYaml .Values.sshd.resources | nindent 12 }} volumeMounts: - {{- range .Values.sshd.pvcMounts }} - - mountPath: {{ .mountPath }} - name: {{ .name }} - readOnly: {{ default false .readOnly }} + {{- range $index, $mount := .Values.sshd.pvcMounts }} + - mountPath: {{ $mount.mountPath }} + name: vol-{{ $index }} + readOnly: {{ default false $mount.readOnly }} {{- end }} {{- if .Values.sshd.publicKeyMount }} - mountPath: {{ .Values.sshd.publicKeyMountPath }} @@ -69,11 +69,11 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - {{- range .Values.sshd.pvcMounts }} - - name: {{ .name }} + {{- range $index, $mount := .Values.sshd.pvcMounts }} + - name: vol-{{ $index }} persistentVolumeClaim: - claimName: {{ required ".Values.sshd.pvcMounts[*].pvcName is required!" .name }} - readOnly: {{ default false .readOnly }} + claimName: {{ required ".Values.sshd.pvcMounts[*].pvcName is required!" $mount.name }} + readOnly: {{ default false $mount.readOnly }} {{- end }} {{- if or .Values.sshd.publicKeyMount .Values.sshd.privateKeyMount }} - name: keys diff --git a/internal/integrationtest/app_test.go b/internal/integrationtest/app_test.go index 81e0093737e5027fd271a82e00c47022b5b661e8..f277a0a4c7025fb7f9f579b7937295cd2d151fcf 100644 --- a/internal/integrationtest/app_test.go +++ b/internal/integrationtest/app_test.go @@ -37,6 +37,9 @@ const ( dataFilePath = "/volume/file.txt" extraDataFilePath = "/volume/extra_file.txt" generateDataContent = "DATA" + + longSourcePvcName = "source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source-source" + longDestPvcName = "dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest-dest" ) var ( @@ -299,6 +302,28 @@ func TestLocal(t *testing.T) { assert.NoError(t, err) } +func TestLongPVCNames(t *testing.T) { + _, err := execInPod(mainClusterCli, ns1, "long-dest", clearDataShellCommand) + assert.NoError(t, err) + + cmd := fmt.Sprintf("--log-level debug m -i -n %s -N %s %s %s", + ns1, ns1, longSourcePvcName, longDestPvcName) + assert.NoError(t, runCliApp(cmd)) + + stdout, err := execInPod(mainClusterCli, ns1, "long-dest", printDataUidGidContentShellCommand) + assert.NoError(t, err) + + parts := strings.Split(stdout, "\n") + assert.Equal(t, len(parts), 3) + if len(parts) < 3 { + return + } + + assert.Equal(t, dataFileUid, parts[0]) + assert.Equal(t, dataFileGid, parts[1]) + assert.Equal(t, generateDataContent, parts[2]) +} + func setup() error { homeDir, err := userHomeDir() if err != nil { @@ -342,6 +367,11 @@ func setup() error { return err } + err = setupPVCsWithLongName() + if err != nil { + return err + } + _, err = createPVC(mainClusterCli, ns1, "source") if err != nil { return err @@ -426,6 +456,41 @@ func setup() error { return err } +func setupPVCsWithLongName() error { + _, err := createPVC(mainClusterCli, ns1, longSourcePvcName) + if err != nil { + return err + } + + _, err = createPVC(mainClusterCli, ns1, longDestPvcName) + if err != nil { + return err + } + + _, err = createPod(mainClusterCli, ns1, "long-source", longSourcePvcName) + if err != nil { + return err + } + + _, err = createPod(mainClusterCli, ns1, "long-dest", longDestPvcName) + if err != nil { + return err + } + + err = waitUntilPodIsRunning(mainClusterCli, ns1, "long-source") + if err != nil { + return err + } + + err = waitUntilPodIsRunning(mainClusterCli, ns1, "long-dest") + if err != nil { + return err + } + + _, err = execInPod(mainClusterCli, ns1, "long-source", generateDataShellCommand) + return err +} + func teardown() error { var result *multierror.Error err := deleteNs(mainClusterCli, ns1) diff --git a/internal/migrator/migrator.go b/internal/migrator/migrator.go index 0e138883f8b9afcf52a65fa522180c55ae7d0765..09f495721cbd489778c1b5c7d1b6e7ed4d6a32ff 100644 --- a/internal/migrator/migrator.go +++ b/internal/migrator/migrator.go @@ -16,7 +16,7 @@ import ( "helm.sh/helm/v3/pkg/chart/loader" ) -//go:embed pv-migrate-0.2.0.tgz +//go:embed pv-migrate-0.2.1.tgz var chartBytes []byte type ( diff --git a/internal/migrator/pv-migrate-0.2.0.tgz b/internal/migrator/pv-migrate-0.2.0.tgz deleted file mode 100644 index 19a9a293ec80800ace2dca9f4eecafe881aeba03..0000000000000000000000000000000000000000 Binary files a/internal/migrator/pv-migrate-0.2.0.tgz and /dev/null differ diff --git a/internal/migrator/pv-migrate-0.2.1.tgz b/internal/migrator/pv-migrate-0.2.1.tgz new file mode 100644 index 0000000000000000000000000000000000000000..58f45d35b2fc9636ed2bd7977e1f1a8a0e8961b7 Binary files /dev/null and b/internal/migrator/pv-migrate-0.2.1.tgz differ