Skip to content
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 workspace output when enter into home workspace #2830

Closed
wants to merge 1 commit into from

Conversation

qiujian16
Copy link
Contributor

Summary

the workspace output when run kubectl ws "~" is not user friendly.

I was

$ k ws "~"
Current workspace is "kvdk2spgmbix".

with the fix, it is changed to

$ kubectl ws "~"
Current workspace is "user:kcp-admin".

Related issue(s)

Fixes #2737

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 22, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ncdc for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@s-urbaniak
Copy link
Contributor

some unit tests failed, maybe these are related?

@davidfestal
Copy link
Member

some unit tests failed, maybe these are related?

In any case it would be great to ensure there is a unit test covering the fixed bug.

@qiujian16
Copy link
Contributor Author

test updated. actually the original test case should cover this, but th cluster annotation set in the test case is not the same as what it is in the real server.

@@ -753,7 +753,7 @@ func TestUse(t *testing.T) {
AuthInfos: map[string]*clientcmdapi.AuthInfo{"test": {Token: "test"}},
},
existingObjects: map[logicalcluster.Name][]string{
core.RootCluster: {"~"},
core.RootCluster: {"~", homeWorkspaceLogicalCluster.String()},
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand why this addition is necessary.
Afaict, it the failing case would be better tested if we distinguish between homeWorkspaceLogicalCluster name and homeWorkspaceLogicalCluster hierarchical path. Afaik for now we use the same value (path everywhere). But the failing test was precisely related to the fact that those 2 values are different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not necessary, removed.

Copy link
Member

Choose a reason for hiding this comment

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

Afaict, it the failing case would be better tested if we distinguish between homeWorkspaceLogicalCluster name and homeWorkspaceLogicalCluster hierarchical path. Afaik for now we use the same value (path everywhere). But the failing test was precisely related to the fact that those 2 values are different.

what about this part of my comment ?

Signed-off-by: Jian Qiu <jqiu@redhat.com>
@@ -215,8 +215,21 @@ func (o *UseWorkspaceOptions) Run(ctx context.Context) error {
if err != nil {
return err
}
newServerHost = homeWorkspace.Spec.URL

u, homeCluster, err := pluginhelpers.ParseClusterURL(homeWorkspace.Spec.URL)
Copy link
Member

Choose a reason for hiding this comment

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

homeWorkspace.Spec.URL has the path. We just have to extract it from the URL. We have a helper here somewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Would rather not go through the LogicalCluster for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not think currently the value lf homeWorkspace.Spec.URL is the same as path annotation in LogicalCluster. homeWorkspace.Spec.URL is https://xxx/clusters/kvdk2spgmbix while path annotation is user:kcp-admin. Should homeWorkspace.Spec.URL be https://xxx/clusters/user:kcp-admin?

Copy link
Member

Choose a reason for hiding this comment

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

Would rather not go through the LogicalCluster for that.

@sttts what would be an alternate solution ?

Copy link
Member

Choose a reason for hiding this comment

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

Should homeWorkspace.Spec.URL be https://xxx/clusters/user:kcp-admin?

Yes, I think it should.

Copy link
Member

@davidfestal davidfestal Feb 23, 2023

Choose a reason for hiding this comment

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

Ah, so that means that the problem is at a different level, when this URL is set in the Spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sttts would you check if #2846 is the appropriate way.

@pdettori
Copy link
Contributor

I tested this PR and it does resolve issue #2737

@ncdc
Copy link
Member

ncdc commented Mar 3, 2023

Replaced by #2846

@ncdc ncdc closed this Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: kcp bind compute does not work as expected for locations on a different workspace
6 participants