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

Bug: ACM-5052, Policy gets shortly into non-compliant state #144

Merged

Conversation

JeffeyL
Copy link
Contributor

@JeffeyL JeffeyL commented Jun 20, 2023

Description of problem: When stringData is set on a Secret within a policy, Kubernetes automatically converts it to a base64 encoded data field. The next time the policy is evaluated, the controller expects to see a stringData field - however, stringData is no longer set (due to the conversion) so the controller sees a mismatch.

Solution: When the controller handles a single key, a check has been added for the exact case where stringData is set within a Secret. In this case, the data field will be base64 decoded and then used for comparison.

Ref: https://issues.redhat.com/browse/ACM-5052

Copy link
Member

@JustinKuli JustinKuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks really good! I think it would fix the problem (in a surprisingly clean way!), but I think we need a better test to be sure.

test/e2e/case32_secret_stringdata_test.go Outdated Show resolved Hide resolved
controllers/configurationpolicy_controller.go Outdated Show resolved Hide resolved
controllers/configurationpolicy_controller.go Outdated Show resolved Hide resolved
Copy link
Member

@JustinKuli JustinKuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just small comments that aren't really necessary.

I think #145 will fix the timeout in the most recent CI run, so we could wait for that to merge, then re-base this. Or maybe a re-run will randomly work.

controllers/configurationpolicy_controller.go Outdated Show resolved Hide resolved
@JeffeyL JeffeyL force-pushed the ACM-5052 branch 2 times, most recently from 59158ee to 5175a2a Compare June 22, 2023 19:08
Copy link
Member

@dhaiducek dhaiducek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and clean solution! I dropped a couple comments to consider.

test/e2e/case32_secret_stringdata_test.go Outdated Show resolved Hide resolved
test/e2e/case32_secret_stringdata_test.go Outdated Show resolved Hide resolved
controllers/configurationpolicy_controller.go Show resolved Hide resolved
@@ -2556,6 +2558,30 @@ func handleSingleKey(
mergedValue.(map[string]interface{}), existingValue.(map[string]interface{}))
}

if key == "stringData" && existingObj.GetKind() == "Secret" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somewhere throw an error?

@@ -2411,6 +2412,7 @@ func handleSingleKey(

desiredValue := formatTemplate(desiredObj, key)
existingValue := existingObj.UnstructuredContent()[key]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this blank

@yiraeChristineKim
Copy link
Contributor

/unhold

Copy link
Member

@dhaiducek dhaiducek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit about whitespace, but otherwise I think we can merge this!

Solution: decode automatically converted stringData prior to evaluation

Signed-off-by: Jeffrey Luo <jeluo@redhat.com>
@dhaiducek
Copy link
Member

@JustinKuli requested changes here, so he'll need to re-review it for it to merge.

@openshift-ci
Copy link

openshift-ci bot commented Jun 28, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dhaiducek, JeffeyL, JustinKuli

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 [JustinKuli,dhaiducek]

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

@openshift-cherrypick-robot

@JeffeyL: only open-cluster-management-io org members may request cherry picks. You can still do the cherry-pick manually.

In response to this:

/cherry-pick release-2.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@yiraeChristineKim
Copy link
Contributor

/cherry-pick release-2.7

@openshift-cherrypick-robot

@yiraeChristineKim: only open-cluster-management-io org members may request cherry picks. You can still do the cherry-pick manually.

In response to this:

/cherry-pick release-2.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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.

7 participants