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

refactor: re-define vfolder delete status #1892

Merged
merged 27 commits into from
Feb 22, 2024
Merged

Conversation

fregataa
Copy link
Member

@fregataa fregataa commented Feb 6, 2024

refs #767
related to lablup/backend.ai-webui#2204

!! MUST

  • do alembic migration upgrade. ./py -m alembic upgrade head
  • DON'T FORGET to stamp. ./py -m alembic stamp head
  • You must stamp even when you revert the DB schema to main. ./py -m alembic downgrade -1, ./py -m alembic stamp a5319bfc7d7c

Updates

  • Add delete-pending, delete-error vfolder status
  • Set delete-pending status as a "trash-bin" stataus
  • Set delete-complete status as vfolder hard delete in storage proxy
  • Replace deleted-complete to delete-pending
  • Rename recover API to restore. Because recover is a more appropriate term when you want to retrieve a file or data after you lose it, and restore is more often used when you want to return to a certain point in time or state.

Updated/Added API

  • DELETE /folders now accepts any of vfolder_id, vfolderId, id parameter and the response contains success message
curl --location --request DELETE 'MANAGER_ENDPOINT/folders' \
--header 'Content-Type: application/json' \
--data '{
    "vfolder_id": "VFOLDER_ID"
    # or "vfolderId", "id"
}'
  • POST /folders/restore-from-trash-bin restores soft-deleted vfolders(aka trash-bin) into ready state.
curl --location 'MANAGER_ENDPOINT/folders/restore-from-trash-bin' \
--header 'Content-Type: application/json' \
--data '{
    "vfolder_id": "VFOLDER_ID"
}'
  • POST /folders/delete-from-trash-bin permanently deletes vfolders in storage.
curl --location 'MANAGER_ENDPOINT/folders/delete-from-trash-bin' \
--header 'Content-Type: application/json' \
--data '{
    "vfolder_id": "VFOLDER_ID"
}'
  • POST /folders/<NAME>/purge change to POST /folders/purge and get vfolder_id parameter
curl --location 'MANAGER_ENDPOINT/folders/purge' \
--header 'Content-Type: application/json' \
--data '{
    "vfolder_id": "VFOLDER_ID"
}'

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue
  • API server-client counterparts (e.g., manager API -> client SDK)
  • Test case(s) to:
    • Demonstrate the difference of before/after
    • Demonstrate the flow of abstract/conceptual models with a concrete implementation
  • Documentation
    • Contents in the docs directory
    • docstrings in public interfaces and type annotations

@fregataa fregataa added this to the 24.03 milestone Feb 6, 2024
@fregataa fregataa requested a review from achimnol February 6, 2024 11:16
@fregataa fregataa self-assigned this Feb 6, 2024
@github-actions github-actions bot added comp:storage-proxy Related to Storage proxy component type:feature Add new features comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated size:L 100~500 LoC labels Feb 6, 2024
@github-actions github-actions bot added the comp:client Related to Client component label Feb 7, 2024
@github-actions github-actions bot added size:XL 500~ LoC and removed size:L 100~500 LoC labels Feb 7, 2024
@fregataa fregataa marked this pull request as ready for review February 7, 2024 05:48
@github-actions github-actions bot added the urgency:4 As soon as feasible, implementation is essential. label Feb 11, 2024
@fregataa fregataa requested a review from agatha197 February 14, 2024 05:43
@fregataa fregataa added the comp:cli Related to CLI component label Feb 15, 2024
@fregataa fregataa requested a review from kyujin-cho February 16, 2024 02:09
print_error(e)
sys.exit(ExitCode.FAILURE)


@vfolder.command()
@click.argument("name", type=str)
def recover(name):
Copy link
Member

Choose a reason for hiding this comment

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

Let's rename this to restore and keep the alias for backward compatibility.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added restore command right below(line no 236) and left this for backward compatibility.

Comment on lines 120 to 121
pydantic_params_api_handler,
pydantic_response_api_handler,
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to rename these to:

  • pydantic_api_params_handler
  • pydantic_api_reponse_handler

for consistency with composite nouns in a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

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

Let's postpone this refactoring to a follow-up PR.

await ensure_vfolder_status(
request, VFolderAccessStatus.HARD_DELETABLE, folder_id_or_name=folder_id
)
async with root_ctx.db.begin() as conn:
Copy link
Member

Choose a reason for hiding this comment

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

This could be also a readonly connection or transaction.

@@ -3296,14 +3446,13 @@ def create_app(default_cors_options):
vfolder_resource = cors.add(app.router.add_resource(r"/{name}"))
cors.add(vfolder_resource.add_route("GET", get_info))
cors.add(vfolder_resource.add_route("DELETE", delete_by_name))
cors.add(add_route("GET", r"/{name}/id", get_vfolder_id))
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to move the name parameter to a query param.

Since /folders/{name} may conflict with /folders/{invitations,purge,restore-from-trash-bin,delete-from-trash-bin}, I'd suggest using a new app prefix: /vfolders/ for new UUID-based API routes.

Copy link
Member

Choose a reason for hiding this comment

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

Let's postpone this refactoring to a follow-up PR.

@achimnol achimnol added this pull request to the merge queue Feb 22, 2024
Merged via the queue into main with commit f5a8bbf Feb 22, 2024
26 checks passed
@achimnol achimnol deleted the refactor/vfolder-delete-status branch February 22, 2024 06:54
achimnol added a commit that referenced this pull request Feb 28, 2024
- It is a follow-up to #1892 and #1936.
- Adds `index=True` to the `kernels.role` column to avoid mismatch of DB
  and migrations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:cli Related to CLI component comp:client Related to Client component comp:manager Related to Manager component comp:storage-proxy Related to Storage proxy component require:db-migration Automatically set when alembic migrations are added or updated size:XL 500~ LoC type:feature Add new features urgency:4 As soon as feasible, implementation is essential.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants