Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2079690

Summary: [RH OCP 4.9] Affinity definition YAML shows difference in web console
Product: OpenShift Container Platform Reporter: Ankita Kanekar <akanekar>
Component: Management ConsoleAssignee: Jon Jackson <jonjacks>
Status: CLOSED ERRATA QA Contact: Xiyun Zhao <xiyuzhao>
Severity: medium Docs Contact: Olivia Payne <opayne>
Priority: medium    
Version: 4.9CC: aos-bugs, jonjacks, nmukherj, opayne, yapei
Target Milestone: ---   
Target Release: 4.12.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
*Previously, the `MatchExpression` component did not account for array-type values. As a result, only single values could be entered through forms using this component. With this update, the `MatchExpression` component accepts comma-separated values as an array. (link:https://bugzilla.redhat.com/show_bug.cgi?id=2079690[*BZ#207690*])
Story Points: ---
Clone Of:
: 2108230 (view as bug list) Environment:
Last Closed: 2023-01-17 19:48:18 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: 2108230, 2109573    

Description Ankita Kanekar 2022-04-28 06:03:52 UTC
Description of problem:

In OpenShift operator for our product we want users to be able to set affinity:
- nodeAffinity
- podAffinity
- podAntiAffinity

We are using the x-descriptors for that in our CSV:
urn:alm:descriptor:com.tectonic.ui:nodeAffinity
urn:alm:descriptor:com.tectonic.ui:podAffinity
urn:alm:descriptor:com.tectonic.ui:podAntiAffinity

as described here: 
https://github.com/openshift/console/blob/master/frontend/packages/operator-lifecycle-manager/src/components/descriptors/reference/reference.md#11-nodeaffinity

The problem is that while setting affinity values in the form view in OpenShift console, the mapping we see in YAML view is incorrect. 
Filling up a single key-value for nodeAffinity results in the following lines in the YAML view:

    node_affinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
              - key: some_key
                operator: In
                value: some_value

While the correct version would be:

    node_affinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
              - key: some_key
                operator: In
                values: 
                 - some_value

as described in: https://docs.openshift.com/container-platform/4.9/nodes/scheduling/nodes-scheduler-node-affinity.html

With this wrong YAML we then get the following error on an attempt to create a deployment:

failed to install release: unable to build kubernetes objects from release manifest: error validating "": error validating data: [ValidationError(Deployment.spec.template.spec.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].preference.matchExpressions[0]): unknown field "value" in io.k8s.api.core.v1.NodeSelectorRequirement, ValidationError(Deployment.spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0]): unknown field "value" in io.k8s.api.core.v1.NodeSelectorRequirement]

The exact same thing has been reported on GitHub some time ago: https://github.com/openshift/console/issues/9802


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


How reproducible:
Easy

Steps to Reproduce:
1. Create a pod affinity definition on cluster
2. Access the YAML definition from OCP console.


Actual results:

- key: some_key
    operator: In
    value: some_value


Expected results:

- key: some_key
    operator: In
    value: 
      - some_value


Additional info:

Comment 4 Xiyun Zhao 2022-08-11 10:06:45 UTC
This bug has been verified on payload 4.12.0-0.nightly-2022-08-10-200611

Verification Step:
1. Prepare a mock file (CSD, CSV, attached sample file) with affinity, which is as same as customer said in the description
   - nodeAffinity
   - podAffinity
   - podAntiAffinity
2. Fill in the data on Form view, and switch to YAML view
3. Check the format on YAML file
4. Check if the file can be created successfully

Result:
3. The data on YAML file will follow the format below (Attached: result)
    nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
        - matchExpressions:
            - key: test
              operator: In
              values:
                - test1
                - test2
                - test3
        - matchExpressions:
            - key: testnodeaffinity
              operator: In
              values:
                - testnodeaffinity1
                - testnodeaffinity2
                - testnodeaffinity3
4. The Resource can be created with YAML view and without any error message

Comment 9 errata-xmlrpc 2023-01-17 19:48:18 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 (Moderate: OpenShift Container Platform 4.12.0 bug fix and security 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:7399