Bug 2079690 - [RH OCP 4.9] Affinity definition YAML shows difference in web console
Summary: [RH OCP 4.9] Affinity definition YAML shows difference in web console
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Management Console
Version: 4.9
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
: 4.12.0
Assignee: Jon Jackson
QA Contact: Xiyun Zhao
Olivia Payne
URL:
Whiteboard:
Depends On:
Blocks: 2108230 2109573
TreeView+ depends on / blocked
 
Reported: 2022-04-28 06:03 UTC by Ankita Kanekar
Modified: 2023-01-17 19:48 UTC (History)
5 users (show)

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*])
Clone Of:
: 2108230 (view as bug list)
Environment:
Last Closed: 2023-01-17 19:48:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift console pull 11834 0 None open Bug 2079690: Fix operand affinity form field 2022-07-15 18:34:06 UTC
Red Hat Product Errata RHSA-2022:7399 0 None None None 2023-01-17 19:48:38 UTC

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


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