Skip to content

Commit b0fcd8b

Browse files
committed
Volume name should respect restrictions
In foreman, the VM name may contain also the domain name. When setting this name as the volume name, running the VM fails with the following error: Warning FailedCreate 21s virtualmachine-controller Error creating pod: Pod "virt-launcher-vmi-multus-lqcwz" is invalid: spec.containers[0].name: Invalid value: "volumevmi-multus.example.com": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?') Therefore the dots from FQDN VM name cannot be part of the volume name. The patch assumes the name without the domain should be sufficient.
1 parent 35f69aa commit b0fcd8b

File tree

1 file changed

+4
-4
lines changed
  • lib/fog/compute/kubevirt/models

1 file changed

+4
-4
lines changed

lib/fog/compute/kubevirt/models/vms.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ def create(args = {})
5252
end
5353

5454
volumes = []
55-
55+
volume_name = vm_name.split('.')[0]
5656
if !image.nil?
57-
volumes.push(:name => vm_name, :registryDisk => {:image => image})
57+
volumes.push(:name => volume_name, :registryDisk => {:image => image})
5858
else
59-
volumes.push(:name => vm_name, :persistentVolumeClaim => {:claimName => pvc})
59+
volumes.push(:name => volume_name, :persistentVolumeClaim => {:claimName => pvc})
6060
end
6161

6262
unless init.empty?
@@ -90,7 +90,7 @@ def create(args = {})
9090
:bus => "virtio"
9191
},
9292
:name => vm_name,
93-
:volumeName => vm_name
93+
:volumeName => volume_name
9494
}
9595
]
9696
},

0 commit comments

Comments
 (0)