diff --git a/pkg/controller/plan/migration.go b/pkg/controller/plan/migration.go index 69e835aa7..ee2cdc9c3 100644 --- a/pkg/controller/plan/migration.go +++ b/pkg/controller/plan/migration.go @@ -756,7 +756,7 @@ func (r *Migration) execute(vm *plan.VMStatus) (err error) { err = nil break } - if errs := k8svalidation.IsDNS1123Label(vm.Name); len(errs) > 0 { + if errs := k8svalidation.IsDNS1123Subdomain(vm.Name); len(errs) > 0 { vm.NewName, err = r.kubevirt.changeVmNameDNS1123(vm.Name, r.Plan.Spec.TargetNamespace) if err != nil { r.Log.Error(err, "Failed to update the VM name to meet DNS1123 protocol requirements.") diff --git a/pkg/controller/plan/validation.go b/pkg/controller/plan/validation.go index 224859f12..6094a14f1 100644 --- a/pkg/controller/plan/validation.go +++ b/pkg/controller/plan/validation.go @@ -258,7 +258,7 @@ func (r *Reconciler) validateTargetNamespace(plan *api.Plan) (err error) { plan.Status.SetCondition(newCnd) return } - if len(k8svalidation.IsDNS1123Label(plan.Spec.TargetNamespace)) > 0 { + if len(k8svalidation.IsDNS1123Subdomain(plan.Spec.TargetNamespace)) > 0 { newCnd.Reason = NotValid plan.Status.SetCondition(newCnd) } @@ -491,7 +491,7 @@ func (r *Reconciler) validateVM(plan *api.Plan) error { } return liberr.Wrap(pErr) } - if len(k8svalidation.IsDNS1123Label(ref.Name)) > 0 { + if len(k8svalidation.IsDNS1123Subdomain(ref.Name)) > 0 { nameNotValid.Items = append(nameNotValid.Items, ref.String()) } if _, found := setOf[ref.ID]; found { diff --git a/pkg/controller/plan/vm_name_handler.go b/pkg/controller/plan/vm_name_handler.go index c9904cd8e..1e7871ced 100644 --- a/pkg/controller/plan/vm_name_handler.go +++ b/pkg/controller/plan/vm_name_handler.go @@ -33,7 +33,7 @@ func (r *KubeVirt) changeVmNameDNS1123(vmName string, vmNamespace string) (gener // changes VM name to match DNS1123 RFC convention. func changeVmName(currName string) string { - var underscoreExcluded = regexp.MustCompile("[_.]") + var underscoreExcluded = regexp.MustCompile("[_]") var nameExcludeChars = regexp.MustCompile("[^a-z0-9-]") newName := strings.ToLower(currName)