Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

feat(helm): support admission control failurePolicy configuration#13838

Closed
flowdopip wants to merge 1 commit intostackrox:masterstackrox/stackrox:masterfrom
flowdopip:masterflowdopip/stackrox:masterCopy head branch name to clipboard
Closed

feat(helm): support admission control failurePolicy configuration#13838
flowdopip wants to merge 1 commit intostackrox:masterstackrox/stackrox:masterfrom
flowdopip:masterflowdopip/stackrox:masterCopy head branch name to clipboard

Conversation

@flowdopip
Copy link
Contributor

Description

Add support to define which failurePolicy the admission controller can apply.
FailurePolicy defines how unrecognized errors from the admission endpoint are handled - allowed values are Ignore or Fail. Defaults to Fail.

User-facing documentation

  • CHANGELOG is updated OR update is not needed
  • documentation PR is created and is linked above OR is not needed

Testing and quality

  • the change is production ready: the change is GA or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

Added unit test for current config and custom configuration.

@openshift-ci
Copy link

openshift-ci bot commented Jan 16, 2025

Hi @flowdopip. Thanks for your PR.

I'm waiting for a stackrox member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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-sigs/prow repository.

@github-actions github-actions bot added the external-contributor To put on issues and PRs from external contributors label Jan 16, 2025
@flowdopip
Copy link
Contributor Author

Anything I can do to speed up this "feature"? I need this asap for an internal compliance audit.
Thanks

Copy link
Contributor

@vladbologa vladbologa left a comment

Choose a reason for hiding this comment

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

Hi @flowdopip, thanks for contributing to Stackrox! The change looks good to me, but I see some style check failures.

I would also like that another colleague reviews this as well.

@vladbologa
Copy link
Contributor

/ok-to-test

@flowdopip
Copy link
Contributor Author

Thanks @vladbologa.
Already push an update for you comments

image/templates/helm/stackrox-secured-cluster/values-public.yaml.example:312: trailing whitespace.
+# failurePolicy: Ignore

- istio-system
{{- end }}
failurePolicy: Ignore
failurePolicy: {{ ._rox.admissionControl.failurePolicy | default "Ignore" }}
Copy link
Contributor

@mclasmeier mclasmeier Jan 22, 2025

Choose a reason for hiding this comment

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

We are currently aiming for consolidating our default settings for configurable settings in one place. Could you add the default here instead of having the defaulting here?

Same below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done! Please review!

listenOnCreates: true
listenOnEvents: false
expect: |
.validatingwebhookconfigurations[].webhooks[].failurePolicy == "Ignore"
Copy link
Contributor

Choose a reason for hiding this comment

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

This test doesn't work in it's current form. Here's a patch:

--- a/pkg/helm/charts/tests/securedclusterservices/testdata/helmtest/admission-control.test.yaml
+++ b/pkg/helm/charts/tests/securedclusterservices/testdata/helmtest/admission-control.test.yaml
@@ -170,12 +170,12 @@ tests:
           listenOnCreates: true
           listenOnEvents: false
       expect: |
-        .validatingwebhookconfigurations[].webhooks[].failurePolicy == "Ignore"
+        .validatingwebhookconfigurations[].webhooks[].failurePolicy | assertThat(. == "Ignore")
     - name: "override failurePolicy to fail"
       values:
         admissionControl:
           listenOnCreates: true
           listenOnEvents: false
-          failurePolicy: "fail"
+          failurePolicy: "Fail"
       expect: |
-        .validatingwebhookconfigurations[].webhooks[].failurePolicy == "Fail"
\ No newline at end of file
+        .validatingwebhookconfigurations[].webhooks[].failurePolicy | assertThat(. == "Fail")

You can run the tests as follows:

❯ pwd
/Users/mclasmeier/go/src/github.com/stackrox/stackrox/pkg/helm/charts/tests/securedclusterservices

❯ go test -v ./ -run TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy
=== RUN   TestWithHelmtest
=== RUN   TestWithHelmtest/testdata/helmtest
=== PAUSE TestWithHelmtest/testdata/helmtest
=== CONT  TestWithHelmtest/testdata/helmtest
=== RUN   TestWithHelmtest/testdata/helmtest/admission-control.test.yaml
=== PAUSE TestWithHelmtest/testdata/helmtest/admission-control.test.yaml
=== CONT  TestWithHelmtest/testdata/helmtest/admission-control.test.yaml
=== RUN   TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy
=== PAUSE TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy
=== CONT  TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy
=== RUN   TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy/default_failure_policy_ignore
=== PAUSE TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy/default_failure_policy_ignore
=== RUN   TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy/override_failurePolicy_to_fail
=== PAUSE TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy/override_failurePolicy_to_fail
=== CONT  TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy/default_failure_policy_ignore
=== CONT  TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy/override_failurePolicy_to_fail
--- PASS: TestWithHelmtest (0.02s)
    --- PASS: TestWithHelmtest/testdata/helmtest (0.00s)
        --- PASS: TestWithHelmtest/testdata/helmtest/admission-control.test.yaml (0.00s)
            --- PASS: TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy (0.00s)
                --- PASS: TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy/override_failurePolicy_to_fail (0.20s)
                --- PASS: TestWithHelmtest/testdata/helmtest/admission-control.test.yaml/Admission_Controller_Failure_Policy/default_failure_policy_ignore (0.20s)
PASS
ok      github.com/stackrox/rox/pkg/helm/charts/tests/securedclusterservices    0.981s

Besides the assertion syntax, there was a typo (fail vs. Fail) and a missing newline at the end of the fail, which would probably be criticized by our automatic style checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the explanation!
Please review the update

Copy link
Contributor

@mclasmeier mclasmeier left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

@flowdopip
Copy link
Contributor Author

/retest

@openshift-ci
Copy link

openshift-ci bot commented Jan 22, 2025

@flowdopip: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocp-4-12-nongroovy-e2e-tests 4d5287e link false /test ocp-4-12-nongroovy-e2e-tests
ci/prow/gke-upgrade-tests 4d5287e link false /test gke-upgrade-tests
ci/prow/gke-operator-e2e-tests 4d5287e link false /test gke-operator-e2e-tests
ci/prow/gke-nongroovy-e2e-tests 4d5287e link true /test gke-nongroovy-e2e-tests
ci/prow/gke-qa-e2e-tests 4d5287e link false /test gke-qa-e2e-tests
ci/prow/gke-scanner-v4-install-tests 4d5287e link false /test gke-scanner-v4-install-tests
ci/prow/ocp-4-12-scanner-v4-install-tests 4d5287e link false /test ocp-4-12-scanner-v4-install-tests
ci/prow/ocp-4-17-nongroovy-e2e-tests 4d5287e link false /test ocp-4-17-nongroovy-e2e-tests
ci/prow/ocp-4-17-qa-e2e-tests 4d5287e link false /test ocp-4-17-qa-e2e-tests
ci/prow/ocp-4-17-operator-e2e-tests 4d5287e link false /test ocp-4-17-operator-e2e-tests
ci/prow/ocp-4-12-qa-e2e-tests 4d5287e link false /test ocp-4-12-qa-e2e-tests
ci/prow/ocp-4-12-operator-e2e-tests 4d5287e link false /test ocp-4-12-operator-e2e-tests
ci/prow/ocp-4-17-scanner-v4-install-tests 4d5287e link false /test ocp-4-17-scanner-v4-install-tests

Full PR test history. Your PR dashboard.

Details

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-sigs/prow repository. I understand the commands that are listed here.

@vladbologa
Copy link
Contributor

@flowdopip @mclasmeier I have opened another PR using @flowdopip's commit, so that CI can run properly. We can merge that one instead.

@flowdopip
Copy link
Contributor Author

@vladbologa why you need to open a new PR for the CI to work?
Anything I can do from my side?

@vladbologa
Copy link
Contributor

@vladbologa why you need to open a new PR for the CI to work? Anything I can do from my side?

Looking into it, but for now I thought it would be faster if I just open another PR. It's merged now btw, so nothing left for you to do. It'll be available in the 4.7 release.

@vladbologa vladbologa closed this Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor To put on issues and PRs from external contributors ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.