Skip to content

Commit

Permalink
bugfix: proxy rejects calls when UserSignup is not in a ready state a…
Browse files Browse the repository at this point in the history
…ttempt 3 (#346)

* attempt fix issue with space provisioning

* fix unit test

* avoid checking for usersignup complete status in proxy

* fix linter

* remove checkUserSignupCompleted from GetSignup

* Update pkg/proxy/service/cluster_service.go

Co-authored-by: Alexey Kazakov <[email protected]>

* address pr comments

* disable signup complete check for list user workspaces

* Update pkg/proxy/handlers/spacelister.go

* Update pkg/proxy/handlers/spacelister.go

---------

Co-authored-by: Alexey Kazakov <[email protected]>
  • Loading branch information
mfrancisc and alexeykazakov authored Sep 12, 2023
1 parent d5ffd83 commit 4c7bceb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/proxy/handlers/spacelister.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ func (s *SpaceLister) ListUserWorkspaces(ctx echo.Context) ([]toolchainv1alpha1.
userID, _ := ctx.Get(context.SubKey).(string)
username, _ := ctx.Get(context.UsernameKey).(string)

signup, err := s.GetSignupFunc(nil, userID, username, true)
signup, err := s.GetSignupFunc(nil, userID, username, false)
if err != nil {
ctx.Logger().Error(errs.Wrap(err, "error retrieving signup"))
return nil, err
}
if signup == nil || !signup.Status.Ready {
// account exists but is not ready so return an empty list
if signup == nil || signup.CompliantUsername == "" {
// account exists but the compliant username is not set yet, meaning it has not been fully provisioned yet, so return an empty list
return []toolchainv1alpha1.Workspace{}, nil
}

Expand Down
19 changes: 17 additions & 2 deletions pkg/proxy/handlers/spacelister_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ func TestHandleSpaceListRequest(t *testing.T) {
expectedErrCode: 404,
},
"signup not ready yet": {
username: "movie.lover",
expectedWs: []toolchainv1alpha1.Workspace{
workspaceFor(t, fakeClient, "movielover", "admin", true),
},
expectedErr: "",
expectedWorkspace: "movielover",
},
"signup has no compliant username set": {
username: "racing.lover",
expectedWs: []toolchainv1alpha1.Workspace{},
expectedErr: "",
Expand Down Expand Up @@ -224,14 +232,21 @@ func TestHandleSpaceListRequest(t *testing.T) {
}

func newSignup(signupName, username string, ready bool) fake.SignupDef {
return fake.Signup(signupName, &signup.Signup{
compliantUsername := signupName
if !ready {
// signup is not ready, let's set compliant username to blank
compliantUsername = ""
}
us := fake.Signup(signupName, &signup.Signup{
Name: signupName,
CompliantUsername: signupName,
Username: username,
CompliantUsername: compliantUsername,
Status: signup.Status{
Ready: ready,
},
})

return us
}

func getFakeInformerService(fakeClient client.Client) func() service.InformerService {
Expand Down

0 comments on commit 4c7bceb

Please sign in to comment.