Skip to content

Modern Docker Management, Designed for Everyone

fix: block compose self-redeploy when arcane manages itself (#2404)

Giulio Savini6854f695ed14
diff --git a/backend/internal/common/errors.go b/backend/internal/common/errors.go
index 411dadfeb..b57941d72 100644
--- a/backend/internal/common/errors.go
+++ b/backend/internal/common/errors.go
@@ -180,6 +180,12 @@ func (e *ContainerRedeployError) Error() string {
return fmt.Sprintf("Failed to redeploy container: %v", e.Err)
}
+type ArcaneSelfRedeployError struct{}
+
+func (e *ArcaneSelfRedeployError) Error() string {
+ return "arcane cannot redeploy itself; use the system upgrade flow (Settings -> Updates) instead"
+}
+
type ContainerDeleteError struct {
Err error
}
diff --git a/backend/internal/huma/handlers/containers.go b/backend/internal/huma/handlers/containers.go
index 3aaff6448..bf4e789b4 100644
--- a/backend/internal/huma/handlers/containers.go
+++ b/backend/internal/huma/handlers/containers.go
@@ -581,13 +581,11 @@ func (h *ContainerHandler) GetContainer(ctx context.Context, input *GetContainer
return nil, huma.Error500InternalServerError("service not available")
}
- containerInspect, err := h.containerService.GetContainerByID(ctx, input.ContainerID)
+ details, err := h.containerService.GetContainerDetails(ctx, input.ContainerID)
if err != nil {
return nil, huma.Error404NotFound((&common.ContainerRetrievalError{Err: err}).Error())
}
- details := containertypes.NewDetails(containerInspect)
-
return &GetContainerOutput{
Body: ContainerDetailsResponse{
Success: true,
@@ -678,10 +676,8 @@ func (h *ContainerHandler) RedeployContainer(ctx context.Context, input *Contain
}
// Fetch full container details to return (consistent with other endpoints)
- containerInspect, inspectErr := h.containerService.GetContainerByID(ctx, newContainerID)
+ details, inspectErr := h.containerService.GetContainerDetails(ctx, newContainerID)
if inspectErr == nil {
- details := containertypes.NewDetails(containerInspect)
-
return &GetContainerOutput{
Body: ContainerDetailsResponse{
Success: true,
diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.go
index 64a7af3aa..d0e5cd0ce 100644
--- a/backend/internal/services/container_service.go
+++ b/backend/internal/services/container_service.go
@@ -13,12 +13,14 @@ import (
"time"
composetypes "github.com/compose-spec/compose-go/v2/types"
+ "github.com/getarcaneapp/arcane/backend/internal/common"
"github.com/getarcaneapp/arcane/backend/internal/database"
"github.com/getarcaneapp/arcane/backend/internal/models"
dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"
"github.com/getarcaneapp/arcane/backend/pkg/libarcane"
"github.com/getarcaneapp/arcane/backend/pkg/libarcane/containerstats"
"github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"
+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"
"github.com/getarcaneapp/arcane/backend/pkg/pagination"
"github.com/getarcaneapp/arcane/backend/pkg/projects"
containertypes "github.com/getarcaneapp/arcane/types/container"
@@ -459,6 +461,16 @@ func (s *ContainerService) RedeployContainer(ctx context.Context, containerID st
wasRunning := containerInfo.State != nil && containerInfo.State.Running
apiVersion := libarcane.DetectDockerAPIVersion(ctx, dockerClient)
+ currentContainerID, currentContainerErr := dockerutils.GetCurrentContainerID()
+ if libupdater.ShouldDisableArcaneServerRedeploy(containerInfo.Config.Labels, containerInfo.ID, currentContainerID, currentContainerErr) {
+ err = &common.ArcaneSelfRedeployError{}
+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", err, models.JSON{
+ "action": "redeploy",
+ "step": "self_redeploy_blocked",
+ })
+ return "", err
+ }
+
// If this container belongs to a known compose project, redeploy through the
// compose-aware path so that compose file changes (healthchecks, env, etc.) and
// the project's include/project_directory/env-file context are honored. The
@@ -575,6 +587,19 @@ func (s *ContainerService) GetContainerByID(ctx context.Context, id string) (*co
return s.GetContainerByReference(ctx, id)
}
+func (s *ContainerService) GetContainerDetails(ctx context.Context, id string) (containertypes.Details, error) {
+ containerInspect, err := s.GetContainerByID(ctx, id)
+ if err != nil {
+ return containertypes.Details{}, err
+ }
+
+ details := containertypes.NewDetails(containerInspect)
+ currentContainerID, currentContainerErr := dockerutils.GetCurrentContainerID()
+ details.RedeployDisabled = libupdater.ShouldDisableArcaneServerRedeploy(details.Labels, details.ID, currentContainerID, currentContainerErr)
+
+ return details, nil
+}
+
// GetContainerNameByReference resolves a container's clean name from a Docker ID or name.
func (s *ContainerService) GetContainerNameByReference(ctx context.Context, ref string) (string, error) {
info, err := s.GetContainerByReference(ctx, ref)
@@ -915,7 +940,8 @@ func (s *ContainerService) ListContainersPaginated(
dockerContainers = filterInternalContainers(dockerContainers, includeInternal)
imageIDs := collectImageIDs(dockerContainers)
updateInfoMap := s.getUpdateInfoMap(ctx, imageIDs)
- items := s.buildContainerSummaries(dockerContainers, updateInfoMap)
+ currentContainerID, currentContainerErr := dockerutils.GetCurrentContainerID()
+ items := s.buildContainerSummaries(dockerContainers, updateInfoMap, currentContainerID, currentContainerErr)
config := s.buildContainerPaginationConfig()
counts := s.calculateContainerStatusCounts(items)
@@ -1108,13 +1134,14 @@ func (s *ContainerService) getUpdateInfoMap(ctx context.Context, imageIDs []stri
return updateInfoMap
}
-func (s *ContainerService) buildContainerSummaries(containers []container.Summary, updateInfoMap map[string]*imagetypes.UpdateInfo) []containertypes.Summary {
+func (s *ContainerService) buildContainerSummaries(containers []container.Summary, updateInfoMap map[string]*imagetypes.UpdateInfo, currentContainerID string, currentContainerErr error) []containertypes.Summary {
items := make([]containertypes.Summary, 0, len(containers))
for _, dc := range containers {
summary := containertypes.NewSummary(dc)
if info, exists := updateInfoMap[dc.ImageID]; exists {
summary.UpdateInfo = info
}
+ summary.RedeployDisabled = libupdater.ShouldDisableArcaneServerRedeploy(summary.Labels, summary.ID, currentContainerID, currentContainerErr)
items = append(items, summary)
}
return items
diff --git a/backend/internal/services/dashboard_service.go b/backend/internal/services/dashboard_service.go
index 628b9c7a4..c5e514a2a 100644
--- a/backend/internal/services/dashboard_service.go
+++ b/backend/internal/services/dashboard_service.go
@@ -10,8 +10,10 @@ import (
"github.com/getarcaneapp/arcane/backend/internal/database"
"github.com/getarcaneapp/arcane/backend/internal/models"
+ dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"
"github.com/getarcaneapp/arcane/backend/pkg/libarcane"
"github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"
+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"
"github.com/getarcaneapp/arcane/types/base"
containertypes "github.com/getarcaneapp/arcane/types/container"
dashboardtypes "github.com/getarcaneapp/arcane/types/dashboard"
@@ -106,11 +108,14 @@ func (s *DashboardService) GetSnapshot(ctx context.Context, options DashboardAct
filteredContainers := filterInternalContainers(dockerContainers, false)
containerItems := make([]containertypes.Summary, 0, len(filteredContainers))
+ currentContainerID, currentContainerErr := dockerutils.GetCurrentContainerID()
if s.containerService != nil {
- containerItems = s.containerService.buildContainerSummaries(filteredContainers, nil)
+ containerItems = s.containerService.buildContainerSummaries(filteredContainers, nil, currentContainerID, currentContainerErr)
} else {
for _, container := range filteredContainers {
- containerItems = append(containerItems, containertypes.NewSummary(container))
+ summary := containertypes.NewSummary(container)
+ summary.RedeployDisabled = libupdater.ShouldDisableArcaneServerRedeploy(summary.Labels, summary.ID, currentContainerID, currentContainerErr)
+ containerItems = append(containerItems, summary)
}
}
diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.go
index 650d28a87..ede34e8a5 100644
--- a/backend/internal/services/project_service.go
+++ b/backend/internal/services/project_service.go
@@ -25,6 +25,7 @@ import (
dockerutil "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"
libbuild "github.com/getarcaneapp/arcane/backend/pkg/libarcane/libbuild"
"github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"
+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"
"github.com/getarcaneapp/arcane/backend/pkg/pagination"
"github.com/getarcaneapp/arcane/backend/pkg/projects"
"github.com/getarcaneapp/arcane/backend/pkg/utils"
@@ -153,15 +154,17 @@ func (s *ProjectService) getProjectRelativePathInternal(projectsDir, projectPath
// Helpers
type ProjectServiceInfo struct {
- Name string `json:"name"`
- Image string `json:"image"`
- Status string `json:"status"`
- ContainerID string `json:"container_id"`
- ContainerName string `json:"container_name"`
- Ports []string `json:"ports"`
- Health *string `json:"health,omitempty"`
- IconURL string `json:"icon_url,omitempty"`
- ServiceConfig *composetypes.ServiceConfig `json:"service_config,omitempty"`
+ Name string `json:"name"`
+ Image string `json:"image"`
+ Status string `json:"status"`
+ ContainerID string `json:"container_id"`
+ ContainerName string `json:"container_name"`
+ Ports []string `json:"ports"`
+ Health *string `json:"health,omitempty"`
+ IconURL string `json:"icon_url,omitempty"`
+ ServiceConfig *composetypes.ServiceConfig `json:"service_config,omitempty"`
+ Labels map[string]string `json:"labels,omitempty"`
+ RedeployDisabled bool `json:"redeploy_disabled,omitempty"`
}
type ProjectBuildOptions struct {
@@ -673,6 +676,7 @@ func (s *ProjectService) GetProjectServices(ctx context.Context, projectID strin
slog.Error("compose ps error", "projectName", composeProject.Name, "error", err)
return nil, fmt.Errorf("failed to get compose services status: %w", err)
}
+ currentContainerID, currentContainerErr := dockerutil.GetCurrentContainerID()
have := map[string]bool{}
var services []ProjectServiceInfo
@@ -695,15 +699,17 @@ func (s *ProjectService) GetProjectServices(ctx context.Context, projectID strin
}
services = append(services, ProjectServiceInfo{
- Name: c.Service,
- Image: c.Image,
- Status: string(c.State),
- ContainerID: c.ID,
- ContainerName: c.Name,
- Ports: formatPorts(c.Publishers),
- Health: health,
- IconURL: meta.ServiceIcons[c.Service],
- ServiceConfig: svcConfig,
+ Name: c.Service,
+ Image: c.Image,
+ Status: string(c.State),
+ ContainerID: c.ID,
+ ContainerName: c.Name,
+ Ports: formatPorts(c.Publishers),
+ Health: health,
+ IconURL: meta.ServiceIcons[c.Service],
+ ServiceConfig: svcConfig,
+ Labels: c.Labels,
+ RedeployDisabled: libupdater.ShouldDisableArcaneServerRedeploy(c.Labels, c.ID, currentContainerID, currentContainerErr),
})
have[c.Service] = true
}
@@ -799,15 +805,19 @@ func (s *ProjectService) GetProjectDetails(ctx context.Context, projectID string
runtimeServices := make([]project.RuntimeService, len(services))
for i, svc := range services {
runtimeServices[i] = project.RuntimeService{
- Name: svc.Name,
- Image: svc.Image,
- Status: svc.Status,
- ContainerID: svc.ContainerID,
- ContainerName: svc.ContainerName,
- Ports: svc.Ports,
- Health: svc.Health,
- IconURL: svc.IconURL,
- ServiceConfig: svc.ServiceConfig,
+ Name: svc.Name,
+ Image: svc.Image,
+ Status: svc.Status,
+ ContainerID: svc.ContainerID,
+ ContainerName: svc.ContainerName,
+ Ports: svc.Ports,
+ Health: svc.Health,
+ IconURL: svc.IconURL,
+ ServiceConfig: svc.ServiceConfig,
+ RedeployDisabled: svc.RedeployDisabled,
+ }
+ if svc.RedeployDisabled {
+ resp.RedeployDisabled = true
}
}
resp.RuntimeServices = runtimeServices
@@ -1693,6 +1703,14 @@ func (s *ProjectService) RedeployProject(ctx context.Context, projectID string,
return err
}
+ disabled, err := s.projectRedeployDisabledInternal(ctx, *proj)
+ if err != nil {
+ return err
+ }
+ if disabled {
+ return &common.ArcaneSelfRedeployError{}
+ }
+
if err := s.PullProjectImages(ctx, projectID, io.Discard, user, nil); err != nil {
slog.WarnContext(ctx, "failed to pull project images", "error", err)
}
@@ -1705,6 +1723,31 @@ func (s *ProjectService) RedeployProject(ctx context.Context, projectID string,
return s.DeployProject(ctx, projectID, user, nil)
}
+func (s *ProjectService) projectRedeployDisabledInternal(ctx context.Context, proj models.Project) (bool, error) {
+ containers, err := projects.ListGlobalComposeContainers(ctx)
+ if err != nil {
+ slog.WarnContext(ctx, "could not list compose containers to check self-redeploy guard; skipping guard", "error", err)
+ return false, nil
+ }
+
+ containersByProject := make(map[string][]container.Summary)
+ for _, c := range containers {
+ projectName := c.Labels["com.docker.compose.project"]
+ if projectName != "" {
+ containersByProject[projectName] = append(containersByProject[projectName], c)
+ }
+ }
+
+ currentContainerID, currentContainerErr := dockerutil.GetCurrentContainerID()
+ for _, container := range lookupProjectContainers(proj, containersByProject) {
+ if libupdater.ShouldDisableArcaneServerRedeploy(container.Labels, container.ID, currentContainerID, currentContainerErr) {
+ return true, nil
+ }
+ }
+
+ return false, nil
+}
+
func (s *ProjectService) PullProjectImages(ctx context.Context, projectID string, progressWriter io.Writer, user models.User, credentials []containerregistry.Credential) error {
proj, err := s.GetProjectFromDatabaseByID(ctx, projectID)
if err != nil {
@@ -3322,14 +3365,15 @@ func (s *ProjectService) fetchProjectStatusConcurrently(ctx context.Context, pro
// 3. Map to DTOs
results := make([]project.Details, len(projectsList))
+ currentContainerID, currentContainerErr := dockerutil.GetCurrentContainerID()
for i, p := range projectsList {
- results[i] = s.mapProjectToDto(ctx, projectsDir, p, containersByProject)
+ results[i] = s.mapProjectToDto(ctx, projectsDir, p, containersByProject, currentContainerID, currentContainerErr)
}
return results
}
-func (s *ProjectService) mapProjectToDto(ctx context.Context, projectsDir string, p models.Project, containersByProject map[string][]container.Summary) project.Details {
+func (s *ProjectService) mapProjectToDto(ctx context.Context, projectsDir string, p models.Project, containersByProject map[string][]container.Summary, currentContainerID string, currentContainerErr error) project.Details {
var resp project.Details
_ = mapper.MapStruct(p, &resp)
@@ -3368,14 +3412,21 @@ func (s *ProjectService) mapProjectToDto(ctx context.Context, projectsDir string
containerName = strings.TrimPrefix(c.Names[0], "/")
}
+ redeployDisabled := libupdater.ShouldDisableArcaneServerRedeploy(c.Labels, c.ID, currentContainerID, currentContainerErr)
+ if redeployDisabled {
+ resp.RedeployDisabled = true
+ }
+
services = append(services, ProjectServiceInfo{
- Name: svcName,
- Image: c.Image,
- Status: string(state),
- ContainerID: c.ID,
- ContainerName: containerName,
- Ports: formatDockerPorts(c.Ports),
- Health: health,
+ Name: svcName,
+ Image: c.Image,
+ Status: string(state),
+ ContainerID: c.ID,
+ ContainerName: containerName,
+ Ports: formatDockerPorts(c.Ports),
+ Health: health,
+ Labels: c.Labels,
+ RedeployDisabled: redeployDisabled,
})
if state == "running" {
@@ -3387,14 +3438,15 @@ func (s *ProjectService) mapProjectToDto(ctx context.Context, projectsDir string
runtimeServices := make([]project.RuntimeService, len(services))
for k, s := range services {
runtimeServices[k] = project.RuntimeService{
- Name: s.Name,
- Image: s.Image,
- Status: s.Status,
- ContainerID: s.ContainerID,
- ContainerName: s.ContainerName,
- Ports: s.Ports,
- Health: s.Health,
- ServiceConfig: s.ServiceConfig,
+ Name: s.Name,
+ Image: s.Image,
+ Status: s.Status,
+ ContainerID: s.ContainerID,
+ ContainerName: s.ContainerName,
+ Ports: s.Ports,
+ Health: s.Health,
+ ServiceConfig: s.ServiceConfig,
+ RedeployDisabled: s.RedeployDisabled,
}
}
resp.RuntimeServices = runtimeServices
diff --git a/backend/internal/services/project_service_test.go b/backend/internal/services/project_service_test.go
index 6bb18242e..055a5beb3 100644
--- a/backend/internal/services/project_service_test.go
+++ b/backend/internal/services/project_service_test.go
@@ -17,6 +17,7 @@ import (
composetypes "github.com/compose-spec/compose-go/v2/types"
"github.com/getarcaneapp/arcane/backend/internal/config"
+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"
"github.com/getarcaneapp/arcane/backend/pkg/pagination"
"github.com/getarcaneapp/arcane/backend/pkg/projects"
buildtypes "github.com/getarcaneapp/arcane/types/builds"
@@ -1979,6 +1980,98 @@ func TestProjectService_ListProjects_FiltersByUpdateStatus(t *testing.T) {
}
}
+func TestProjectService_MapProjectToDto_SetsRedeployDisabledFromRuntimeServices(t *testing.T) {
+ projectPath := filepath.Join(t.TempDir(), "arcane")
+ now := time.Now()
+ proj := models.Project{
+ Name: "arcane",
+ Path: projectPath,
+ ServiceCount: 1,
+ BaseModel: models.BaseModel{
+ ID: "project-arcane",
+ CreatedAt: now,
+ UpdatedAt: &now,
+ },
+ }
+
+ tests := []struct {
+ name string
+ containerID string
+ currentContainerID string
+ currentErr error
+ labels map[string]string
+ wantProject bool
+ wantService bool
+ }{
+ {
+ name: "current Arcane server container disables project redeploy",
+ containerID: "arcane1234567890",
+ currentContainerID: "arcane1234567890",
+ labels: map[string]string{
+ "com.docker.compose.project": "arcane",
+ "com.docker.compose.service": "server",
+ libupdater.LabelArcane: "true",
+ },
+ wantProject: true,
+ wantService: true,
+ },
+ {
+ name: "Arcane server container fails closed when current container is unavailable",
+ containerID: "arcane1234567890",
+ currentErr: errors.New("not running in docker"),
+ labels: map[string]string{
+ "com.docker.compose.project": "arcane",
+ "com.docker.compose.service": "server",
+ libupdater.LabelArcane: "true",
+ },
+ wantProject: true,
+ wantService: true,
+ },
+ {
+ name: "Arcane agent container stays redeployable",
+ containerID: "agent1234567890",
+ currentContainerID: "agent1234567890",
+ labels: map[string]string{
+ "com.docker.compose.project": "arcane",
+ "com.docker.compose.service": "agent",
+ libupdater.LabelArcane: "true",
+ libupdater.LabelArcaneAgent: "true",
+ },
+ },
+ {
+ name: "non Arcane container stays redeployable",
+ containerID: "regular1234567890",
+ currentContainerID: "regular1234567890",
+ labels: map[string]string{
+ "com.docker.compose.project": "arcane",
+ "com.docker.compose.service": "postgres",
+ },
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ service := &ProjectService{}
+ details := service.mapProjectToDto(context.Background(), filepath.Dir(projectPath), proj, map[string][]container.Summary{
+ "arcane": {
+ {
+ ID: tt.containerID,
+ Image: "ghcr.io/getarcaneapp/arcane:latest",
+ State: "running",
+ Status: "Up",
+ Names: []string{"/arcane-server"},
+ Labels: tt.labels,
+ },
+ },
+ }, tt.currentContainerID, tt.currentErr)
+
+ require.Equal(t, tt.wantProject, details.RedeployDisabled)
+ require.Len(t, details.RuntimeServices, 1)
+ require.Equal(t, tt.wantService, details.RuntimeServices[0].RedeployDisabled)
+ })
+ }
+}
+
func TestProjectService_MergeBuildTags(t *testing.T) {
tags := mergeBuildTags("example/app:latest", []string{"example/app:sha", "example/app:latest", " "})
assert.Equal(t, []string{"example/app:latest", "example/app:sha"}, tags)
diff --git a/backend/pkg/libarcane/updater/labels.go b/backend/pkg/libarcane/updater/labels.go
index 726b811cb..e7453cde8 100644
--- a/backend/pkg/libarcane/updater/labels.go
+++ b/backend/pkg/libarcane/updater/labels.go
@@ -18,6 +18,26 @@ func IsArcaneContainer(labels map[string]string) bool {
return hasTruthyLabelInternal(labels, LabelArcane) || IsArcaneAgentContainer(labels)
}
+// IsArcaneServerContainer checks if the container is the Arcane server, excluding agents.
+func IsArcaneServerContainer(labels map[string]string) bool {
+ return hasTruthyLabelInternal(labels, LabelArcane) && !IsArcaneAgentContainer(labels)
+}
+
+// ShouldDisableArcaneServerRedeploy reports whether redeploy should be blocked for the given container.
+func ShouldDisableArcaneServerRedeploy(labels map[string]string, containerID, currentContainerID string, currentErr error) bool {
+ if !IsArcaneServerContainer(labels) {
+ return false
+ }
+
+ if currentErr != nil || strings.TrimSpace(currentContainerID) == "" {
+ // Without a runtime container ID, non-agent Arcane server labels are treated as protected.
+ // This prevents accidental self-redeploy, but native/CI runs can mark other Arcane servers disabled.
+ return true
+ }
+
+ return containerIDsMatchInternal(containerID, currentContainerID)
+}
+
// IsArcaneAgentContainer checks if the container is an Arcane agent container.
func IsArcaneAgentContainer(labels map[string]string) bool {
return hasTruthyLabelInternal(labels, LabelArcaneAgent)
@@ -77,3 +97,13 @@ func isTruthyLabelValueInternal(v string) bool {
return false
}
}
+
+func containerIDsMatchInternal(a, b string) bool {
+ a = strings.TrimSpace(a)
+ b = strings.TrimSpace(b)
+ if a == "" || b == "" {
+ return false
+ }
+
+ return a == b || strings.HasPrefix(a, b) || strings.HasPrefix(b, a)
+}
diff --git a/backend/pkg/libarcane/updater/labels_test.go b/backend/pkg/libarcane/updater/labels_test.go
index 3129197e5..68a9f74e7 100644
--- a/backend/pkg/libarcane/updater/labels_test.go
+++ b/backend/pkg/libarcane/updater/labels_test.go
@@ -1,6 +1,7 @@
package updater
import (
+ "errors"
"testing"
)
@@ -128,6 +129,64 @@ func TestIsArcaneAgentContainer(t *testing.T) {
}
}
+func TestIsArcaneServerContainer(t *testing.T) {
+ tests := []struct {
+ name string
+ labels map[string]string
+ want bool
+ }{
+ {
+ name: "nil labels",
+ labels: nil,
+ want: false,
+ },
+ {
+ name: "server label true",
+ labels: map[string]string{LabelArcane: "true"},
+ want: true,
+ },
+ {
+ name: "server label case insensitive key",
+ labels: map[string]string{"COM.GETARCANEAPP.ARCANE": "on"},
+ want: true,
+ },
+ {
+ name: "server label false",
+ labels: map[string]string{LabelArcane: "off"},
+ want: false,
+ },
+ {
+ name: "agent label only",
+ labels: map[string]string{LabelArcaneAgent: "true"},
+ want: false,
+ },
+ {
+ name: "agent label wins over server label",
+ labels: map[string]string{
+ LabelArcane: "true",
+ LabelArcaneAgent: "true",
+ },
+ want: false,
+ },
+ {
+ name: "false agent label does not exclude server",
+ labels: map[string]string{
+ LabelArcane: "true",
+ LabelArcaneAgent: "false",
+ },
+ want: true,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := IsArcaneServerContainer(tt.labels); got != tt.want {
+ t.Errorf("IsArcaneServerContainer() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
func TestIsUpdateDisabled(t *testing.T) {
tests := []struct {
name string
@@ -200,6 +259,79 @@ func TestIsUpdateDisabled(t *testing.T) {
}
}
+func TestShouldDisableArcaneServerRedeploy(t *testing.T) {
+ tests := []struct {
+ name string
+ labels map[string]string
+ containerID string
+ currentContainerID string
+ currentErr error
+ want bool
+ }{
+ {
+ name: "current Arcane server container",
+ labels: map[string]string{LabelArcane: "true"},
+ containerID: "abcdef1234567890",
+ currentContainerID: "abcdef1234567890",
+ want: true,
+ },
+ {
+ name: "current Arcane server container with short detected ID",
+ labels: map[string]string{LabelArcane: "true"},
+ containerID: "abcdef1234567890",
+ currentContainerID: "abcdef123456",
+ want: true,
+ },
+ {
+ name: "different Arcane server container",
+ labels: map[string]string{LabelArcane: "true"},
+ containerID: "abcdef1234567890",
+ currentContainerID: "123456abcdef7890",
+ want: false,
+ },
+ {
+ name: "fail closed when current container cannot be detected",
+ labels: map[string]string{LabelArcane: "true"},
+ containerID: "abcdef1234567890",
+ currentErr: errors.New("not in docker"),
+ want: true,
+ },
+ {
+ name: "agent container remains redeployable",
+ labels: map[string]string{LabelArcaneAgent: "true"},
+ containerID: "abcdef1234567890",
+ currentContainerID: "abcdef1234567890",
+ want: false,
+ },
+ {
+ name: "agent label excludes Arcane server label",
+ labels: map[string]string{
+ LabelArcane: "true",
+ LabelArcaneAgent: "true",
+ },
+ containerID: "abcdef1234567890",
+ currentContainerID: "abcdef1234567890",
+ want: false,
+ },
+ {
+ name: "non-Arcane container",
+ labels: map[string]string{"app": "demo"},
+ containerID: "abcdef1234567890",
+ currentContainerID: "abcdef1234567890",
+ want: false,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got := ShouldDisableArcaneServerRedeploy(tt.labels, tt.containerID, tt.currentContainerID, tt.currentErr)
+ if got != tt.want {
+ t.Errorf("ShouldDisableArcaneServerRedeploy() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
func TestGetStopSignal(t *testing.T) {
tests := []struct {
name string
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index d147fa2b1..4e809212c 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -194,6 +194,7 @@
"log_parsed_mode_tooltip": "Shows structured logs in parsed form when available. Turn it off to see the original raw line text.",
"common_logout": "Logout",
"common_redeploy": "Redeploy",
+ "common_redeploy_disabled_arcane_self": "Managed by Arcane; use Settings > Updates.",
"common_use_template": "Use Template",
"maintenance_title": "Maintenance",
"scheduled_prune_title": "Scheduled Prune",
diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelte
index a86382fd9..225b11307 100644
--- a/frontend/src/lib/components/action-buttons.svelte
+++ b/frontend/src/lib/components/action-buttons.svelte
@@ -49,6 +49,7 @@
redeployLoading = $bindable(false),
refreshLoading = $bindable(false),
hasBuildDirective = false,
+ disableRedeploy = false,
onRefresh
}: {
id: string;
@@ -65,6 +66,7 @@
redeployLoading?: boolean;
refreshLoading?: boolean;
hasBuildDirective?: boolean;
+ disableRedeploy?: boolean;
onRefresh?: () => void | Promise<void>;
} = $props();
@@ -827,6 +829,28 @@
}
</script>
+{#snippet RedeployActionButton(size: 'default' | 'icon' = 'default', showLabel = true)}
+ {#if disableRedeploy}
+ <span class="inline-flex" title={m.common_redeploy_disabled_arcane_self()}>
+ <ArcaneButton action="redeploy" {size} {showLabel} disabled />
+ </span>
+ {:else}
+ <ArcaneButton action="redeploy" {size} {showLabel} onclick={() => confirmAction('redeploy')} loading={uiLoading.redeploy} />
+ {/if}
+{/snippet}
+
+{#snippet RedeployMenuItem()}
+ {#if disableRedeploy}
+ <DropdownMenu.Item disabled title={m.common_redeploy_disabled_arcane_self()}>
+ {m.common_redeploy()}
+ </DropdownMenu.Item>
+ {:else}
+ <DropdownMenu.Item onclick={() => confirmAction('redeploy')} disabled={uiLoading.redeploy}>
+ {m.common_redeploy()}
+ </DropdownMenu.Item>
+ {/if}
+{/snippet}
+
{#if desktopVariant === 'adaptive'}
<div>
<!-- On xl+ show labels; below xl use icon-only to avoid overflow in constrained headers (sidebar layouts) -->
@@ -886,13 +910,7 @@
{/if}
{#if type === 'container'}
- <ArcaneButton
- action="redeploy"
- size={adaptiveIconOnly ? 'icon' : 'default'}
- showLabel={!adaptiveIconOnly}
- onclick={() => confirmAction('redeploy')}
- loading={uiLoading.redeploy}
- />
+ {@render RedeployActionButton(adaptiveIconOnly ? 'icon' : 'default', !adaptiveIconOnly)}
<ArcaneButton
action="remove"
size={adaptiveIconOnly ? 'icon' : 'default'}
@@ -901,13 +919,7 @@
loading={uiLoading.remove}
/>
{:else}
- <ArcaneButton
- action="redeploy"
- size={adaptiveIconOnly ? 'icon' : 'default'}
- showLabel={!adaptiveIconOnly}
- onclick={() => confirmAction('redeploy')}
- loading={uiLoading.redeploy}
- />
+ {@render RedeployActionButton(adaptiveIconOnly ? 'icon' : 'default', !adaptiveIconOnly)}
{#if type === 'project'}
{#if projectHasBuildDirective}
@@ -1028,16 +1040,12 @@
{/if}
{#if type === 'container'}
- <DropdownMenu.Item onclick={() => confirmAction('redeploy')} disabled={uiLoading.redeploy}>
- {m.common_redeploy()}
- </DropdownMenu.Item>
+ {@render RedeployMenuItem()}
<DropdownMenu.Item onclick={() => confirmAction('remove')} disabled={uiLoading.remove}>
{m.common_remove()}
</DropdownMenu.Item>
{:else}
- <DropdownMenu.Item onclick={() => confirmAction('redeploy')} disabled={uiLoading.redeploy}>
- {m.common_redeploy()}
- </DropdownMenu.Item>
+ {@render RedeployMenuItem()}
{#if type === 'project'}
{#if projectHasBuildDirective}
@@ -1155,10 +1163,10 @@
{/if}
{#if type === 'container'}
- <ArcaneButton action="redeploy" onclick={() => confirmAction('redeploy')} loading={uiLoading.redeploy} />
+ {@render RedeployActionButton()}
<ArcaneButton action="remove" onclick={() => confirmAction('remove')} loading={uiLoading.remove} />
{:else}
- <ArcaneButton action="redeploy" onclick={() => confirmAction('redeploy')} loading={uiLoading.redeploy} />
+ {@render RedeployActionButton()}
{#if type === 'project'}
{#if projectHasBuildDirective}
@@ -1259,16 +1267,12 @@
{/if}
{#if type === 'container'}
- <DropdownMenu.Item onclick={() => confirmAction('redeploy')} disabled={uiLoading.redeploy}>
- {m.common_redeploy()}
- </DropdownMenu.Item>
+ {@render RedeployMenuItem()}
<DropdownMenu.Item onclick={() => confirmAction('remove')} disabled={uiLoading.remove}>
{m.common_remove()}
</DropdownMenu.Item>
{:else}
- <DropdownMenu.Item onclick={() => confirmAction('redeploy')} disabled={uiLoading.redeploy}>
- {m.common_redeploy()}
- </DropdownMenu.Item>
+ {@render RedeployMenuItem()}
{#if type === 'project'}
{#if projectHasBuildDirective}
diff --git a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
index 91cfc96b3..8361eefae 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
+++ b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
@@ -209,6 +209,7 @@
onclick={() => bulkAction.onClick(selectedIds!)}
disabled={bulkAction.disabled || bulkAction.loading}
loading={bulkAction.loading}
+ title={bulkAction.disabled ? bulkAction.disabledReason : undefined}
class="h-9"
/>
{/each}
diff --git a/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts b/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
index e0304bf48..f26f8c8a2 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
+++ b/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
@@ -124,6 +124,7 @@ export type BulkAction = {
action: 'start' | 'stop' | 'restart' | 'remove' | 'deploy' | 'redeploy' | 'up' | 'down';
onClick: (ids: string[]) => void;
disabled?: boolean;
+ disabledReason?: string;
loading?: boolean;
icon?: any;
};
diff --git a/frontend/src/lib/types/container.type.ts b/frontend/src/lib/types/container.type.ts
index abeb0d485..310b12217 100644
--- a/frontend/src/lib/types/container.type.ts
+++ b/frontend/src/lib/types/container.type.ts
@@ -73,6 +73,7 @@ export interface ContainerSummaryDto extends BaseContainer {
networkSettings: ContainerNetworkSettings;
mounts: ContainerMounts[];
updateInfo?: ImageUpdateInfoDto;
+ redeployDisabled?: boolean;
}
export interface ContainerSummaryGroupDto {
@@ -203,6 +204,7 @@ export interface ContainerDetailsDto {
mounts: ContainerMounts[];
labels: Record<string, string>;
composeInfo?: ComposeInfo;
+ redeployDisabled?: boolean;
}
// Container Stats Types
diff --git a/frontend/src/lib/types/project.type.ts b/frontend/src/lib/types/project.type.ts
index 6d34db2c0..24685b2af 100644
--- a/frontend/src/lib/types/project.type.ts
+++ b/frontend/src/lib/types/project.type.ts
@@ -62,6 +62,7 @@ export interface RuntimeService {
health?: string;
iconUrl?: string;
serviceConfig?: ProjectService;
+ redeployDisabled?: boolean;
}
export interface ProjectUpdateInfo {
@@ -95,6 +96,7 @@ export interface Project {
lastSyncCommit?: string;
gitRepositoryURL?: string;
hasBuildDirective?: boolean;
+ redeployDisabled?: boolean;
updateInfo?: ProjectUpdateInfo;
services?: ProjectService[];
runtimeServices?: RuntimeService[];
diff --git a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte
index 631911e2c..0a50133ce 100644
--- a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte
+++ b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte
@@ -295,6 +295,7 @@
type="container"
itemState={container.state?.running ? 'running' : 'stopped'}
desktopVariant="adaptive"
+ disableRedeploy={!!container.redeployDisabled}
/>
{/snippet}
diff --git a/frontend/src/routes/(app)/containers/container-table.svelte b/frontend/src/routes/(app)/containers/container-table.svelte
index ea3ee2fba..daf979f73 100644
--- a/frontend/src/routes/(app)/containers/container-table.svelte
+++ b/frontend/src/routes/(app)/containers/container-table.svelte
@@ -646,14 +646,21 @@
</DropdownMenu.Item>
{/if}
- <DropdownMenu.Item onclick={() => handleRedeployContainer(item)} disabled={status === 'redeploying' || isAnyLoading}>
- {#if status === 'redeploying'}
- <Spinner class="size-4" />
- {:else}
- <RedeployIcon class="size-4" />
- {/if}
- {m.common_redeploy()}
- </DropdownMenu.Item>
+ {#if item.redeployDisabled}
+ <DropdownMenu.Item disabled title={m.common_redeploy_disabled_arcane_self()}>
+ <RedeployIcon class="size-4 opacity-50" />
+ {m.common_redeploy()}
+ </DropdownMenu.Item>
+ {:else}
+ <DropdownMenu.Item onclick={() => handleRedeployContainer(item)} disabled={status === 'redeploying' || isAnyLoading}>
+ {#if status === 'redeploying'}
+ <Spinner class="size-4" />
+ {:else}
+ <RedeployIcon class="size-4" />
+ {/if}
+ {m.common_redeploy()}
+ </DropdownMenu.Item>
+ {/if}
<DropdownMenu.Separator />
diff --git a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
index 76c9b2dba..e3377474a 100644
--- a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
+++ b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
@@ -713,6 +713,7 @@
itemState={project.status}
{hasBuildDirective}
desktopVariant="adaptive"
+ disableRedeploy={!!project.redeployDisabled}
bind:startLoading={isLoading.deploying}
bind:stopLoading={isLoading.stopping}
bind:restartLoading={isLoading.restarting}
diff --git a/frontend/src/routes/(app)/projects/projects-table.svelte b/frontend/src/routes/(app)/projects/projects-table.svelte
index bf518f15a..ba38b8586 100644
--- a/frontend/src/routes/(app)/projects/projects-table.svelte
+++ b/frontend/src/routes/(app)/projects/projects-table.svelte
@@ -116,6 +116,8 @@
const isAnyLoading = $derived(
Object.values(actionStatus).some((status) => status !== '') || Object.values(isBulkLoading).some((loading) => loading)
);
+ const selectedProjects = $derived.by(() => (projects?.data ?? []).filter((project) => selectedIds?.includes(project.id)));
+ const hasRedeployDisabledSelection = $derived.by(() => selectedProjects.some((project) => project.redeployDisabled));
const columns = [
{ accessorKey: 'id', title: m.common_id(), hidden: true },
@@ -169,7 +171,8 @@
action: 'redeploy',
onClick: handleBulkRedeploy,
loading: isBulkLoading.redeploy,
- disabled: isAnyLoading,
+ disabled: isAnyLoading || hasRedeployDisabledSelection,
+ disabledReason: hasRedeployDisabledSelection ? m.common_redeploy_disabled_arcane_self() : undefined,
icon: RedeployIcon
}
]);
@@ -377,17 +380,24 @@
</DropdownMenu.Item>
{/if}
- <DropdownMenu.Item
- onclick={() => performProjectAction('redeploy', item.id)}
- disabled={status === 'redeploying' || isAnyLoading}
- >
- {#if status === 'redeploying'}
- <Spinner class="size-4" />
- {:else}
- <RedeployIcon class="size-4" />
- {/if}
- {m.compose_pull_redeploy()}
- </DropdownMenu.Item>
+ {#if item.redeployDisabled}
+ <DropdownMenu.Item disabled title={m.common_redeploy_disabled_arcane_self()}>
+ <RedeployIcon class="size-4 opacity-50" />
+ {m.compose_pull_redeploy()}
+ </DropdownMenu.Item>
+ {:else}
+ <DropdownMenu.Item
+ onclick={() => performProjectAction('redeploy', item.id)}
+ disabled={status === 'redeploying' || isAnyLoading}
+ >
+ {#if status === 'redeploying'}
+ <Spinner class="size-4" />
+ {:else}
+ <RedeployIcon class="size-4" />
+ {/if}
+ {m.compose_pull_redeploy()}
+ </DropdownMenu.Item>
+ {/if}
<DropdownMenu.Separator />
diff --git a/types/container/container.go b/types/container/container.go
index 805f45470..55452116e 100644
--- a/types/container/container.go
+++ b/types/container/container.go
@@ -721,6 +721,11 @@ type Summary struct {
//
// Required: false
UpdateInfo *imagetypes.UpdateInfo `json:"updateInfo,omitempty"`
+
+ // RedeployDisabled indicates whether redeploy actions are disabled for this container.
+ //
+ // Required: false
+ RedeployDisabled bool `json:"redeployDisabled,omitempty"`
}
// ComposeInfo contains Docker Compose project information extracted from container labels.
@@ -826,6 +831,11 @@ type Details struct {
//
// Required: false
ComposeInfo *ComposeInfo `json:"composeInfo,omitempty"`
+
+ // RedeployDisabled indicates whether redeploy actions are disabled for this container.
+ //
+ // Required: false
+ RedeployDisabled bool `json:"redeployDisabled,omitempty"`
}
// Created represents a newly created container.
diff --git a/types/project/project.go b/types/project/project.go
index 62f2399a5..8231a39a2 100644
--- a/types/project/project.go
+++ b/types/project/project.go
@@ -141,6 +141,11 @@ type RuntimeService struct {
//
// Required: false
ServiceConfig *composetypes.ServiceConfig `json:"serviceConfig,omitempty"`
+
+ // RedeployDisabled indicates whether redeploy actions are disabled for this runtime service.
+ //
+ // Required: false
+ RedeployDisabled bool `json:"redeployDisabled,omitempty"`
}
// UpdateInfo contains aggregated image update status for a project.
@@ -373,6 +378,11 @@ type Details struct {
// Required: false
HasBuildDirective bool `json:"hasBuildDirective,omitempty"`
+ // RedeployDisabled indicates whether redeploy actions are disabled for this project.
+ //
+ // Required: false
+ RedeployDisabled bool `json:"redeployDisabled,omitempty"`
+
// GitOpsManagedBy is the ID of the GitOps sync managing this project (if any).
//
// Required: false