Bug 1826523 - Various fields in build resources are displayed as `null` if unset
Summary: Various fields in build resources are displayed as `null` if unset
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 4.5
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.5.0
Assignee: aaleman
QA Contact: wewang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-04-21 21:09 UTC by aaleman
Modified: 2020-07-13 17:30 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: optional BuildConfig and Build fields did not have `omitempty` in their JSON tags Consequence: several fields appear as `null` in oc get build Fix: add `omitempty` tags to relevant Build and BuildConfig fields Result: empty, optional fields do not appear in JSON or YAML output of Build and BuildConfig objects
Clone Of:
Environment:
Last Closed: 2020-07-13 17:29:58 UTC
Target Upstream Version:
Embargoed:
wewang: needinfo-


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift api pull 626 0 None closed Bug 1826523: Builds: Make a bunch of fields omitempty 2020-06-23 10:14:35 UTC
Github openshift openshift-apiserver pull 99 0 None closed Bug 1826523: Bump openshift/api to 0422dc17083e9e8df18d029f3f34322e96e9c326 2020-06-23 10:14:34 UTC
Red Hat Product Errata RHBA-2020:2409 0 None None None 2020-07-13 17:30:15 UTC

Description aaleman 2020-04-21 21:09:55 UTC
Description of problem:

There is a set of fields that are displayed as `null` in Build custom resources, rather than getting omitted, for example:

```
apiVersion: build.openshift.io/v1
kind: Build
[...]
spec:
  nodeSelector: null
  [...]
  source:
    - as: null
      from:
     [...]
  triggeredBy: null
```


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


How reproducible:

100%


Steps to Reproduce:
1. `oc get build -o yaml`
2.
3.

Actual results:


Expected results:

Unset fields are omitted, rather than shown with a `null` value


Additional info:

Comment 3 wewang 2020-04-23 08:52:12 UTC
It can be reproduced, but now latest accepted payload is 4.5.0-0.nightly-2020-04-21-103613, will wait newer payload to check it.
'''
  nodeSelector: null
  output:
    pushSecret:
      name: builder-dockercfg-55m9g
    to:
      kind: ImageStreamTag
      name: test:latest
  postCommit: {}
  resources: {}
  serviceAccount: builder
  source:
    binary:
      asFile: Dockerfile
    type: Binary
  strategy:
    dockerStrategy: {}
    type: Docker
  triggeredBy: null
'''

Comment 4 wewang 2020-04-24 03:25:12 UTC
@aaleman Tested in ci payload, but still met null, if need others update.
version:
4.5.0-0.ci-2020-04-23-151503

'''
spec:
  nodeSelector: null
  output:
    pushSecret:
      name: builder-dockercfg-89pcs
    to:
      kind: ImageStreamTag
      name: test:latest
  postCommit: {}
  resources: {}
  serviceAccount: builder
  source:
    binary:
      asFile: Dockerfile
    type: Binary
  strategy:
    dockerStrategy: {}
    type: Docker
  triggeredBy: null
'''

Comment 5 wewang 2020-04-24 05:14:24 UTC
Oh, I know why null still exists, seems vendor/github.com/openshift/api/build/v1/types.go in ocm repo also need to bump, @adam could you help to check it, thanks.

Comment 6 aaleman 2020-04-24 12:28:14 UTC
Posted https://github.com/openshift/openshift-apiserver/pull/99 to get the changes picked up

Comment 8 wewang 2020-05-07 08:12:12 UTC
Will wait latest payload to check it

Comment 9 wewang 2020-05-08 02:16:31 UTC
Oh, I found nodeSelector is not omitempty, should be ignore, if it's null
Version:
4.5.0-0.nightly-2020-05-07-144853

-----  
spec:
    nodeSelector: null
    output:
      pushSecret:
        name: builder-dockercfg-d4gm4
-----

Comment 10 wewang 2020-05-08 02:30:18 UTC
Seems cannot omitempty for nodeSelector as said before:https://github.com/openshift/api/pull/626#discussion_r407503527, but how to resolve null issue about nodeSelector?

Comment 11 aaleman 2020-05-08 15:35:47 UTC
Unfortunately, we can not do anything about the nodeSelector being displayed as null as that would mean we can not differentiate null from empty anymore.

Comment 13 wewang 2020-05-18 03:22:27 UTC
@aaleman Oh, sorry forgot change status according your comment 11

Comment 14 errata-xmlrpc 2020-07-13 17:29:58 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, 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/RHBA-2020:2409


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