-
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
fix: add spacebindingrequests to workspace binding list #387
fix: add spacebindingrequests to workspace binding list #387
Conversation
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.
great job! just a few nits
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #387 +/- ##
==========================================
+ Coverage 78.03% 78.40% +0.37%
==========================================
Files 38 38
Lines 3223 3306 +83
==========================================
+ Hits 2515 2592 +77
- Misses 616 620 +4
- Partials 92 94 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-authored-by: Francesco Ilario <filario@redhat.com>
Co-authored-by: Francesco Ilario <filario@redhat.com>
/retest |
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
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 one optional thing that might be beneficial.
@@ -77,9 +79,16 @@ func GetUserWorkspace(ctx echo.Context, spaceLister *SpaceLister, workspaceName | |||
ctx.Logger().Error(fmt.Sprintf("unauthorized access - there is no SpaceBinding present for the user %s and the workspace %s", userSignup.CompliantUsername, workspaceName)) | |||
return nil, nil | |||
} | |||
|
|||
// list all SpaceBindingRequests , just in case there might be some failing to create a SpaceBinding resource. | |||
allSpaceBindingRequests, err := listSpaceBindingRequestsForSpace(ctx, GetMembersFunc, space) |
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 a bit concerned about adding even more stuff to the GetUserWorkspace()
function. This function is currently used not only in our WS lister API but it's called for every request to the proxy in case there is a workspace context in the request. And we don't care about failed SBRs in that case (or even about the available user roles either btw).
Maybe it's time to split this function to two? One to remain a lightweight version for the general proxy requests and and with all additional information for the WS lister. Or make this function flexible/configurable so it can be used everywhere.
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.
Makes sense. Let me take a look an split it so that proxy request do not have to populate the bindings list. Thanks for the suggestion.
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.
@alexeykazakov @MatousJobanek I've created 2 functions GetUserWorkspace
used by proxy only and GetUserWorkspaceWithBindings
used by the spacelister.
Please take a look when you have some time.
PS: there is one new error condition which is not tested 574d4eb#diff-23bf3528567b934bf6ab8d0d690dc61a0ac564ba1b43b89cb5ddde609bb150b1R75-R79 , I can add a specific test in the proxy_test.go
as I'm not sure where that should go in the current TestProxy
since it's more a combination of different headers and requests.
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.
It's not that important where you add this test. Add it to whatever place you think makes sense. But let's add a test for it if it's not too tricky.
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've added a specific test for this error condition in 98d2640
Co-authored-by: Andy Sadler <ansadler@redhat.com>
# Conflicts: # go.mod # go.sum # pkg/proxy/proxy.go
# Conflicts: # go.mod # go.sum
space, err := spaceLister.GetInformerServiceFunc().GetSpace(workspaceName) | ||
if err != nil { | ||
ctx.Logger().Error(errs.Wrap(err, "unable to get space")) | ||
return userSignup, nil, nil |
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 returning nil
instead of err
?
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've left the functionality unchanged
registration-service/pkg/proxy/handlers/spacelister_get.go
Lines 52 to 56 in 81de976
space, err := spaceLister.GetInformerServiceFunc().GetSpace(workspaceName) | |
if err != nil { | |
ctx.Logger().Error(errs.Wrap(err, "unable to get space")) | |
return nil, nil | |
} |
I see we return 404 when when usersignup and space are not found.
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.
Then let's add a comment to the function description stating that if no space found then a "nil" returned instead of an error.
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.
makes sense. Done 52690f3
# Conflicts: # pkg/proxy/handlers/spacelister_test.go
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 good overall but it looks like we could add more unit tests.
Could you please take a look at the codecov report and cover the missing cases when it's not too tricky?
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
@alexeykazakov thanks for pointing that out, I've added some more unit tests to cover the error cases, please take a look at 1c1fa6f |
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 good. Thanks.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexeykazakov, filariow, mfrancisc, sadlerap 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 |
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 8 New issues |
Users are unable to manage SpaceBindingRequests that are not provisioned ( meaning there is no SpaceBinding associated with it).
This PR adds the SpaceBindingRequests ( that have no SpaceBinding associated) to the list of Bindings in the Workspace, so that RHTAP users can manage them from the UI.
Jira: https://issues.redhat.com/browse/ASC-443
Related PR:
TODO: