Bug 2117319 - Error while creating Migration Policy
Summary: Error while creating Migration Policy
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: Virtualization
Version: 4.12.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 4.12.0
Assignee: Itamar Holder
QA Contact: Kedar Bidarkar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-08-10 15:32 UTC by Akriti Gupta
Modified: 2023-04-09 11:57 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-09-06 11:56:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Migration Policy yaml (370 bytes, text/plain)
2022-08-16 10:32 UTC, Akriti Gupta
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker CNV-20416 0 None None None 2023-03-30 12:07:29 UTC

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


Note You need to log in before you can comment on or make changes to this bug.