Skip to content

Conversation

raghavyuva
Copy link
Owner

@raghavyuva raghavyuva commented Sep 17, 2025

Summary by CodeRabbit

  • New Features

    • Added Docker Swarm cluster management: initialize/join/leave clusters, view nodes/services/tasks/secrets/configs/volumes/networks.
    • Service lifecycle: create, update, delete, rollback; scale replicas; stream real-time events.
    • Health insights for services and tasks; automatic cluster detection/initialization on startup.
  • Refactor

    • Deployment, restart, delete, and rollback now use Swarm services instead of individual containers.
    • Deployments publish app ports via service endpoints and update status/metadata accordingly.
    • Improved service-oriented logs and error handling.

…d more methods wrapper for future integrations for multi server management
Copy link
Contributor

coderabbitai bot commented Sep 17, 2025

Walkthrough

Introduces Docker Swarm cluster management APIs and wires them into DockerService initialization. Migrates deployment task handlers from container-level operations to swarm service operations for run, restart, delete, and rollback. Adds service health checks, event streaming, and node/cluster introspection. Updates repository interface to expose new swarm methods.

Changes

Cohort / File(s) Summary of changes
Swarm cluster service implementation
api/internal/features/deploy/docker/cluster.go
Adds DockerService methods for swarm lifecycle (init/join/leave), introspection (info/nodes/services/tasks/secrets/configs/volumes/networks), events, node availability, service CRUD, scaling, rollback, and health checks.
Repository interface and init wiring
api/internal/features/deploy/docker/init.go
Extends DockerRepository with new swarm APIs; updates NewDockerService to build client and conditionally init swarm via isClusterInitialized; imports updated; minor formatting.
Task handlers: service-based deploy
api/internal/features/deploy/tasks/run.go
Replaces container orchestration with swarm service spec/create/update flow; adds service lookup helpers; updates deployment state population and health checks.
Task handlers: service restart
api/internal/features/deploy/tasks/restart.go
Switches restart from per-container to service update on existing swarm service; updates logs and error handling.
Task handlers: service delete
api/internal/features/deploy/tasks/delete.go
Replaces container cleanup with deletion of matching swarm service; retains image cleanup and subsequent repository/domain cleanup.
Task handlers: service rollback
api/internal/features/deploy/tasks/rollback.go
Implements native swarm rollback via DockerRepo.RollbackService, waits briefly, verifies service health, updates logs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant TaskService
  participant DeployTasks
  participant DockerRepo as DockerRepository (Swarm)
  participant DockerEngine as Docker Engine

  rect rgba(230,245,255,0.6)
  note over User,DeployTasks: Deploy/Update flow (service-based)
  User->>TaskService: Enqueue Run/Update
  TaskService->>DeployTasks: HandleRun (AtomicUpdateContainer)
  DeployTasks->>DockerRepo: GetClusterServices
  alt Service exists
    DeployTasks->>DockerRepo: UpdateService(serviceID, serviceSpec, rollback=none)
  else New service
    DeployTasks->>DockerRepo: CreateService(serviceSpec)
  end
  DeployTasks->>DockerRepo: GetServiceByID / GetServiceHealth
  DockerRepo->>DockerEngine: Swarm API calls
  DockerEngine-->>DockerRepo: Specs/Health
  DockerRepo-->>DeployTasks: Health OK/err
  DeployTasks-->>TaskService: Mark success/failure
  end
Loading
sequenceDiagram
  autonumber
  participant User
  participant TaskService
  participant RestartTasks as Restart Handler
  participant DockerRepo as DockerRepository (Swarm)
  participant DockerEngine as Docker Engine

  rect rgba(240,255,240,0.6)
  note over User,RestartTasks: Restart via service update
  User->>TaskService: Enqueue Restart
  TaskService->>RestartTasks: HandleRestart
  RestartTasks->>DockerRepo: GetClusterServices
  alt Service found
    RestartTasks->>DockerRepo: UpdateService(serviceID, currentSpec, rollback=none)
  else Not found
    RestartTasks-->>TaskService: ErrContainerNotRunning
  end
  DockerRepo->>DockerEngine: Service Update
  DockerEngine-->>DockerRepo: Update ACK
  DockerRepo-->>RestartTasks: OK/err
  end
Loading
sequenceDiagram
  autonumber
  participant User
  participant TaskService
  participant RollbackTasks as Rollback Handler
  participant DockerRepo as DockerRepository (Swarm)
  participant DockerEngine as Docker Engine

  rect rgba(255,245,230,0.6)
  note over User,RollbackTasks: Native swarm rollback
  User->>TaskService: Enqueue Rollback
  TaskService->>RollbackTasks: HandleRollback
  RollbackTasks->>DockerRepo: RollbackService(serviceID)
  DockerRepo->>DockerEngine: Service Rollback
  DockerEngine-->>DockerRepo: Rollback ACK
  RollbackTasks->>DockerRepo: GetServiceByID / GetServiceHealth
  DockerRepo-->>RollbackTasks: Health status
  RollbackTasks-->>TaskService: Success/ErrFailedToUpdateContainer
  end
Loading
sequenceDiagram
  autonumber
  participant User
  participant TaskService
  participant DeleteTasks as Delete Handler
  participant DockerRepo as DockerRepository (Swarm)

  rect rgba(255,240,245,0.6)
  note over User,DeleteTasks: Service deletion
  User->>TaskService: Enqueue Delete
  TaskService->>DeleteTasks: HandleDelete
  DeleteTasks->>DockerRepo: GetClusterServices
  DeleteTasks->>DockerRepo: DeleteService(matching name)
  DeleteTasks->>DockerRepo: RemoveImage(...) [per deployment]
  DeleteTasks-->>TaskService: Cleanup complete
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

nixopus-docker

Poem

I thump my paws—deploys take form,
From lone containers to a swarm.
Services scale, then roll back neat,
Events hop by in a tidy beat.
Nodes align, networks weave—
A rabbit approves, ears up the sleeve. 🐇🚢

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/deploy_to_cluster

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ad3b64 and 4b090cf.

📒 Files selected for processing (6)
  • api/internal/features/deploy/docker/cluster.go (1 hunks)
  • api/internal/features/deploy/docker/init.go (5 hunks)
  • api/internal/features/deploy/tasks/delete.go (2 hunks)
  • api/internal/features/deploy/tasks/restart.go (1 hunks)
  • api/internal/features/deploy/tasks/rollback.go (1 hunks)
  • api/internal/features/deploy/tasks/run.go (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@raghavyuva raghavyuva self-assigned this Sep 17, 2025
@raghavyuva
Copy link
Owner Author

@coderabbitai summary

Copy link
Contributor

coderabbitai bot commented Sep 17, 2025

✅ Actions performed

Summary regeneration triggered.

@raghavyuva
Copy link
Owner Author

@coderabbitai summary

Copy link
Contributor

coderabbitai bot commented Sep 18, 2025

✅ Actions performed

Summary regeneration triggered.

@raghavyuva raghavyuva added this to the Beta Release milestone Sep 18, 2025
@raghavyuva raghavyuva merged commit 0aec16a into feat/develop Sep 18, 2025
4 checks passed
@github-project-automation github-project-automation bot moved this to Done in Nixopus Sep 18, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant