Skip to content

Conversation

migmartri
Copy link
Member

@migmartri migmartri commented Dec 1, 2023

Being able to leave an organization

  • Remove membership
  • Delete the organization if the currentUser is the only member
chainloop org leave --id 669dbbda-9bd0-4f44-b970-254287c9e1d8
You are about to leave the organization "shared-org"
To confirm, please type "J9RY-93XU"
INF Membership deleted

closes #414

Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
@migmartri migmartri marked this pull request as ready for review December 1, 2023 21:11
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
}

if len(membershipsInOrg) == 0 {
// Delete the org
Copy link
Contributor

Choose a reason for hiding this comment

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

Just an architectural question, to make sure I understand everything well.

What happens if, in between the membership deletion and the org deletion, some other membership is created? Where are these races being handled?

Copy link
Member Author

@migmartri migmartri Dec 4, 2023

Choose a reason for hiding this comment

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

Good question; they are not handled. I thought about this one, and to solve it, we'll need to move most of this logic to the data layer, where we could leverage ent transactions.

I just thought that the possibility of this race was very, very low and not worth the implementation in this first pass. That said, I'll create an issue for it so we don't forget.

Copy link
Contributor

@buccarel buccarel left a comment

Choose a reason for hiding this comment

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

Looks good to me.
I just asked a question for my own understanding.

@migmartri migmartri merged commit fc04f06 into chainloop-dev:main Dec 4, 2023
@migmartri migmartri deleted the leave-subscription branch December 4, 2023 15:20
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.

Allow leaving organization
2 participants