Introducing a new way to review your PRs.

Read the announcement

getarcaneapp / arcane

Modern Docker Management, Designed for Everyone

View on GitHub

26 documents · Updated Oct 19, 2026

docs / swarm-resources-and-runtime

Swarm resources and runtime workflows

Arcane presents Docker Swarm as a managed cluster surface. It joins the backend Swarm service to Docker and the environment system, then gives the web app one set of flows for cluster state, nodes, services, stacks, tasks, configs, secrets, and saved stack source. The page complements Swarm orchestration and cluster management with the runtime paths that operate those resources.

Backend Swarm boundary

The backend Swarm service is the boundary between Arcane requests and a Docker Swarm manager. It composes focused services for nodes, services, stacks, configs, and secrets, then checks cluster access and returns shared Swarm shapes to the HTTP layer.

HTTP resource boundary

The Swarm handler exposes resource reads and changes below an environment path. Read operations cover cluster metadata and resource views. Change operations cover lifecycle actions, service and node changes, stack deployment, and config or secret management. Permission checks and audit events sit at this boundary so the resource service can focus on the operation itself.

References: backend/…/handler.go• L332-407 backend/…/module.go• L23-40 types/…/swarm.go• L9-55

Docker manager boundary

The service uses the Docker client for the live cluster rather than treating the web application as the source of truth. It converts Docker results into stable summaries and combines related Docker objects when a useful view needs more than one resource, such as service nodes, network names, or task service names.

References: backend/…/service.go• L39-70 backend/…/service.go• L309-367 backend/…/service.go• L40-116 types/…/service.go• L57-173 types/…/task.go• L9-79

Cluster lifecycle

Cluster lifecycle flows establish the manager, add or remove members, and maintain the security material needed for managers and workers. The enabled flag is a small Arcane state value that tells the product whether Swarm is expected to be active; Docker remains the authority for the actual cluster state.

Cluster initialization and membership

An administrator can initialize a local engine or join it to an existing cluster. A manager can also use Easy Join to select other visible environments and join them as workers or managers. Each target receives an independent result, which lets a multi-target action report joined, already-member, unverified, or failed outcomes without hiding partial success.

The environment system links a Swarm node to the environment that represents its agent. Arcane checks the reported node identity before it saves a binding. It also detects missing, stale, ambiguous, or mismatched coverage so a node view does not present an unverified environment as the wrong node.

References: backend/…/service.go• L120-190 backend/…/service.go• L172-235 backend/…/service.go• L409-565 types/…/lifecycle.go• L84-129 types/…/node.go• L10-45

Cluster security and state

The cluster page treats join tokens, the manager unlock key, and the Swarm specification as separate controls. Token rotation can target worker or manager tokens. Unlock and leave require an active cluster. Initialization, joining, and leaving update Arcane's Swarm-enabled state after Docker accepts the change, while a state sync can correct that flag from Docker when the two states differ.

References: backend/…/service.go• L177-306 backend/…/service.go• L388-447 backend/…/handler.go• L1131-1426 types/…/lifecycle.go• L9-63 frontend/…/+page.svelte• L103-257

Runtime resource workflows

Swarm resources form a connected runtime view: services define desired work, tasks show the work placed on nodes, and stacks group services under a namespace. Configs and secrets supply named data to those workloads. The backend keeps these views linked so users can move from a high-level resource to the live objects that explain its state.

Service and task workflows

Services can be listed, inspected, created, updated, scaled, rolled back, removed, and watched through their logs. A service summary shows desired and running work plus its ports, networks, mounts, and active nodes. Scaling changes replica targets for replicated and replicated-job services; global services and global jobs use node placement or job rules instead.

The service detail surface keeps runtime inspection and service actions together. It presents overview, logs, tasks, configuration, network, and storage views when those views have data. Management actions are grouped in the page header, while replica changes open a focused scale dialog. The action remains available only when the caller can manage services and the service mode supports scaling. Successful changes close the dialog when needed and refresh the service state.

Tasks are the runtime records behind services. The product lists all tasks and supports views filtered by service, node, or stack. Each task view ties desired state to current state and includes the node, service, image, container, and reported error when available.

References: backend/…/service.go• L40-116 backend/…/service.go• L259-453 backend/…/service_test.go• L32-143 backend/…/service.go• L309-367 types/…/service.go• L57-173 types/…/task.go• L9-130 frontend/…/+page.svelte• L169-237 frontend/…/+page.svelte• L261-336 frontend/…/+page.svelte• L339-471

Stack deployment and source

