open-cluster-management-io / api

Core APIs for open cluster management
https://open-cluster-management.io
Apache License 2.0
251 stars 77 forks source link

Set omitempty on the ManifestWork UpdateStrategy field #206

Closed mprahl closed 1 year ago

mprahl commented 1 year ago

When a ManifestWork without UpdateStrategy set is marshalled into JSON, it causes the JSON value of "updateStrategy": null. This works on newer versions of Kubernetes, however, on older versions such as v1.19.16, the following error is returned when creating a ManifestWork: The ManifestWork "addon-config-policy-controller-pre-delete-hosting-cluster2" is invalid: spec.manifestConfigs.updateStrategy: Invalid value: "null": spec.manifestConfigs.updateStrategy in body must be of type object: "null"

The best way to avoid this is to add omitempty to the JSON tag so that it's completely not present in the JSON representation.

This bug was encountered when using a predelete hook in the addon framework. So this change will need to be updated in at least the addon framework and the work agent.

Relates: https://issues.redhat.com/browse/ACM-3233 https://issues.redhat.com/browse/ACM-2923

Signed-off-by: mprahl mprahl@users.noreply.github.com

mprahl commented 1 year ago

/cc @qiujian16

qiujian16 commented 1 year ago

/approve /lgtm

openshift-ci[bot] commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mprahl, qiujian16

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/open-cluster-management-io/api/blob/main/OWNERS)~~ [qiujian16] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment