-
Notifications
You must be signed in to change notification settings - Fork 33
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
allow for approved status false after user sign up deactivated #351
allow for approved status false after user sign up deactivated #351
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mmulholla The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @mmulholla. Thanks for your PR. I'm waiting for a codeready-toolchain 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/test-infra repository. |
/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.
I think the unit tests should be updated to.
pkg/signup/service/signup_service.go
Outdated
@@ -438,7 +438,8 @@ func (s *ServiceImpl) DoGetSignup(ctx *gin.Context, provider ResourceProvider, u | |||
// Check UserSignup status to determine whether user signup is complete | |||
approvedCondition, approvedFound := condition.FindConditionByType(userSignup.Status.Conditions, toolchainv1alpha1.UserSignupApproved) | |||
completeCondition, completeFound := condition.FindConditionByType(userSignup.Status.Conditions, toolchainv1alpha1.UserSignupComplete) | |||
if !approvedFound || !completeFound || approvedCondition.Status != apiv1.ConditionTrue { | |||
if !approvedFound || !completeFound || | |||
( approvedCondition.Status != apiv1.ConditionTrue && approvedCondition.Reason != toolchainv1alpha1.UserSignupUserDeactivatedReason) { |
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 we should replace it by:
( approvedCondition.Status != apiv1.ConditionTrue && approvedCondition.Reason != toolchainv1alpha1.UserSignupUserDeactivatedReason) { | |
condition.IsFalseWithReason(userSignup.Status.Conditions, toolchainv1alpha1.UserSignupApproved, toolchainv1alpha1.UserSignupPendingApprovalReason { |
This is the actual condition we set for UserSignup when it's pending approval:
- reason: PendingApproval
status: "False"
type: Approved
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 can do that if you prefer but my concern would be that is is more strict than the current code which could lead to other behavior changes.
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.
Yeah, I still think it's better to rely on the PendingApproval
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.
Updated
pkg/signup/service/signup_service.go
Outdated
approvedCondition, approvedFound := condition.FindConditionByType(userSignup.Status.Conditions, toolchainv1alpha1.UserSignupApproved) | ||
completeCondition, completeFound := condition.FindConditionByType(userSignup.Status.Conditions, toolchainv1alpha1.UserSignupComplete) | ||
if !approvedFound || !completeFound || approvedCondition.Status != apiv1.ConditionTrue { | ||
if !approvedFound || !completeFound || | ||
(approvedCondition.Status != apiv1.ConditionTrue && approvedCondition.Reason != toolchainv1alpha1.UserSignupUserDeactivatedReason) { |
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.
EDIT: I misread the conditions - all good ;-)
this would mean that if the approved is found, but the status is not true (is pending approval), then the if statement would be evaluated as "false", which would mean (in this context) as approved, which is wrong, right?
Please try to play with the condition.
package - you may found some useful functions there that could simplify it.
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'm idiot 🤦♂️
It's Monday and I cannot read the if statement correctly. Your version should work fine.
Could you please add/update some unit tests?
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.
Have updated the tests.
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.
Also changed the if statement per Alexey's comment .
@mmulholla: The following test failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@@ -1093,7 +1093,8 @@ func (s *TestSignupServiceSuite) TestGetSignupDeactivated() { | |||
// given | |||
s.ServiceConfiguration(configuration.Namespace(), true, "", 5) | |||
|
|||
us := s.newUserSignupCompleteWithReason("Deactivated") | |||
us := s.newUserSignupComplete() | |||
us.Status.Conditions = deactivated() |
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.
Maybe I'm missing something but this test doesn't seem to check the signup
payload status in lines 1132-1133. So it doesn't really test the changed signup service. Could you please add it to the test? Check the status.
Had to rename the branch because it was picking up the toolchain-e2e branch in my fork which was causing failures but are needed for host-operator changes. New PR is: #354 |
Fix required for: codeready-toolchain/host-operator#868
it should not cause a regression because this condition:
approvedCondition.Reason != toolchainv1alpha1.UserSignupUserDeactivatedReason
can only be true without codeready-toolchain/host-operator#868
This is the issue it fixes as a result of codeready-toolchain/host-operator#868