-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add relatedObjs to unnamed musthave object #182
Add relatedObjs to unnamed musthave object #182
Conversation
4aa40f9
to
14c59de
Compare
test/e2e/case37_no_name_test.go
Outdated
case37PolicyCSName string = "case37-test-policy-clusterscope" | ||
) | ||
|
||
var _ = Describe("Test a namespace-scope policy that is missing name ", Ordered, func() { |
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.
These tests look great! I see tests for objects when it is compliant and when it is non-compliant (I was worried just looking through the code that it only covered one of those cases).
Do these changes also address similar cases for mustnothave
policies?
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.
if objShouldExist {
.
.
.
if objDetails.kind != "" && objDetails.name == "" {
It doesn't affect mustnothave
. I thought mustnothave
ok
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.
I think when a mustnothave
policy is Compliant, it would have a similar situation: its relatedObjects list would be empty. It doesn't look like it's necessary to address that for this issue, but it's something to consider in the future. I think it could be nice if there was always something in that list.
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.
Can you give me example relatedObjects when it is mustnothave
? To me.. it is mustnothave
so it is right that it should not show anything
57af0a8
to
3eb1cd4
Compare
|
||
// Change reason to Resource found but does not match | ||
if len(objNames) > 0 { | ||
shouldAddCondensedRelatedObj = true |
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.
Why not just always set this to true instead of duplicating the list query performed in getNamesOfKind
?
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.
len(objNames) == 0 there is nothing to show on relatedobj. In other words, there is nothing to debug
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.
I'd prefer if whenever the object template is not named and it's noncompliant, you just set shouldAddCondensedRelatedObj = true
. Perhaps there are no objects, but that's okay. It makes the behavior consistent.
Also, I'm not sure if reasonWantFoundNoMatch
is better than reasonWantFoundDNE
, so if that's why you are duplicating the list query by calling getNamesOfKind
again, then it's not worth it in my opinion.
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.
um... to me, reasonWantFoundNoMatch
is better. Because the name is * in relatedObj and users only see the reason
on the console. reasonWantFoundNoMatch
is for relatedObj.. isn't it? @JustinKuli how about yoiu
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.
After this poll, we should decide mustnothave
reason too
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.
Sorry for slow response, if you're still looking for input, I think reasonWantFoundNoMatch
makes more sense when the name is *
. It doesn't make as much sense to say something "resource *, not found" when some instances of that resource do exist.
So for mustnothave
, same kind of thing: if the names would be *
or something similar, because some resources were found they just didn't fully match the policy criteria, then use a NoMatch
kind of reason.
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.
@JustinKuli Thanks!
e82f43c
to
8c2868d
Compare
01ab83e
to
8d7b9ae
Compare
ebbd1c7
to
78d9c3f
Compare
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.
/hold
Looks good to me! I'm not sure if Matt had any remaining requirements
78d9c3f
to
410e9b9
Compare
b72dc03
to
615a10f
Compare
test/e2e/case37_no_name_test.go
Outdated
case37PolicyMustnothaveName, testNamespace, true, defaultTimeoutSeconds) | ||
Expect(plc).ShouldNot(BeNil()) | ||
}) | ||
It("should have 0 Compliant relatedObject under the policy's status", func() { |
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.
I don't think this is correctly describing the test since it's expecting related objects to have a length of 1. Could you please reword it?
test/e2e/case37_no_name_test.go
Outdated
return utils.GetComplianceState(managedPlc) | ||
}, defaultTimeoutSeconds, 1).Should(Equal("Compliant")) | ||
|
||
By("relatedObjects should not exist") |
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.
By("relatedObjects should not exist") | |
By("relatedObjects should exist") |
test/e2e/case37_no_name_test.go
Outdated
// Getting relatedObjects takes longer time | ||
}, defaultTimeoutSeconds*2, 1).Should(HaveLen(1)) | ||
|
||
By("Check the reasons of relatedObjects") |
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.
By("Check the reasons of relatedObjects") | |
By("Check the reason of the related object") |
|
||
By("Check the reason of relatedObjects") | ||
reason := relatedObjects[0].(map[string]interface{})["reason"].(string) | ||
Expect(reason).Should(Equal("Resource found but should not exist")) |
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.
Could you please also test that the name is not *
here?
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.
This looks great! Just a few minor comments in the tests.
615a10f
to
0063245
Compare
Ref: https://issues.redhat.com/browse/ACM-8782 Signed-off-by: Yi Rae Kim <yikim@redhat.com>
0063245
to
bc3883d
Compare
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.
Looks great!
/hold for @JustinKuli to take another look
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.
/unhold
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JustinKuli, mprahl, yiraeChristineKim 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 |
7529c90
into
open-cluster-management-io:main
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.
@yiraeChristineKim I think this file shouldn't have been merged. Can you revert this, please?
What the user wants:
When the object, even if no having name, turns compliant, appears in the list. We can see the object of Kind Node, compliant, and it does not match any specific name of the Kind object.
Ref: https://issues.redhat.com/browse/ACM-8782