A stack is a group of Swarm services produced from Compose content. Deployment accepts the main Compose file, an optional override, environment content, and extra files. The backend saves that source, renders the stack in its working context, resolves registry access when requested, and asks Swarm to apply the result. A stack can therefore remain visible as saved source even when it has no live services.

Editing saved source is a deploy operation, not only a file edit. Arcane applies the new source with pruning so removed services leave the cluster, and it carries registry authentication for images that need it. If deployment fails, it restores the prior saved source so the source view does not claim that an unapplied change is current. Stack removal also waits for the old service tasks to reach a terminal state before it finishes removing stack resources. Stack pages then combine the stack summary, its services, its tasks, and its saved source.

sequenceDiagram
    participant UI as Stack editor
    participant API as Swarm API
    participant Source as Saved stack source
    participant Docker as Swarm manager
    UI->>API: Submit Compose, override, env, and files
    API->>Source: Save source
    API->>Docker: Render and deploy stack
    Docker-->>API: Deployment result
    API-->>UI: Stack result and refreshed views

References: backend/…/service.go• L67-199 backend/…/service.go• L202-370 backend/…/service.go• L455-547 backend/…/service.go• L613-657 backend/…/service_test.go• L54-200 types/…/stack.go• L5-180 types/…/stack_deploy.go• L3-71 frontend/…/+page.svelte• L179-243 frontend/…/+page.svelte• L141-199

Config and secret workflows

Configs and secrets are named Swarm data resources with separate permissions and lifecycle controls. The backend lists and inspects them through the manager, validates a named resource specification, creates the resource, and removes it through Docker. The frontend uses one shared resource pattern for both types: create named data, inspect it as read-only content, and remove it after confirmation.

The shared page encodes text for the API boundary and decodes it for display. It does not offer in-place edits because these Swarm resources are treated as immutable after creation. Services and stacks can still refer to them as part of their workload specification.

References: backend/…/service.go• L27-98 backend/…/service.go• L27-98 backend/…/handler.go• L1429-1608 types/…/config_secret.go• L10-67 frontend/…/swarm-kv-page.svelte• L83-171 frontend/…/+page.svelte• L35-44 frontend/…/+page.svelte• L35-44

Frontend cluster surfaces

The frontend selects an environment before it calls the Swarm service. The client service turns the selected environment and table options into API requests, while route pages refresh their data when the selected environment changes. Permission checks hide or disable changes without removing read views.

Cluster and node surfaces

The cluster page shows whether Swarm is initialized, cluster metadata, join tokens, and unlock state. It also provides guarded controls for initialization, direct joining, Easy Join, token rotation, specification updates, unlock, and leave. Changing the selected environment resets local security and edit state before the page loads the new cluster view.

The node page presents the manager and worker view with readiness, role, availability, labels, platform, and agent coverage. Operators can inspect a node's tasks, change its Swarm role or availability, and add or remove user labels. The page reconciles agent coverage when the selected environment or user changes, then warns when nodes have no connected agent. This keeps Docker node health separate from Arcane agent coverage.

References: frontend/…/swarm-service.ts• L97-161 frontend/…/swarm-service.ts• L214-272 frontend/…/+page.svelte• L28-172 frontend/…/+page.svelte• L174-300 frontend/…/+page.svelte• L19-71 frontend/…/nodes-table.svelte• L67-217 frontend/…/nodes-table.svelte• L219-307 frontend/…/swarm.ts• L248-312

Stack and service surfaces

The stack list is the entry point for deployment and saved-source management. The deployment editor combines Compose content with an optional override, environment content, and extra files. It also exposes pruning, registry authentication, and image-resolution choices so the operator can control how the desired stack reaches Swarm.

A stack detail page shows live services and tasks only when the stack has live services. It also shows the saved Compose and environment source when the caller has stack management access, which supports a useful distinction between a deployed stack and a saved but not deployed stack.

The source view is read-only and has separate tabs for the Compose file and saved environment content. It reports missing, forbidden, or failed source reads instead of treating those states as an empty stack. The stack edit action leads to the deployment editor, while deletion returns to the stack list.

The service list supports creation and inspection. Creation opens the service editor and refreshes the list after a successful request. A service detail page joins overview, logs, tasks, configuration, network, and storage views when those views have data. The header groups edit, rollback, delete, and permitted scale actions, while a separate scale dialog handles replica changes for scalable service modes. Successful actions refresh the live service, and deletion returns to the service list. The log panel can start or stop a live stream or refresh current logs, with search, auto-scroll, and saved display preferences.

References: frontend/…/swarm-service.ts• L52-212 frontend/…/swarm-service.ts• L234-242 frontend/…/+page.svelte• L16-58 frontend/…/+page.svelte• L45-96 frontend/…/+page.svelte• L183-245 frontend/…/+page.svelte• L334-374 frontend/…/+page.svelte• L73-392 frontend/…/+page.svelte• L20-69 frontend/…/+page.svelte• L169-237 frontend/…/+page.svelte• L261-336 frontend/…/+page.svelte• L339-471 frontend/…/swarm-kv-page.svelte• L194-282 frontend/…/swarm-kv-page.svelte• L83-171 frontend/…/ServiceLogsPanel.svelte• L18-85

Task and data surfaces

The task page is a shared runtime view that can show all tasks or tasks for one node. A node-scoped page keeps the node identity in its request so the table describes only that node's work. The page refreshes when the selected environment changes and reports the total task count for the current scope. Task state is ordered from active work to terminal failure so the most useful runtime information appears first. Config and secret pages use the same list, create, select, and remove flow while keeping their permission names and labels separate.

References: frontend/…/+page.svelte• L12-65 frontend/…/swarm-tasks.ts• L4-43 frontend/…/swarm-kv-page.svelte• L194-282 frontend/…/swarm-kv.ts• L4-31

Scheduler coordination

Swarm itself schedules tasks inside Docker. Arcane's scheduler coordinates work around Swarm, especially GitOps delivery of stack source. This separation matters: the scheduler decides when Arcane should apply a desired stack source, while Swarm decides where the resulting service tasks run.

GitOps stack delivery

An enabled GitOps sync registers one dynamic job for its sync record. The job runs on its interval and can also run at startup or when a sync becomes due. The sync flow prepares repository source, identifies the Swarm stack target, carries Compose inputs and additional files into a stack deploy request, and enables pruning and registry authentication for that path.

flowchart LR
    Repo[Git repository] --> Sync[GitOps sync]
    Sync --> Job[Dynamic scheduler job]
    Job --> Deploy[Swarm stack deployment]
    Deploy --> Services[Swarm services]
    Services --> Tasks[Swarm tasks on nodes]

References: backend/…/gitops_sync.go• L417-459 backend/…/gitops_sync.go• L909-959 backend/…/gitops_sync.go• L1126-1209

Run admission and reconciliation

The scheduler registry uses one job name per sync and one admission key per sync. This prevents a scheduled run, startup kick, manual action, or webhook from deploying the same stack at the same time. Each scheduled run re-reads its sync record, skips disabled records, and unregisters a job when its record no longer exists.

References: backend/…/entityjobs.go• L20-110 backend/…/gitops_sync.go• L376-445 backend/…/gitops_sync.go• L909-920

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the environment path rules aligned with the central node-agent and Easy Join operations. Those calls must not be sent to a remote engine as ordinary resource requests.
  • Keep service, task, and node name enrichment aligned. Resource tables depend on IDs being resolved to the names that users see.
  • Keep stack source persistence and stack deployment as one contract. A successful source edit must describe the deployed stack, and a failed deploy must not leave a false saved source.
  • Keep the frontend Swarm types aligned with the backend shared Swarm types. Service mode names, node-agent states, stack source fields, and config or secret specs cross this boundary.
  • Keep GitOps stack requests aligned with direct stack deploy requests. Registry authentication, pruning, working directory, and synced files affect private images and related stack resources.
  • Keep the Swarm-enabled KV state aligned with lifecycle actions. Initialization and join enable the state; leave disables it, and state sync must continue to reflect Docker.
  • Keep the service log panel's stream controls aligned with the log viewer contract. The service ID, stream state, refresh action, and log preferences must continue to describe the same service.
  • Keep the service detail action layout aligned with the service mode and permission rules. Scale must remain available only for replicated or replicated-job modes, and a completed scale action must refresh the displayed service state.
  • Keep the service creation flow aligned with the service editor contract. The submitted service name and specification must remain valid for the backend, and a successful create must refresh the list.
  • Keep node task navigation aligned with task filtering. A node action must carry the node ID and hostname so the task page shows the intended scope.
  • Keep node agent reconciliation aligned with environment changes. The warning count and node coverage must describe the selected environment after reconciliation completes.
  • Keep stack detail tabs aligned with source access and live service state. Saved source must remain visible for an undeployed stack when permitted, while live tabs must appear only when live services exist and must reflect the current service and task counts.
  • Keep stack source states distinct in the detail page. Missing, forbidden, and failed reads must not appear as an empty saved source, and the read-only source view must stay separate from the deployment editor.
  • Keep stack editor inputs aligned with deployment behavior. Compose, override, environment, extra files, pruning, registry authentication, and image resolution must reach the same deploy contract.

Important failure modes

TriggerConsequenceGuard
A resource operation reaches a Docker engine that is not an active managerThe service cannot list or change manager-owned Swarm resourcesManager and active-cluster checks run before manager operations in backend/…/service.go
A node agent reports a different Swarm node IDThe environment is marked mismatched instead of being shown as connected to the nodeIdentity is checked before binding and during node coverage enrichment
More than one environment appears to represent one nodeArcane cannot choose a safe bindingThe node remains ambiguous until an operator selects or reconciles one candidate
A stack source edit deploys unsuccessfullyThe live stack and saved source could disagreeUpdateStackSource restores the previous source after a failed redeploy
Stack tasks remain active after service removalStack removal can time out before resource cleanup completesRemoval waits for task convergence and returns a timeout after its bounded wait
A Swarm config or secret is removed while a workload still refers to itDocker rejects the removal or the workload loses a required resourceDocker validates resource use; the UI requires an explicit destructive confirmation
Two GitOps triggers fire for one sync at the same timeClone and deploy work can race and apply conflicting sourceThe per-sync admission lease allows only one run
A GitOps sync row is disabled or deleted without removing its old jobA stale job could keep trying to deploy itEach run re-reads the row and skips or unregisters itself
A scale action targets a global service or global jobThe request is rejected instead of changing an invalid replica targetThe backend accepts scaling only for replicated and replicated-job modes
A service create succeeds but the list is not refreshedThe new service is absent from the current resource viewThe service list closes the editor and reloads after creation
A node task action omits or changes the node filterThe task page opens with the wrong runtime scopeNode actions encode the node ID and hostname in the task URL
Node agent reconciliation completes for a different environmentCoverage from one environment can appear in another environment's node viewThe node page checks the selected environment before applying the result
A stack has saved source but no live servicesLive service and task tabs show no useful data, even though source remains availableStack detail derives live tabs from service count and keeps the source tab separate
Saved stack source is missing, forbidden, or fails to loadThe page could imply that an empty or unavailable source is validStack detail keeps explicit source states and renders the source editor only for available content
Stack editor options are not carried into deploymentSwarm can apply different pruning, registry, or image-resolution behavior than the operator selectedThe editor sends the deployment options with the stack source

Key files

FileWhy to read it
backend/…/service.goRoot Swarm service for dependency composition, cluster lifecycle, manager checks, task enrichment, and KV state
backend/…/handler.goAPI boundary for permissions, routes, response shapes, error mapping, and audit events
backend/…/module.goSwarm route registration and dependency boundary
backend/…/service.goNode views, agent coverage, environment binding, Easy Join, and node actions
backend/…/service.goService summaries, inspection, scaling, updates, rollback, logs, and task filters
backend/…/service.goStack summaries, Compose source, deployment, pruning, removal, and stack task views
backend/…/service.go and backend/…/service.goManager-backed config and secret lifecycle contracts
types/…/lifecycle.goCluster lifecycle, Easy Join, token, unlock, and node-agent contracts
types/…/service.goService summaries, inspection data, modes, scaling, and update contracts
types/…/stack.go and types/…/stack_deploy.goStack summaries, saved source, render results, and deployment inputs
types/…/node.go and types/…/task.goNode coverage and task runtime contracts
types/…/config_secret.goConfig and secret API shapes
frontend/…/swarm-service.tsFrontend request map for cluster lifecycle, node-agent, service, task, stack, config, and secret workflows
frontend/…/swarm-kv-page.svelteShared config and secret create, inspect, and remove experience
frontend/…/+page.svelteCluster setup, security, specification, and lifecycle experience
frontend/…/+page.svelteNode refresh, agent reconciliation, environment changes, and uncovered-node warning
frontend/…/nodes-table.svelteNode actions, agent binding, labels, and task navigation
frontend/…/+page.svelteStack list refresh and entry point for deployment
frontend/…/+page.svelteStack source editor and deployment choices
frontend/…/+page.svelteStack runtime tabs, saved-source states, service and task views, and deployment navigation
frontend/…/+page.svelteService creation entry point and list refresh behavior
frontend/…/+page.svelteService inspection, scalable service actions, and runtime action experience
frontend/…/+page.svelteAll-task and node-scoped task entry point with environment refresh behavior
frontend/…/ServiceLogsPanel.svelteService log stream controls, refresh behavior, and log display preferences
backend/…/gitops_sync.goScheduler-driven path from repository source to Swarm stack deployment
backend/…/entityjobs.goPer-entity job registration and single-run admission model