Skip to content

ROX-14946: change PSP auto-sensing in e2e tests#6567

Merged
johannes94 merged 5 commits intomasterfrom
jmalsam/ROX-14946-PSP-version-check-on-eks
Jun 20, 2023
Merged

ROX-14946: change PSP auto-sensing in e2e tests#6567
johannes94 merged 5 commits intomasterfrom
jmalsam/ROX-14946-PSP-version-check-on-eks

Conversation

@johannes94
Copy link
Contributor

@johannes94 johannes94 commented Jun 19, 2023

Description

There are CI Errors for the auto-sensing logic for PSP introduced in #4488.

The checks where failing for EKS because they put other characters in their version strings returned by kubectl.

There are additional consideration to why the approach with major/minor version check is brittle in #4813 comments.

This PR changes the check so that it uses kubectl api-resources command instead. This should be a more reliable solution.

Checklist

  • Investigated and inspected CI test results
  • [ ] Unit test and regression tests added
  • [ ] Evaluated and added CHANGELOG entry if required
  • [ ] Determined and documented upgrade steps
  • [ ] Documented user facing changes (create PR based on openshift/openshift-docs and merge into rhacs-docs)

If any of these don't apply, please comment below.

Testing Performed

Running the following once against a cluster with PSPs and once against another cluster without PSPs

source tests/e2e/lib.sh
setup_podsecuritypolicies_config

In addition to reviewing your code, reviewers must also review your testing
instructions and make sure they are sufficient.

@johannes94 johannes94 requested a review from msugakov June 19, 2023 13:29
@johannes94 johannes94 changed the title ROX-14946: replace PSP k8s version check with kubectl api-resources in e2e tests ROX-14946: check PSP availability with kubectl api-resources in e2e tests Jun 19, 2023
@johannes94 johannes94 changed the title ROX-14946: check PSP availability with kubectl api-resources in e2e tests ROX-14946: change PSP auto-sensing in e2e tests Jun 19, 2023
@ghost
Copy link

ghost commented Jun 19, 2023

Images are ready for the commit at 61a9316.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.0.x-751-g61a9316f45.

@johannes94 johannes94 requested a review from a team June 20, 2023 06:08
tests/e2e/lib.sh Outdated
Comment on lines +371 to +373
available_api_resources=$(kubectl api-resources -o name)

if echo "$available_api_resources" | grep -q podsecuritypolicies.policy;
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I find a few examples of a slightly different pattern

SUPPORTS_PSP=$(kubectl api-resources | grep "podsecuritypolicies" -c || true)
if [[ "${SUPPORTS_PSP}" -eq 0 ]]; then
echo "Pod security policies are not supported on this cluster. Skipping..."
POD_SECURITY_POLICIES="false"
fi

Would be good to standardize on some approach and use it consistently. Please choose either your or other approach and make sure all instances look and work similarly.

  1. [Nitpicking] There's no point to declare available_api_resources and abandon it later. It can be just inlined:
    if kubectl api-resources -o name | grep -q podsecuritypolicies.policy;

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 hint, I changed my code to use the existing pattern.

@johannes94 johannes94 merged commit 88e0597 into master Jun 20, 2023
@johannes94 johannes94 deleted the jmalsam/ROX-14946-PSP-version-check-on-eks branch June 20, 2023 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants