Bug 2117319

Summary: Error while creating Migration Policy
Product: Container Native Virtualization (CNV) Reporter: Akriti Gupta <akrgupta>
Component: VirtualizationAssignee: Itamar Holder <iholder>
Status: CLOSED NOTABUG QA Contact: Kedar Bidarkar <kbidarka>
Severity: high Docs Contact:
Priority: high    
Version: 4.12.0CC: cnv-qe-bugs, dshchedr
Target Milestone: ---Keywords: Regression, TestBlocker
Target Release: 4.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-06 11:56:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Migration Policy yaml none

Description Akriti Gupta 2022-08-10 15:32:50 UTC
Description of problem: when trying to create migration policy using the yaml attached I get the following error:

[akrgupta@fedora auth]$ oc apply -f migration_policy.yaml
The MigrationPolicy "policy1" is invalid: 
* spec.selectors.namespaceSelector.matchLabels: Invalid value: "object": spec.selectors.namespaceSelector.matchLabels in body must be of type string: "object"
* spec.selectors.virtualMachineInstanceSelector.matchLabels: Invalid value: "object": spec.selectors.virtualMachineInstanceSelector.matchLabels in body must be of type string: "object"


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Akriti Gupta 2022-08-16 10:32:46 UTC
Created attachment 1905718 [details]
Migration Policy yaml

Comment 2 Kedar Bidarkar 2022-09-05 10:34:40 UTC
Blocker as this is Regression.

Comment 3 Itamar Holder 2022-09-05 11:38:04 UTC
Hello,

A recent commit [1] got rid of the redundant "matchLabels" fields.
In other words, please replace your YAML with this one:

spec:
  allowAutoConverge: True
  bandwidthPerMigration: 512Ki
  completionTimeoutPerGiB: 50
  allowPostCopy: True
  selectors:
    namespaceSelector:
      awesome-namespace: "yes"
    virtualMachineInstanceSelector:
      best-vm: ""


p.s. please bear in mind that having an empty value does NOT act as a wildcard, but literally as an empty string. The reason I mention this is because there was an intention, followed by a PR [2] (that never got merged), to implement a wildcard this way. Currently this PR is abandoned and we plan to delay this implementation for now (for many reasons).

Please confirm that it works. If it does, I think we should close this BZ on "not a bug".

[1] https://github.com/kubevirt/kubevirt/pull/7510/commits/cab98e53fbaf0004299582c4617338d0ffa34950
[2] https://github.com/kubevirt/kubevirt/pull/7322

Comment 4 Akriti Gupta 2022-09-06 08:32:21 UTC
Thanks Itamar
I checked with suggested changes , I was able to successfully create migration policy on 4.12

[akrgupta@fedora auth]$ cat migration_policy.yaml 
apiVersion: migrations.kubevirt.io/v1alpha1
kind: MigrationPolicy
metadata:
  name: policy2
spec:
  allowAutoConverge: True
  bandwidthPerMigration: 512Ki
  completionTimeoutPerGiB: 50
  allowPostCopy: True
  selectors:
    namespaceSelector:
      awesome-namespace: "yes"
    virtualMachineInstanceSelector:
      best-vm: ""
[akrgupta@fedora auth]$ oc apply -f migration_policy.yaml
migrationpolicy.migrations.kubevirt.io/policy2 created

Comment 5 Akriti Gupta 2023-03-30 12:06:08 UTC
Need to update the doc https://docs.openshift.com/container-platform/4.12/virt/live_migration/virt-configuring-live-migration-policies.html
the Migration policy yaml in doc contains matchLabels field needs to be removed .
Actual :
  selectors:
    namespaceSelector: 
      matchLabels:
        hpc-workloads: "True"
        xyz-workloads-type: ""
    virtualMachineInstanceSelector: 
      matchLabels:
        workload-type: "db"
        operating-system: ""

expected:

  selectors:
    namespaceSelector: 
        hpc-workloads: "True"
        xyz-workloads-type: ""
    virtualMachineInstanceSelector: 
        workload-type: "db"
        operating-system: ""

Comment 6 Itamar Holder 2023-04-09 11:57:45 UTC
Looks good to me.
I've also added a PR to upstream user-guide regarding that: https://github.com/kubevirt/user-guide/pull/671