Prevent orphaned containers and duplicate hosts#318
Open
cmyers-mieweb wants to merge 2 commits into
Open
Conversation
Add safeguards to container creation and deletion to avoid orphaned Proxmox containers and duplicate hostnames. Import Job model and check for cancelled creation jobs during provisioning; if cancelled, abort creation. After provisioning but before applying config, verify the DB record still exists and if it was deleted, destroy the orphaned Proxmox container and abort. In the containers router, enforce a unique hostname-per-site check (with transaction lock) and return 409 for API requests or flash an error for web UI to prevent duplicates. Also cancel any pending/running creation job when a container is deleted. Changes affect create-a-container/bin/create-container.js and create-a-container/routers/containers.js.
Collaborator
Author
|
@copilot resolve the merge conflicts in this pull request |
Contributor
runleveldev
requested changes
Jul 10, 2026
Comment on lines
+416
to
+427
| const existingContainer = await Container.findOne({ | ||
| where: { siteId: site.id, hostname }, | ||
| transaction: t, | ||
| lock: t.LOCK.UPDATE, | ||
| }); | ||
| if (existingContainer) { | ||
| throw new ApiError( | ||
| 409, | ||
| 'duplicate_hostname', | ||
| `Container with hostname "${hostname}" already exists in this site`, | ||
| ); | ||
| } |
Collaborator
There was a problem hiding this comment.
Container should have a unique condition in the database on siteId + hostname already. The create statement on line 466 below should throw in this case. This preflight check adds an extra DB roundtrip for something that should be caught there.
runleveldev
requested changes
Jul 10, 2026
Comment on lines
+237
to
+240
| if (job && job.status === 'cancelled') { | ||
| console.error('Job was cancelled — aborting container creation.'); | ||
| process.exit(1); | ||
| } |
Collaborator
There was a problem hiding this comment.
Doing this would probably completely rewrite this PR but could we instead have job-runner watch for cancelled jobs and send SIGTERM to them? Then this job would have a SIGTERM handler to rollback it's changes before exitting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: #317
Jobmodel and check for cancelled creation jobs during provisioning; if cancelled, abort creation.409for duplicate hostnames.mainand preserve these safeguards in the updated router layout.Changes affect
create-a-container/bin/create-container.jscreate-a-container/routers/api/v1/containers.js