Skip to content

Add user tag to AWS and GCP volumes#1948

Merged
r4victor merged 17 commits intodstackai:masterfrom
james-boydell:1943_add_user_tag_to_aws_volumes
Nov 5, 2024
Merged

Add user tag to AWS and GCP volumes#1948
r4victor merged 17 commits intodstackai:masterfrom
james-boydell:1943_add_user_tag_to_aws_volumes

Conversation

@james-boydell
Copy link
Copy Markdown
Contributor

@james-boydell james-boydell commented Nov 3, 2024

fixes: #1943

-extended to gcp as well

- create volume now requires a user of type UserModel to be passed in
- db for volumes should have column for user_id
-only passing back the user name when creating the volume
@james-boydell james-boydell marked this pull request as ready for review November 3, 2024 01:50
@r4victor
Copy link
Copy Markdown
Collaborator

r4victor commented Nov 4, 2024

@james-boydell, I also recommend running Python tests locally for a faster feedback loop. It should be fairly simple to set up: install deps from requirements_dev.txt and run pytest src/tests/.

@r4victor r4victor changed the title 1943 add user tag to aws volumes Add user tag to AWS and GCP volumes Nov 5, 2024
@r4victor
Copy link
Copy Markdown
Collaborator

r4victor commented Nov 5, 2024

@james-boydell, thanks for the PR, nice work! I added a commit to handle backward compatibility. Merging it.

The loading is required everywhere VolumeModel is converted to Volume.
If not loaded, the server errors when processing/returning other users' volumes.
E.g. when global admins lists all volumes.
@r4victor
Copy link
Copy Markdown
Collaborator

r4victor commented Nov 5, 2024

Found missing VolumeModel.user loading in few places. Fixed it.

@r4victor r4victor merged commit 003d30b into dstackai:master Nov 5, 2024
@james-boydell james-boydell deleted the 1943_add_user_tag_to_aws_volumes branch November 5, 2024 15:28
superprat pushed a commit to bahaal-tech/dstack that referenced this pull request Dec 20, 2024
* update volumes model

* generate db migration

* add user field to Volume class

* update volume service

- create volume now requires a user of type UserModel to be passed in
- db for volumes should have column for user_id
-only passing back the user name when creating the volume

* update router

* tag aws volume with dstack user that created it

* add datack user to gcp volume label

* updating tests

* updating on how user is fetched

* updating tests

* update data migration to update volume user_id based on project.owner_id

* update volume model to remove lazy join

* regenerate migration

* join in users

* Set default Volume.user for client backward compatibility

* Load VolumeModel.user

The loading is required everywhere VolumeModel is converted to Volume.
If not loaded, the server errors when processing/returning other users' volumes.
E.g. when global admins lists all volumes.

* Fix VolumeModel.user loading on postgres

---------

Co-authored-by: Victor Skvortsov <vds003@gmail.com>
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.

[Feature]: Add dstack_user tag to AWS volumes

2 participants