Skip to content

fix: set user unready when no default ns #536

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/codeready-toolchain/api => github.com/mfrancisc/api v0.0.0-20250616123239-4c04c1fb9d8f
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtM
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/codeready-toolchain/api v0.0.0-20250506183835-ee4a91d0bca4 h1:m2OsrXpH1MieIg65FQQl3EV0oAyqNfIAYhW2TQnOrWY=
github.com/codeready-toolchain/api v0.0.0-20250506183835-ee4a91d0bca4/go.mod h1:20258od6i5+jP406Z76YaI2ow/vc7URwsDU2bokpkRE=
github.com/codeready-toolchain/toolchain-common v0.0.0-20250506093954-2b65ad3a2e12 h1:w54sojJJ8PsHZzK1mC+/EUBrQ9F2sC/k7JUVc8LSqK4=
github.com/codeready-toolchain/toolchain-common v0.0.0-20250506093954-2b65ad3a2e12/go.mod h1:TrMvD0sP69wI6Rouzfs7OsOUSj4CGn/ZiIdiDBAFQjk=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -268,6 +266,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mfrancisc/api v0.0.0-20250616123239-4c04c1fb9d8f h1:TrA2m+lpNhB0Dl483z0thJ1kI42z38i/wzFmbS0v56E=
github.com/mfrancisc/api v0.0.0-20250616123239-4c04c1fb9d8f/go.mod h1:20258od6i5+jP406Z76YaI2ow/vc7URwsDU2bokpkRE=
github.com/migueleliasweb/go-github-mock v0.0.18 h1:0lWt9MYmZQGnQE2rFtjlft/YtD6hzxuN6JJRFpujzEI=
github.com/migueleliasweb/go-github-mock v0.0.18/go.mod h1:CcgXcbMoRnf3rRVHqGssuBquZDIcaplxL2W6G+xs7kM=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
Expand Down
10 changes: 10 additions & 0 deletions pkg/signup/service/signup_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,16 @@ func (s *ServiceImpl) DoGetSignup(ctx *gin.Context, cl namespaced.Client, userna
signupResponse.DefaultUserNamespace = defaultNamespace
}

if defaultNamespace == "" {
// default namespace is not set, so we need to set the status to not ready
signupResponse.Status = signup.Status{
Ready: false,
Reason: toolchainv1alpha1.UserSignupNoDefaultNamespaceReason,
Message: "No default namespace found",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about this message instead?

Suggested change
Message: "No default namespace found",
Message: "Default namespace not available (yet)",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for @alexeykazakov's version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

VerificationRequired: states.VerificationRequired(userSignup),
}
}

return signupResponse, nil
}

Expand Down
30 changes: 30 additions & 0 deletions pkg/signup/service/signup_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,36 @@ func (s *TestSignupServiceSuite) TestGetSignupUpdatesUserSignupIdentityClaims()
})
}

func (s *TestSignupServiceSuite) TestGetSignupStatusNoDefaultNamespace() {
// given
s.ServiceConfiguration(true, "", 5)

username, us := s.newUserSignupComplete()
mur := s.newProvisionedMUR("ted")
toolchainStatus := s.newToolchainStatus(".apps.")
// Do NOT create any Space or SpaceBinding for this user
_, application := testutil.PrepareInClusterApp(s.T(), us, mur, toolchainStatus)

c, _ := gin.CreateTestContext(httptest.NewRecorder())

// when
response, err := application.SignupService().GetSignup(c, username, true)

// then
require.NoError(s.T(), err)
require.NotNil(s.T(), response)
assert.False(s.T(), response.Status.Ready)
assert.Equal(s.T(), toolchainv1alpha1.UserSignupNoDefaultNamespaceReason, response.Status.Reason)
assert.Equal(s.T(), "No default namespace found", response.Status.Message)
assert.Empty(s.T(), response.DefaultUserNamespace)
assert.Empty(s.T(), response.ConsoleURL)
assert.Empty(s.T(), response.CheDashboardURL)
assert.Empty(s.T(), response.APIEndpoint)
assert.Empty(s.T(), response.ClusterName)
assert.Empty(s.T(), response.ProxyURL)
assert.Empty(s.T(), response.RHODSMemberURL)
}

func (s *TestSignupServiceSuite) newUserSignupComplete() (string, *toolchainv1alpha1.UserSignup) {
return "ted@kubesaw", testusersignup.NewUserSignup(
testusersignup.WithEncodedName("ted@kubesaw"),
Expand Down
Loading