Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-2.9] 🤖 Sync from open-cluster-management-io/config-policy-controller: #171 #629

Conversation

openshift-cherrypick-robot

This is an automated cherry-pick of #627

/assign mprahl

If a policy specified an empty map but the object didn't return a value
for the map, it was assumed that API server was just not returning an
empty value.

This is true in most cases, however, if the underlying Go type of the
map is a pointer to a struct, an empty map may have a different meaning
than nil. One example is the `emptyDir` key in the
"configs.imageregistry.operator.openshift.io" resource.

This commit changes the local comparison logic from considering empty
maps being the same as a nil value. The controller then performs a dry
run update request to see if the API server returns an empty map or
omits the value entirely (i.e. seen as nil).

The result of the object comparison is now cached to not continuously
making dry run update requests on every policy evaluation.

Relates:
https://issues.redhat.com/browse/ACM-7810

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
(cherry picked from commit ffc115c)
This is important for the dry-run to not send a noncompliant error
because the dry-run failed due to an object conflict. On the normal
update case, it saves the time it takes for the policy to be evaluated
again.

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
(cherry picked from commit d2a4e04)
@mprahl
Copy link
Contributor

mprahl commented Nov 7, 2023

/hold for code freeze

Copy link

sonarcloud bot commented Nov 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

81.6% 81.6% Coverage
0.0% 0.0% Duplication

@mprahl
Copy link
Contributor

mprahl commented Nov 22, 2023

/unhold

@openshift-ci openshift-ci bot added the lgtm label Nov 22, 2023
Copy link

openshift-ci bot commented Nov 22, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mprahl, openshift-cherrypick-robot

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit a9bab48 into stolostron:release-2.9 Nov 22, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants