Bug 1826523

Summary: Various fields in build resources are displayed as `null` if unset
Product: OpenShift Container Platform Reporter: aaleman
Component: BuildAssignee: aaleman
Status: CLOSED ERRATA QA Contact: wewang <wewang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.5CC: adam.kaplan, aos-bugs, pweil, wzheng
Target Milestone: ---Flags: wewang: needinfo-
Target Release: 4.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-13 17:29:58 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:

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