[PR #5] [MERGED] fix(deployments): add pre-flight image existence check before rollback #9

Closed
opened 2026-03-02 05:12:30 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/gotempsh/temps/pull/5
Author: @dviejokfs
Created: 2/17/2026
Status: Merged
Merged: 2/17/2026
Merged by: @dviejokfs

Base: mainHead: fix/rollback-preflight-image-check


📝 Commits (1)

  • bd34152 fix(deployments): add pre-flight image existence check before rollback

📊 Changes

3 files changed (+140 additions, -0 deletions)

View changed files

📝 crates/temps-deployer/src/docker.rs (+13 -0)
📝 crates/temps-deployer/src/lib.rs (+7 -0)
📝 crates/temps-deployments/src/services/services.rs (+120 -0)

📄 Description

Summary

  • Adds a pre-flight Docker image existence check in rollback_to_deployment before any container operations begin, preventing mid-rollback failures that could disrupt the currently running deployment
  • Introduces ContainerDeployer::image_exists() trait method with a default Ok(true) fallback for backward compatibility; DockerRuntime overrides it using Docker's inspect API (returns false on 404)
  • Returns a clear, actionable error message when the target image has been pruned/removed, suggesting the user redeploy from source instead

Problem

When rolling back to a previous deployment whose Docker image had been pruned or removed, the rollback would fail mid-way during docker.create_container() with a confusing nested error. By that point, the current deployment's containers may have already been disrupted, leaving the environment in a broken state.

Solution

The image existence check runs before any deployment work begins (before DeployImageJob execution). If the image is missing, rollback is aborted cleanly with no side effects.

Changes

File Change
crates/temps-deployer/src/lib.rs Added image_exists() to ContainerDeployer trait with default impl
crates/temps-deployer/src/docker.rs DockerRuntime override using inspect_image API, 404 → false
crates/temps-deployments/src/services/services.rs Pre-flight check in rollback_to_deployment, mock updates, new test

Testing

  • test_rollback_fails_when_image_missing — verifies rollback returns clear error when image doesn't exist
  • All 4 rollback tests pass, all 165 deployment tests pass, all 39 deployer tests pass

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/gotempsh/temps/pull/5 **Author:** [@dviejokfs](https://github.com/dviejokfs) **Created:** 2/17/2026 **Status:** ✅ Merged **Merged:** 2/17/2026 **Merged by:** [@dviejokfs](https://github.com/dviejokfs) **Base:** `main` ← **Head:** `fix/rollback-preflight-image-check` --- ### 📝 Commits (1) - [`bd34152`](https://github.com/gotempsh/temps/commit/bd34152c860cd41fc0368fe28871c90c7812778a) fix(deployments): add pre-flight image existence check before rollback ### 📊 Changes **3 files changed** (+140 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/temps-deployer/src/docker.rs` (+13 -0) 📝 `crates/temps-deployer/src/lib.rs` (+7 -0) 📝 `crates/temps-deployments/src/services/services.rs` (+120 -0) </details> ### 📄 Description ## Summary - Adds a pre-flight Docker image existence check in `rollback_to_deployment` before any container operations begin, preventing mid-rollback failures that could disrupt the currently running deployment - Introduces `ContainerDeployer::image_exists()` trait method with a default `Ok(true)` fallback for backward compatibility; `DockerRuntime` overrides it using Docker's inspect API (returns `false` on 404) - Returns a clear, actionable error message when the target image has been pruned/removed, suggesting the user redeploy from source instead ## Problem When rolling back to a previous deployment whose Docker image had been pruned or removed, the rollback would fail mid-way during `docker.create_container()` with a confusing nested error. By that point, the current deployment's containers may have already been disrupted, leaving the environment in a broken state. ## Solution The image existence check runs **before** any deployment work begins (before `DeployImageJob` execution). If the image is missing, rollback is aborted cleanly with no side effects. ## Changes | File | Change | |---|---| | `crates/temps-deployer/src/lib.rs` | Added `image_exists()` to `ContainerDeployer` trait with default impl | | `crates/temps-deployer/src/docker.rs` | `DockerRuntime` override using `inspect_image` API, 404 → `false` | | `crates/temps-deployments/src/services/services.rs` | Pre-flight check in `rollback_to_deployment`, mock updates, new test | ## Testing - `test_rollback_fails_when_image_missing` — verifies rollback returns clear error when image doesn't exist - All 4 rollback tests pass, all 165 deployment tests pass, all 39 deployer tests pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 05:12:30 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/temps#9
No description provided.