-
Notifications
You must be signed in to change notification settings - Fork 745
CMP-2859: Resolve failing Image-stream-sets-schedule #12895
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
CMP-2859: Resolve failing Image-stream-sets-schedule #12895
Conversation
Hi @KaushikOP. Thanks for your PR. I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/jira-refresh |
@@ -32,17 +32,17 @@ references: | |||
srg: SRG-APP-000456-CTR-001125 | |||
|
|||
{{% set api_path = '/apis/image.openshift.io/v1/imagestreams' %}} | |||
{{% set jqfilter = '[.items[] | .spec.tags[]? | select(.from.kind != "ImageStreamTag") | (.importPolicy.scheduled != null and .importPolicy.scheduled != false)] | all' %}} | |||
{{% set jqfilter = '[.items[] | select( .metadata.ownerReferences? // [] | all(.kind != "ClusterVersion")) | select(.metadata.labels[]? | select("samples.operator.openshift.io/managed: true") | not) | select(.spec.tags[]?.from.kind != "ImageStreamTag" and (.importPolicy.scheduled != null or .importPolicy.scheduled != false))] | any' %}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Gather all ImageStreams -
.items[]
- Select only those not managed by
ClusterVersion
-select( .metadata.ownerReferences? // [] | all(.kind != "ClusterVersion"))
ClusterVersion
implies on upgrade that these ImageStream entries are upgraded
- From those that remain, check if it's managed by the Samples Operator, if so ignore those -
select(.metadata.labels[]? | select("samples.operator.openshift.io/managed: true") | not)
- Check the Remaining ones are not tags -
select(.spec.tags[]?.from.kind != "ImageStreamTag" and
(partial query here)
- e.g.
ImageStreamTag
latest points tov1.2.3
- The ones that remain from that check to see if scheduled is false or not set -
(.importPolicy.scheduled != null or .importPolicy.scheduled != false))] | any' %}}
If any fail the last condition it returns false for the query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a bunch for the breakdown and explanation of the jq filter.
/retest-required |
@prb112: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
/jira-refresh |
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/LGTM
But could you also update the expected results so that our CI doesn't flag this change?
Change the following lines from FAIL
to PASS
.
$ grep -rA2 "imagestream-sets-schedule" tests/assertions/ocp4/
tests/assertions/ocp4/ocp4-stig-4.12.yml: e2e-stig-imagestream-sets-schedule:
tests/assertions/ocp4/ocp4-stig-4.12.yml- default_result: FAIL
tests/assertions/ocp4/ocp4-stig-4.12.yml- result_after_remediation: FAIL
--
tests/assertions/ocp4/ocp4-stig-4.13.yml: e2e-stig-imagestream-sets-schedule:
tests/assertions/ocp4/ocp4-stig-4.13.yml- default_result: FAIL
tests/assertions/ocp4/ocp4-stig-4.13.yml- result_after_remediation: FAIL
--
tests/assertions/ocp4/ocp4-stig-4.14.yml: e2e-stig-imagestream-sets-schedule:
tests/assertions/ocp4/ocp4-stig-4.14.yml- default_result: FAIL
tests/assertions/ocp4/ocp4-stig-4.14.yml- result_after_remediation: FAIL
--
tests/assertions/ocp4/ocp4-stig-4.15.yml: e2e-stig-imagestream-sets-schedule:
tests/assertions/ocp4/ocp4-stig-4.15.yml- default_result: FAIL
tests/assertions/ocp4/ocp4-stig-4.15.yml- result_after_remediation: FAIL
--
tests/assertions/ocp4/ocp4-stig-4.16.yml: e2e-stig-imagestream-sets-schedule:
tests/assertions/ocp4/ocp4-stig-4.16.yml- default_result: FAIL
tests/assertions/ocp4/ocp4-stig-4.16.yml- result_after_remediation: FAIL
--
tests/assertions/ocp4/ocp4-stig-4.17.yml: e2e-stig-imagestream-sets-schedule:
tests/assertions/ocp4/ocp4-stig-4.17.yml- default_result: FAIL
tests/assertions/ocp4/ocp4-stig-4.17.yml- result_after_remediation: FAIL
--
tests/assertions/ocp4/ocp4-stig-4.18.yml: e2e-stig-imagestream-sets-schedule:
tests/assertions/ocp4/ocp4-stig-4.18.yml- default_result: FAIL
tests/assertions/ocp4/ocp4-stig-4.18.yml- result_after_remediation: FAIL
$ cat ./applications/openshift/registry/imagestream_sets_schedule/tests/ocp4/e2e.yml
---
default_result: FAIL
Thanks @yuumasato I'll leave a message with Kaushik letting him know |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KaushikOP tests/assertions/ocp4/ocp4-stig-4.18.yml
was left out of the assertion update.
Please update it as well.
/test 4.17-e2e-aws-ocp4-stig |
/retest-required |
Hi @yuumasato I have made the changes. Please re-review. |
/retest-required |
/test 4.12-e2e-aws-ocp4-stig |
Grabbed the imagestreams from the must-gather. https://gist.github.com/prb112/06768521d08ecf0eba49476252580e8e Will ask @KaushikOP to test the |
Analyzed the gist / imagestreams - it should have passed. Perhaps a retest? |
/retest-required |
4 similar comments
/retest-required |
/retest-required |
/retest-required |
/retest-required |
@prb112 @KaushikOP I am not sure below imagestream is a good example or not. I created a imagestream without ownerReferences set, and set the importPolicy.scheduled to null. Under this scenario, the rule should FAIL, right?
|
/hold for test |
|
@@ -32,17 +32,17 @@ references: | |||
srg: SRG-APP-000456-CTR-001125 | |||
|
|||
{{% set api_path = '/apis/image.openshift.io/v1/imagestreams' %}} | |||
{{% set jqfilter = '[[.items[] | select( .metadata.ownerReferences? // [] | all(.kind != "ClusterVersion")) | select(.metadata.labels[]? | select("samples.operator.openshift.io/managed: true") | not) | select(.spec.tags[]?.from.kind != "ImageStreamTag" and (.importPolicy.scheduled != null or .importPolicy.scheduled != false))] | any]' %}} | |||
{{% set jqfilter = '[[.items[] | ( .spec.tags[]?.from.kind != "ImageStreamTag" and ([.spec.tags[]? | (.importPolicy.scheduled == null or .importPolicy.scheduled == false)] | any) ) and ((.metadata.labels == null) or (.metadata.labels."samples.operator.openshift.io/managed" == null) or (.metadata.labels."samples.operator.openshift.io/managed" != "true")) and ((.metadata.ownerReferences == null) or (.metadata.ownerReferences | length == 0) or (.metadata.ownerReferences?[].kind == null) or (isempty(.metadata.ownerReferences?[] | select(.kind == "ClusterVersion"))))] | any]' %}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation:
- Get all ImageStreams:
.items[]
- Target user-defined streams only:
.spec.tags[]?.from.kind != "ImageStreamTag"
- Check for non-scheduled tags:
(.importPolicy.scheduled == null or .importPolicy.scheduled == false)] | any)
. - Ignore Sample Operator-managed streams:
((.metadata.labels == null) or (.metadata.labels."samples.operator.openshift.io/managed" == null) or (.metadata.labels."samples.operator.openshift.io/managed" != "true"))
. - Exclude system-managed ImageStreams:
((.metadata.ownerReferences == null) or (.metadata.ownerReferences | length == 0) or (.metadata.ownerReferences?[].kind == null) or (isempty(.metadata.ownerReferences?[] | select(.kind == "ClusterVersion"))
. - Summary: This detects user-managed, unmanaged, external ImageStreams that are not auto-updating.
- Final condition:
| any
returns true if any such non-compliant ImageStream exists.
Verification pass. |
/unhold |
/lgtm |
@KaushikOP Hi, looks good to me. Sorry for delay in picking this up. |
…ator and ClusterVersion Signed-off-by: Kaushik Talathi <kaushik.talathi1@ibm.com>
Signed-off-by: Kaushik Talathi <kaushik.talathi1@ibm.com>
Signed-off-by: Kaushik Talathi <kaushik.talathi1@ibm.com>
Enclosing the jqfilter in array and updating result as false. Signed-off-by: Kaushik Talathi <kaushik.talathi1@ibm.com>
Signed-off-by: Kaushik Talathi <kaushik.talathi1@ibm.com>
Hi @yuumasato, I have rebased this with upstream/master. |
@KaushikOP Sorry for delay, I got sick. There should be no merge commits in the PR: |
172e7ae
to
7b81ca2
Compare
/test all |
Code Climate has analyzed commit 7b81ca2 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 61.9% (0.0% change). View more on Code Climate. |
Description:
Rationale:
fixes failing rule
Fixes #CMP-2859
Review Hints: