Swarm orchestration and cluster management
Arcane is a control plane for Docker Swarm. It lets an engineer create or join a cluster, manage managers and workers, deploy services and stacks, inspect tasks, and maintain cluster configs and secrets. Each operation uses the selected Arcane environment as its connection context.
System boundary
Arcane sits between the web interface and the Docker Swarm manager. The manager remains the source of truth for cluster state and scheduling. Arcane adds an environment-aware API, permission checks, audit records for completed changes, readable summaries, and links between Swarm nodes and Arcane environments.
The main control path is:
flowchart LR
Engineer[Engineer] --> UI[Arcane web interface]
UI --> API[Environment-scoped Swarm API]
API --> Manager[Docker Swarm manager]
Manager --> Nodes[Swarm nodes]
Nodes --> Tasks[Service tasks]
API --> Agents[Arcane node-agent coverage]
Agents --> Environments[Visible or dedicated environments]
An environment is the Arcane connection context for a Docker engine. A remote environment can proxy requests through the parent manager environment. Cluster state and Arcane agent reachability remain separate concerns.
Cluster lifecycle
Cluster membership
Cluster membership covers initialization, joining, leaving, unlocking, and security key rotation. A manager provides separate manager and worker join tokens. Arcane also exposes the manager unlock key when autolock protects manager data.
Initialization creates a cluster on the selected engine. Joining adds an engine through manager addresses and a role-specific token. Leaving removes an engine and may be forced. Token rotation and unlock-key rotation affect cluster access rather than workload state. Successful lifecycle changes create audit events, while failed join details redact the submitted token.
The Easy Join flow applies this model to several Arcane environments. It checks access to the manager and each target, prevents the manager from being a target, lets the engineer choose each target's role and availability, and returns an independent result for every target. It uses current manager addresses when none are supplied and does not expose join tokens in target results.
References: backend/…/handler.go• L155-313 backend/…/handler.go• L451-500 backend/…/easy_join.go• L13-63 backend/…/service.go• L409-565 backend/…/service.go• L120-270 types/…/lifecycle.go• L9-128 frontend/…/+page.svelte• L143-300 frontend/…/easy-join-dialog.svelte• L21-137
Cluster policy
The Swarm specification defines cluster-wide policy. It controls manager behavior and node participation. Arcane reads the current specification and sends versioned updates so a change applies to the cluster that the engineer inspected.
The cluster page groups policy updates with token rotation and manager security actions. This keeps changes that affect all nodes separate from changes to one service or one node. Successful policy changes are recorded in the audit trail.
References: backend/…/handler.go• L316-334 backend/…/service.go• L273-306 types/…/lifecycle.go• L47-63 frontend/…/+page.svelte• L274-300
Node coordination
Node roles and availability
A Swarm node is a manager or a worker. Managers maintain cluster control. Workers run assigned tasks. Node availability controls whether the scheduler may place new work on a node.
Arcane supports node inspection, role changes, availability changes, label updates, promotion, demotion, and removal. These settings are scheduling inputs, so a node change can alter where later service tasks run. The node view can open tasks with the node already selected.
References: backend/…/handler.go• L132-175 backend/…/handler.go• L344-448 backend/…/service.go• L94-170 backend/…/service.go• L626-689 types/…/node.go• L47-153 frontend/…/+page.svelte• L19-70 frontend/…/+page.svelte• L91-103 frontend/…/nodes-table.svelte• L67-76 frontend/…/nodes-table.svelte• L215-217
Node-agent coverage
Node-agent coverage links a visible Swarm node to an Arcane environment that can report or manage that node. Arcane distinguishes local coverage, an environment binding, and a dedicated agent deployment. It reports connected, pending, offline, mismatched, and ambiguous states.
Arcane accepts a binding only when the environment reports the requested Swarm node identity. If more than one environment matches, the node stays ambiguous until an engineer chooses the binding. Reconciliation persists only a unique verified match. The nodes view reconciles coverage when the selected environment or user changes and warns when nodes remain uncovered. Provisioning ensures a node-bound environment and returns deployment snippets, with optional token rotation. Fresh poll or tunnel activity can correct stale stored status. A live identity probe can mark a binding mismatched when it reports another node. The node surface can refresh, replace, detach, and remove coverage.
References: backend/…/handler.go• L178-317 backend/…/handler.go• L319-341 backend/…/service.go• L172-235 backend/…/service.go• L261-407 backend/…/service_test.go• L150-203 backend/…/environment_swarm_nodes.go• L15-113 types/…/node.go• L10-45 frontend/…/+page.svelte• L39-70 frontend/…/+page.svelte• L91-103 frontend/…/nodes-table.svelte• L78-213
Workload orchestration
Services and tasks
A Swarm service is the desired definition of a workload. It includes the image, task mode, replica goal, ports, networks, mounts, and update behavior. A task is one scheduled attempt to run that service on a node. Service summaries compare desired replicas with running replicas. Task views show placement, current state, desired state, and errors.
The service detail surface connects overview, logs, tasks, configuration, network data, and storage. It also supports permission-controlled updates, rollback, removal, and scaling. Scaling applies to replicated services and replicated jobs. Global services and global jobs do not use a scalable replica target. Arcane records successful service changes and refreshes related runtime data after a successful change. The service list also provides a permission-gated path to create a service in the selected environment.
For the detailed resource lifecycle and scheduling relationships, see Swarm resources and runtime and Workload management.
References: backend/…/handler.go• L80-262 backend/…/service.go• L40-151 backend/…/service.go• L259-453 backend/…/service.go• L456-547 backend/…/service.go• L97-117 backend/…/service.go• L309-367 types/…/service.go• L57-173 types/…/task.go• L9-79 frontend/…/swarm-service.ts• L52-95 frontend/…/+page.svelte• L20-78 frontend/…/+page.svelte• L180-236 frontend/…/+page.svelte• L254-340 frontend/…/service-logs-panel.svelte• L25-86 frontend/…/service-tasks-panel.svelte• L24-109 frontend/…/service-configuration.svelte• L24-146 frontend/…/service-network.svelte• L49-185 frontend/…/service-storage.svelte• L50-162
Stacks and source
A stack is a named group of related Swarm services. Arcane deploys a stack from Compose content with optional override content, environment content, and extra files. The stack name groups its services and tasks.
Arcane keeps the source used for a stack so an engineer can inspect or edit the desired definition later. The editor combines Compose, environment data, override content, and workspace files. An engineer can also start from a template, convert a Docker run command, or use a Git source flow. Deployment can prune removed services, pass registry credentials, and choose when images are resolved. Arcane can also render and validate the combined configuration before deployment.
The stack view separates saved source from live services and tasks. A live stack exposes its services and tasks, while authorized source access exposes saved Compose and environment files even when no live services remain. Updating saved source redeploys the stack with pruning so removed services leave the cluster. If that deployment fails, Arcane restores the prior saved source. Direct service changes suit one-off runtime actions, while stack changes suit a grouped Compose-defined workload.
References: backend/…/handler.go• L89-294 backend/…/service.go• L67-199 backend/…/service.go• L202-370 backend/…/service.go• L455-590 backend/…/service_test.go• L54-200 types/…/stack.go• L5-180 frontend/…/swarm-service.ts• L163-212 frontend/…/+page.svelte• L16-58 frontend/…/+page.svelte• L45-95 frontend/…/+page.svelte• L115-140 frontend/…/+page.svelte• L183-245 frontend/…/+page.svelte• L291-317 frontend/…/+page.svelte• L337-375 frontend/…/+page.svelte• L377-501 frontend/…/+page.svelte• L78-182 frontend/…/+page.svelte• L184-242 frontend/…/+page.svelte• L260-399
Cluster resources
Configs and secrets
Configs and secrets are cluster resources that services can use as managed input. A config holds non-sensitive service data. A secret holds sensitive service data and remains protected even when its metadata appears in an inspection response.
Arcane provides separate management surfaces for each resource type. These resources are not edited in place. A new version normally requires a replacement resource and a service or stack change. Successful creation and removal are recorded in the audit trail, and missing resources return a not-found result.
References: backend/…/handler.go• L48-136 backend/…/service.go• L27-98 backend/…/handler.go• L48-136 backend/…/service.go• L27-98 backend/…/service.go• L66-71 types/…/config_secret.go• L10-31 frontend/…/+page.svelte• L9-44 frontend/…/+page.svelte• L9-44
Runtime identity
Arcane exposes cluster identity and runtime status as separate concepts. Cluster information includes identity, timestamps, the current specification, and root-key rotation state. Runtime status records whether Swarm is enabled for the environment.
This distinction matters during setup and recovery. An environment can be selected before it has an active Swarm. Arcane synchronizes its enabled marker with Docker runtime state, but Docker remains the authority for whether Swarm is active. A cluster can also be active while an Arcane node agent is offline. Use cluster inspection for Docker state and agent status for Arcane coverage.
References: backend/…/handler.go• L89-152 backend/…/service.go• L39-117 backend/…/service.go• L388-448 types/…/swarm.go• L9-55 frontend/…/swarm-service.ts• L214-222 frontend/…/+page.svelte• L28-79
Frontend management surfaces
Environment-scoped views
The web interface presents one management surface for each major Swarm concern. Each view uses the selected environment and applies the permission for the resource it changes. List views refresh when the environment changes. Detail views connect related runtime records so an engineer can move from a service or stack to the tasks and source that explain its state.
The cluster view gates state, join-token, and unlock-key reads by their separate permissions. The node view reconciles agent coverage before refreshing its table. The service and stack views gate creation by resource permission. The task view uses either the cluster-wide task query or the node-scoped task query. Sensitive cluster values remain permission-gated. The API presents empty collections consistently and maps manager, not-found, conflict, and validation failures to clear request errors.
| Surface | Main responsibility |
|---|---|
| Cluster | Initialize or join a cluster, inspect policy, manage tokens, unlock managers, and leave |
| Nodes | Inspect nodes, change role or availability, edit labels, manage coverage, and open node tasks |
| Services | Create, inspect, update, scale, roll back, remove, and view task state and logs |
| Stacks | Review groups, deploy, edit Compose source, inspect source, and remove stacks |
| Tasks | Inspect task placement and runtime state across the cluster or one node |
| Configs | Create and remove non-sensitive cluster configs |
| Secrets | Create and remove sensitive cluster secrets |
References: backend/…/handler.go• L89-152 backend/…/handler.go• L399-438 backend/…/handler.go• L48-136 backend/…/service.go• L27-98 backend/…/handler.go• L132-500 backend/…/service.go• L94-235 backend/…/handler.go• L48-136 backend/…/service.go• L27-98 backend/…/handler.go• L80-262 backend/…/service.go• L40-453 backend/…/handler.go• L89-294 backend/…/service.go• L67-590 backend/…/service.go• L97-117 backend/…/service.go• L309-367 frontend/…/swarm-service.ts• L52-302 frontend/…/+page.svelte• L28-69 frontend/…/+page.svelte• L25-65 frontend/…/+page.svelte• L20-68 frontend/…/+page.svelte• L16-48 frontend/…/+page.svelte• L199-245 frontend/…/+page.svelte• L291-317 frontend/…/+page.svelte• L337-501 frontend/…/+page.svelte• L19-65 frontend/…/+page.svelte• L73-243 frontend/…/+page.svelte• L73-243 frontend/…/+page.svelte• L260-399
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to environment selection or remote proxying must preserve the difference between the selected environment and the manager that owns the cluster.
- Changes to node-agent binding must preserve identity checks and the difference between ambiguous, mismatched, and offline states.
- Changes to node task links must preserve the node ID and hostname filter.
- Changes to service summaries must keep service IDs linked to task and node data. Desired and running replicas must retain separate meanings.
- Changes to service creation must keep the selected-environment permission check aligned with the create request.
- Changes to service tabs and actions must preserve the links between service ID, refreshed state, task queries, log streams, and permission gates.
- Changes to service mode handling must keep scaling limited to replicated and replicated-job modes.
- Changes to stack deployment must keep saved source, extra files, image resolution, prune behavior, registry authentication, and live services consistent.
- Changes to stack source updates must preserve redeployment with pruning and restoration of the prior source when deployment fails.
- Changes to stack rendering or source updates must preserve validation before deployment and redeployment after an edited source is saved.
- Changes to stack detail tabs must preserve the difference between live services and tasks and saved source, including source access when no live services exist.
- Changes to stack refresh handling must keep stack, service, task, and source results independent.
- Changes to cluster security actions must keep tokens, unlock keys, hidden values, token redaction, and versioned policy updates aligned across API and UI.
- Changes to Easy Join must keep manager and target permissions distinct and preserve per-target results without exposing tokens.
- Changes to config or secret handling must preserve their separate permissions, not-found behavior, and removal behavior.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The selected engine is not an active Swarm manager | Cluster reads and manager operations fail | Confirm manager role and reachability before changing resources |
| A node agent reports a different node identity during a live probe | Coverage is marked mismatched and is not used for the requested node | Verify identity before binding |
| More than one environment matches a node | Reconciliation leaves the node ambiguous | Select one candidate and bind it explicitly |
| A join token or manager address is stale | The target cannot join the intended cluster | Read current values from the manager |
| A join error includes the submitted token | Logs or API details can expose a credential | Redact the token before logging and returning the error |
| A service mode has no scalable replica target | Scaling is rejected and the workload is unchanged | Check the service mode before scaling |
| A service change succeeds but the detail view is not refreshed | The page shows stale desired or runtime state | Refresh the service and related data |
| A stack definition or supporting file is invalid | Compose rendering or deployment fails | Validate the complete Compose, override, environment, and extra-file set |
| A stack source edit deploys only part of the new definition | Removed services remain in the cluster | Redeploy the full source with pruning |
| A stack source edit fails after the source is saved | The source can describe a state that never reached the cluster | Restore the prior source when redeployment fails |
| Saved stack source is missing or forbidden | Live services can remain visible without an editable source view | Treat live state and source access as separate states |
| A stack refresh returns mixed results | One view can show current data beside stale data | Refresh and report each resource independently |
| A config or secret is still used by a service | Docker rejects removal | Remove the consuming reference first |
Key files
| File | Why to read it |
|---|---|
| backend/…/service.go | Shared Swarm boundary for manager checks, cluster lifecycle, task views, and runtime state |
| backend/…/handler.go | API boundary for cluster lifecycle actions, audit records, token redaction, and error mapping |
| backend/…/service.go | Node management, identity coverage, Easy Join, and node task coordination |
| backend/…/handler.go | Node management, task links, agent coverage, and Easy Join boundaries |
| backend/…/service.go | Service summaries, lifecycle actions, task queries, scaling, rollback, and logs |
| backend/…/handler.go | Service lifecycle, task queries, scaling, rollback, and audit boundaries |
| backend/…/service.go | Stack deployment, persisted source, redeployment, live-resource queries, and removal |
| backend/…/handler.go | Stack deployment, source editing, rendering, live-resource queries, and removal |
| backend/…/service.go | Config inspection and lifecycle boundary |
| backend/…/service.go | Secret inspection and lifecycle boundary |
| backend/…/environment_swarm_nodes.go | Binding and reconciliation rules for Swarm node coverage |
| types/…/lifecycle.go | Contracts for cluster setup, membership, and security actions |
| types/…/service.go | Service desired-state and runtime summary model |
| types/…/node.go | Node and coverage status model |
| types/…/task.go | Task state and placement model |
| types/…/stack.go | Stack source and deployment contracts |
| types/…/config_secret.go | Config and secret API model |
| frontend/…/swarm-service.ts | Environment-scoped requests for Swarm management |
| frontend/…/+page.svelte | Cluster setup, security, policy, and refresh surface |
| frontend/…/+page.svelte | Node coverage reconciliation, warnings, and refresh surface |
| frontend/…/+page.svelte | Service list, creation permission, and refresh surface |
| frontend/…/+page.svelte | Service detail actions and related runtime views |
| frontend/…/service-logs-panel.svelte | Service log stream controls |
| frontend/…/service-tasks-panel.svelte | Service task state and placement view |
| frontend/…/+page.svelte | Stack list, creation permission, and refresh surface |
| frontend/…/+page.svelte | Compose source editor, workspace files, source updates, and deployment options |
| frontend/…/+page.svelte | Stack services, tasks, saved source states, refresh, and removal |
| frontend/…/+page.svelte | Initial, refresh, cluster-wide, and node-scoped task loading |
| frontend/…/+page.svelte | Config management surface |
| frontend/…/+page.svelte | Secret management surface |