Bug 2079674

Summary: Configuring preferred node affinity in the console results in wrong yaml and unschedulable VM
Product: Container Native Virtualization (CNV) Reporter: Germano Veit Michel <gveitmic>
Component: User ExperienceAssignee: Aviv Turgeman <aturgema>
Status: CLOSED ERRATA QA Contact: Guohua Ouyang <gouyang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.10.6CC: aturgema, cnv-qe-bugs, gouyang
Target Milestone: ---   
Target Release: 4.11.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2090127 (view as bug list) Environment:
Last Closed: 2022-09-14 19:31:19 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:
Bug Depends On:    
Bug Blocks: 2090127    

Description Germano Veit Michel 2022-04-28 04:33:00 UTC
Description of problem:

1. Create a new VM from template, dont start it

2. Virtualization -> Virtual Machines -> VM -> Details

3. Under "Scheduling and resources requirements", click the pencil to edit Affinity Rules -> Add Affinity Rule

4. Fill the following

   Type: Node Affinity
   Condition: Preferred during scheduling (not default, change it)
   Weight: 100
   Node Labels
        Key                       Op     Values
        kubernetes.io/hostname    In     <your node hostname>

5. Click "Save Affinity Rule"

6. Click "Save"

7. Start the VM

8. Result:

Error creating pod: Pod "virt-launcher-rhel8-narrow-grasshopper-gqpln" is invalid: spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms: Required value: must have at least one node selector term

9. Why? See what it did in the yaml...

    spec:
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:   <---- this is what I configured
          - preference:
              matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - white.shift.toca.local
            weight: 100
          requiredDuringSchedulingIgnoredDuringExecution:     <--- I configured preferred only, I did not set any required rule
            nodeSelectorTerms: []                             <--- error above caused by this
        podAffinity: {}
        podAntiAffinity: {}

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

How reproducible:
Always

Steps to Reproduce:
As above

Actual results:
VM wont start

Expected results:
Vm starts

Comment 3 Guohua Ouyang 2022-04-28 05:05:15 UTC
Could reproduce this bug on 4.10.

Comment 4 Guohua Ouyang 2022-05-13 01:52:01 UTC
The bug also exists in CNV-v4.11.0-337

Comment 5 Guohua Ouyang 2022-05-25 08:17:22 UTC
verified on v4.11.0-403(OCP v4.11.0-32)

Comment 8 errata-xmlrpc 2022-09-14 19:31:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: OpenShift Virtualization 4.11.0 Images security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:6526