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

Prevent deletion of current droplet #3960

Conversation

philippthun
Copy link
Member

@philippthun philippthun commented Sep 9, 2024

DropletsController: check if droplet is in use (i.e. app's current droplet) and raise an ApiError (UnprocessableEntity)

Prepare for the introduction of a foreign key from apps.droplet_guid to droplets.guid:

  • DropletModel: handle ForeignKeyConstraintViolation and translate into ApiError (UnprocessableEntity)
  • AppModel: handle ForeignKeyConstraintViolation and translate into ValidationFailed error
  • DropletDelete: move destroy before other operations (deletion from blobstore, recording of event) so that an exception stops the control flow
  • AppDelete: clear droplet_guid (i.e. current droplet relation) before deleting subresources (incl. droplets)
  • AppAssignDroplet: handle ValidationFailed error and translate into already existing error
  • Adapt tests to also work with a foreign key
  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@philippthun philippthun linked an issue Sep 9, 2024 that may be closed by this pull request
@philippthun philippthun force-pushed the prevent-deletion-of-current-droplet branch 4 times, most recently from 0cd64e4 to bfe6010 Compare September 12, 2024 11:48
DropletsController: check if droplet is in use (i.e. app's current
droplet) and raise an ApiError (UnprocessableEntity)

Prepare for the introduction of a foreign key from apps.droplet_guid to
droplets.guid:
- DropletModel: handle ForeignKeyConstraintViolation and translate into
  ApiError (UnprocessableEntity)
- AppModel: handle ForeignKeyConstraintViolation and translate into
  ValidationFailed error
- DropletDelete: move destroy before other operations (deletion from
  blobstore, recording of event) so that an exception stops the control
  flow
- AppDelete: clear droplet_guid (i.e. current droplet relation) before
  deleting subresources (incl. droplets)
- AppAssignDroplet: handle ValidationFailed error and translate into
  already existing error
- Adapt tests to also work with a foreign key
@philippthun philippthun force-pushed the prevent-deletion-of-current-droplet branch from bfe6010 to 50bb5d6 Compare September 12, 2024 13:06
@philippthun philippthun marked this pull request as ready for review September 12, 2024 13:37
Copy link
Contributor

@kathap kathap left a comment

Choose a reason for hiding this comment

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

LGTM

@philippthun philippthun merged commit 45c08c8 into cloudfoundry:main Sep 23, 2024
8 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Sep 23, 2024
Changes in cloud_controller_ng:

- Prevent deletion of current droplet
    PR: cloudfoundry/cloud_controller_ng#3960
    Author: Philipp Thun <[email protected]>
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.

Add current droplet guid in apps relationships
3 participants