Show the API message when an environment delete returns 409 or 429

What does this MR do and why?

Context

In !269154 (merged), we delete environments in batches with a per-user rows limit. A delete that runs out of time returns 409 and asks for a retry, and a user over the limit gets 429. The environments page deletes through the REST API and shows "Check if the environment stopped; if not, stop it and try again." for every failure, which is the wrong advice for both.

This MR

  • The delete environment modal shows the API's message for 409 and 429 responses.
  • Every other failure, and a 409 or 429 without a message, keeps the current text. A delete of an environment that isn't stopped returns a bare 403 Forbidden, so the current hint stays more useful there.

Users who hit a partial delete or the rows limit learn to retry or wait instead of being told to stop an environment that is already stopped.

References

Screenshots or screen recordings

Before After
before after

How to set up and validate locally

  1. Check out the batched delete branch with this MR's commit on top:
    git fetch origin environment-delete-batched environment-delete-error-message
    git checkout -b try-environment-delete-message origin/environment-delete-batched
    git cherry-pick origin/environment-delete-error-message
  2. In a project you maintain, create two stopped environments with a few deployments each through the Deployments API.
  3. In a Rails console, enable batched deletes and the rows limit, and set a small limit:
    Feature.enable(:environment_delete_in_batches)
    Feature.enable(:rate_limit_environment_delete_rows)
    ApplicationSetting.current.update!(environment_delete_rows_limit_per_user: 1)
  4. Wait a minute, then from Operate > Environments > Stopped, delete both environments within the same minute. The first is deleted. The second shows "This endpoint has been requested too many times. Try again later." and keeps its deployments.
  5. Clean up: Feature.remove both flags and reset the setting to 20000.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Leaminn Ma

Merge request reports

Loading
Loading