Skip to content

fix: handle dead challenge container removal failures - #584

Open
Yeagerist0 wants to merge 1 commit into
adeyosemanputra:masterfrom
Yeagerist0:fix/challenge-replace-cleanup
Open

Yeagerist0 wants to merge 1 commit into
adeyosemanputra:masterfrom
Yeagerist0:fix/challenge-replace-cleanup

Conversation

@Yeagerist0

Copy link
Copy Markdown
Contributor

Summary

Return a controlled error when Docker cannot remove a dead challenge container before replacement. Do not start another container or overwrite the existing UserChallenge state in that case.

Problem / Motivation

DoItFast.post() called container.remove(force=True) outside its Docker error handler. An API failure raised an unhandled exception, so the request crashed without a stable response and the user could not tell why the challenge did not restart. I reproduced this with a failing Docker removal mock before applying the fix.

Solution / Approach

Catch Docker errors at the replacement boundary and return HTTP 500 with the existing challenge state preserved. A regression test verifies the response, confirms that no replacement container is started, and checks that the stored container ID/live flag remain available for retry.

Files Changed

File Change
challenge/views.py Handle failed removal before starting a replacement.
challenge/tests.py Reproduce and guard the failure path.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Impact

Challenge restart failures now produce a clear response and avoid creating a second container when deletion of the old one fails. No behavior change on the successful path.

Verification

  • python manage.py test challenge --noinput — 24 passed
  • python manage.py test --noinput — 55 passed
  • git diff --check — clean

AI Tool Disclosure

Codex assisted with code analysis, the regression test, and the patch. Test commands above were run in the local repository. No physical Docker daemon was needed for this mocked failure case.

Signed-off-by: Yeagerist0 <180412661+Yeagerist0@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

1 participant