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

[papi] migrate ListWorkspaces and WatchWorkspaceStatus #19022

Merged
merged 2 commits into from
Nov 16, 2023
Merged

Conversation

mustard-mh
Copy link
Contributor

@mustard-mh mustard-mh commented Nov 7, 2023

Description

  • Add ListWorkspaces proto
  • Update dashboard to use ListWorkspaces and WatchWorkspaceStatus
Summary generated by Copilot

🤖 Generated by Copilot at d01aa12

Added a new feature to list workspaces by organization ID and other filters. This involved adding new methods and types to the public API, the connect protocol, the workspace service, and the workspace database layer. The files workspace.proto, workspace_pb.ts, workspace.connect.go, workspace_connect.ts, workspace-service-api.ts, workspace-service.ts, workspace-db.ts, workspace-db-impl.ts, and workspace-db.spec.db.ts were modified or created to implement this feature. The files json-rpc-workspace-client.ts and workspace.proxy.connect.go were updated to use the new methods.

Related Issue(s)

Fixes #

How to test

  • Dashboard should work like before (except some field that we don't respond anymore. like workspace creationTime, context (git commit...))

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

// organization_id
string organization_id = 2;

optional bool pinned = 3;
Copy link
Member

Choose a reason for hiding this comment

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

for the admin case we need other filters as well as sorting. maybe we can generalize somehow?

@roboquat roboquat added size/XXL and removed size/L labels Nov 9, 2023
@mustard-mh mustard-mh changed the title [papi] add ListWorkspaces API [papi] add WorkspaceService proto Nov 10, 2023
@akosyakov
Copy link
Member

@mustard-mh Should not we invalidate react query caches?

@mustard-mh
Copy link
Contributor Author

mustard-mh Should not we invalidate react query caches?

I see, I did but after rebase it turns into the same value

Comment on lines 110 to 117
// http[s]?:\/\/(?<project>.*?\/.*?\/.*?)[./]
const regex = /http[s]?:\/\/(?<host>.*?)\/(?<owner>.*?)\/(?<name>.*?)[./]/gm;
const result = regex.exec(ws.status.gitStatus.cloneUrl);
if (!result) {
return ws.contextUrl.replace("https://", "");
}
const { host, owner, name } = result.groups!;
return `${host}/${owner}/${name}`;
Copy link
Member

Choose a reason for hiding this comment

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

This looks a bit scary 😆. Could we instead fail or return an empty string if we cannot get it from the context URL? Not sure how this would support the deeply-nested GitLab repos, which are not just /owner/repo.

Copy link
Contributor Author

@mustard-mh mustard-mh Nov 15, 2023

Choose a reason for hiding this comment

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

@filiptronicek Yes, it is, and for Gitlab it can be longer since it can define lots of subGroup.

But based on current shape of Workspace we only can do it like this. I'm not sure if we should change workspace shape or do other things

Copy link
Member

Choose a reason for hiding this comment

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

I'm still not sure that we shoudl parse like that or add something like Repository on Workspace? cc @svenefftinge

Copy link
Member

Choose a reason for hiding this comment

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

It looks good to me, and also is only used as a string to visualize.
I believe we have somewhere a function that translates the cloneURL to a shorter version.
IS this not just cutting off https:// and .git?

Copy link
Contributor Author

@mustard-mh mustard-mh Nov 15, 2023

Choose a reason for hiding this comment

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

Do you mean ContextURL.getNormalizedURL ? I can't find other function that may have this feature. But it will only cut some built-in prefix out and won't trim .git.

context-parser is only working with server now. We can use it after (will we?) introduce ContextService in papi

I'll change to use ContextURL.getNormalizedURL here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@svenefftinge for comment above ☝️

Copy link
Member

Choose a reason for hiding this comment

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

Ok

Copy link
Member

Choose a reason for hiding this comment

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

We have a RepoURL.parseRepoUrl function in server that does approximation parsing of owner and name. If that's what's needed, we could thing of pulling this out to protocol.

Otherwise, see RepositoryURL component in Dashboard if we just need a clean repo URL from a given clone URL.

components/dashboard/src/workspaces/WorkspaceEntry.tsx Outdated Show resolved Hide resolved
Comment on lines +56 to +64
// search_term is a search term to filter workspaces by name
string search_term = 4;
Copy link
Member

Choose a reason for hiding this comment

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

What is this actually searching? Is this the ID, description, repo details or something different? I think the comment should make it clear.

Copy link
Contributor Author

@mustard-mh mustard-mh Nov 15, 2023

Choose a reason for hiding this comment

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

to filter workspaces by name by name

qb.andWhere("ws.description LIKE :searchString", { searchString: `%${options.searchString}%` });

Copy link
Member

Choose a reason for hiding this comment

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

@mustard-mh in that case, can we please change to the following?

Suggested change
// search_term is a search term to filter workspaces by name
string search_term = 4;
// search_term is a search term to filter workspaces by description
string search_term = 4;

Copy link
Contributor Author

@mustard-mh mustard-mh Nov 15, 2023

Choose a reason for hiding this comment

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

We named it name now 😄

You can check new Workspace shape in this proto file

Copy link
Member

@svenefftinge svenefftinge Nov 16, 2023

Choose a reason for hiding this comment

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

Please keep it search_term and add a comment. The reason is that we want to stop creating a name from the context, but instead have no name and only when you pin a workspace you name it. So we should really search by git status information and name (and id as long as we expose it like we do).

Edit: ignore ☝️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@svenefftinge I don't understand. Do you mean to change comment that it can filter with git status , workspaceId and name?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, sorry. I missunderstood your comment that you named it name now as if you had changed the property name. So looks good now and we can update the docs once we change the implementation. Thank you!

@mustard-mh
Copy link
Contributor Author

mustard-mh commented Nov 16, 2023

Feedbacks addressed, @AlexTugarev could you help test again? 🙏

I have tested that watch and list is working in preview env

image

@AlexTugarev
Copy link
Member

AlexTugarev commented Nov 16, 2023

Screenshot 2023-11-16 at 13 05 18

When trying to rename a workspace item.

@mustard-mh, I broke it. The issue appears to be permanent. Cannot be resolved with a reload.

@mustard-mh
Copy link
Contributor Author

When trying to rename a workspace item.

mustard-mh, I broke it. The issue appears to be permanent. Cannot be resolved with a reload.

🙏 @AlexTugarev Fixed 3fc7b78

@mustard-mh
Copy link
Contributor Author

rebased to main

Copy link
Member

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

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

Workspace list was working fine in tests! Thanks!

Maybe test once more after rebase on main.

@akosyakov
Copy link
Member

Dashboard should work like before (except some field that we don't respond anymore. like workspace creationTime, context (git commit...))

@mustard-mh just to double check we do test the loading screen? it is affected right?

@mustard-mh
Copy link
Contributor Author

just to double check we do test the loading screen? it is affected right?

@akosyakov Yes, I tested it then found out that .aborted bug 🐛. Will double check after preview env is ready

@AlexTugarev
Copy link
Member

#19057 just landed. @mustard-mh, would it make sense to bump cache version in dashboard?

@mustard-mh
Copy link
Contributor Author

✅ Rebased again, double check that pin, share, status render (create)

/unhold

@roboquat roboquat merged commit 4324fcb into main Nov 16, 2023
15 checks passed
@roboquat roboquat deleted the hw/papi-list-ws branch November 16, 2023 18:44
@mustard-mh mustard-mh mentioned this pull request Nov 29, 2023
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants