migtools / pvc-migrate

Standalone PVC migration
Apache License 2.0
5 stars 13 forks source link

Playbook failed when PVC name is a number #125

Closed lcordero closed 4 years ago

lcordero commented 4 years ago

Add double quotes to string fields on templates to avoid errors creating PVCs on the destination cluster, due numbers on the source PVC names.

Source PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
     ... ...
  finalizers:
  - kubernetes.io/pvc-protection
  name: "33"
  namespace: my-namespace
spec:
   ... ...

Error:

Failed to create object: b'{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\" \\\\\"\\\\\" is invalid: patch: Invalid value: ... ... ...
v1.PersistentVolumeClaim.ObjectMeta: v1.ObjectMeta.Name: ReadString: expects \\\\\" or n, but found 1, error found in #10 byte of ...|],\\\\\"name\\\\\":33,\\\\\"namesp|...,", "reason": "Unprocessable Entity", "status": 422}

Fix: On file: https://github.com/konveyor/pvc-migrate/blob/master/2_pvc_destination_gen/templates/pvc.yml.j2 - add double quotes to name.

metadata:
  finalizers:
  - kubernetes.io/pvc-protection
  name: "{{ item.pvc_name }}"     <<-- HERE
  namespace: {{ item.pvc_namespace }}
spec:
lcordero commented 4 years ago

Please consider all templates that are created using variables based on PVC name. For example: https://github.com/konveyor/pvc-migrate/blob/master/3_run_rsync/templates/pod.yml.j2

pranavgaikwad commented 4 years ago

@lcordero thanks for the issue report. This is being addressed in #126