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

[Workspace] Delete saved objects by workspace #6013

Merged
merged 10 commits into from
Mar 11, 2024

Conversation

Hailong-am
Copy link
Collaborator

@Hailong-am Hailong-am commented Mar 4, 2024

Description

Add delete saved objects by workspace functionality. When delete workspace we need delete all saved objects under this workspace.

Issues Resolved

Partial of #4944
Closes #6016

Screenshot

Testing the changes

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

* Delete saved objects by workspace

Signed-off-by: Hailong Cui <[email protected]>

fix osd boostrap

Signed-off-by: Hailong Cui <[email protected]>

* add unit test

Signed-off-by: Hailong Cui <[email protected]>

* fix can't delete workspace due to invalid permission

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.12%. Comparing base (8f0885d) to head (2f3418c).
Report is 613 commits behind head on main.

Files with missing lines Patch % Lines
...rver/saved_objects/service/saved_objects_client.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6013      +/-   ##
==========================================
- Coverage   67.14%   67.12%   -0.02%     
==========================================
  Files        3324     3324              
  Lines       64309    64318       +9     
  Branches    10341    10344       +3     
==========================================
- Hits        43182    43176       -6     
- Misses      18604    18618      +14     
- Partials     2523     2524       +1     
Flag Coverage Δ
Linux_1 31.66% <0.00%> (-0.01%) ⬇️
Linux_2 55.23% <88.88%> (+0.01%) ⬆️
Linux_3 44.70% <0.00%> (-0.01%) ⬇️
Linux_4 35.08% <11.11%> (-0.01%) ⬇️
Windows_1 31.68% <0.00%> (-0.04%) ⬇️
Windows_2 55.20% <88.88%> (+0.01%) ⬆️
Windows_3 44.70% <0.00%> (-0.02%) ⬇️
Windows_4 35.08% <11.11%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SuZhou-Joe
Copy link
Member

A quick question that it seems all the changes are happening on server side, will we add a new public method like deleteByWorkspace in public/workspace.client?

@Hailong-am
Copy link
Collaborator Author

A quick question that it seems all the changes are happening on server side, will we add a new public method like deleteByWorkspace in public/workspace.client?

No, this's part of delete workspace logic at server side. There will have a public method delete in public/workspaceClient which will call delete method at server side.

src/core/server/saved_objects/service/lib/repository.ts Outdated Show resolved Hide resolved
* @returns {promise} - { took, timed_out, total, deleted, batches, version_conflicts, noops, retries, failures }
*/
async deleteByWorkspace(
workspace: string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it taking the workspace name or id as the param ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

if it's actually taking the id maybe let's try to name like workspaceId or add the detail in the comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

make sense. As we are using workspace everywhere to reference as its id, to make the name consistent, let me add this to parameter comment.

@Hailong-am
Copy link
Collaborator Author

link check failed due to http://fakenews.co/opensearch-dashboards-test/v6.8.2.json is not reachable in this file src/plugins/newsfeed/public/lib/api.test.ts

Errors in src/plugins/newsfeed/public/lib/api.test.ts
+ echo
+ echo ::set-output name=exit_code::2
✗ http://fakenews.co/opensearch-dashboards-test/v6.8.2.json (error sending request for url (http://fakenews.co/opensearch-dashboards-test/v6.8.2.json): connection closed before message completed)
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/```

@@ -30,6 +30,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multiple Datasource] Add Vega support to MDS by specifying a data source name in the Vega spec ([#5975](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5975))
- [Workspace] Consume workspace id in saved object client ([#6014](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6014))

Copy link
Member

Choose a reason for hiding this comment

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

Nit: useless empty line

@SuZhou-Joe SuZhou-Joe merged commit 735424b into opensearch-project:main Mar 11, 2024
67 of 68 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-6013-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 735424bcaabfc752453c4d514ddd5d4b4f1b6d6d
# Push it to GitHub
git push --set-upstream origin backport/backport-6013-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-6013-to-2.x.

Hailong-am added a commit to Hailong-am/OpenSearch-Dashboards that referenced this pull request Apr 12, 2024
* [API] Delete saved objects by workspace (opensearch-project#216)

* Delete saved objects by workspace

Signed-off-by: Hailong Cui <[email protected]>

fix osd boostrap

Signed-off-by: Hailong Cui <[email protected]>

* add unit test

Signed-off-by: Hailong Cui <[email protected]>

* fix can't delete workspace due to invalid permission

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* update test case

Signed-off-by: Hailong Cui <[email protected]>

* Add change log

Signed-off-by: Hailong Cui <[email protected]>

* update change log format

Signed-off-by: Hailong Cui <[email protected]>

* update method comments to make it more clear

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>
(cherry picked from commit 735424b)
SuZhou-Joe added a commit that referenced this pull request Apr 14, 2024
* [Workspace] Delete saved objects by workspace (#6013)

* [API] Delete saved objects by workspace (#216)

* Delete saved objects by workspace

Signed-off-by: Hailong Cui <[email protected]>

fix osd boostrap

Signed-off-by: Hailong Cui <[email protected]>

* add unit test

Signed-off-by: Hailong Cui <[email protected]>

* fix can't delete workspace due to invalid permission

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* update test case

Signed-off-by: Hailong Cui <[email protected]>

* Add change log

Signed-off-by: Hailong Cui <[email protected]>

* update change log format

Signed-off-by: Hailong Cui <[email protected]>

* update method comments to make it more clear

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>
(cherry picked from commit 735424b)

* Update CHANGELOG.md

Co-authored-by: SuZhou-Joe <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>
Co-authored-by: SuZhou-Joe <[email protected]>
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-6013-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 735424bcaabfc752453c4d514ddd5d4b4f1b6d6d
# Push it to GitHub
git push --set-upstream origin backport/backport-6013-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-6013-to-2.x.

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.

[Workspace] Support delete saved objects by workspace
5 participants