Skip to content

Modern Docker Management, Designed for Everyone

fix: keep pinned Compose tags unless updater strategy opts in (#4180)

Kyle Mendell72532defe45a
diff --git a/backend/go.mod b/backend/go.mod
index 6142db149..ff01cf761 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -76,7 +76,7 @@ require (
go.getarcane.app/streams v0.4.3
go.getarcane.app/sys/cgroup v0.2.3
go.getarcane.app/sys/crypto v0.2.1
- go.getarcane.app/updater v0.10.0
+ go.getarcane.app/updater v0.10.1
go.uber.org/fx v1.24.0
go.yaml.in/yaml/v4 v4.0.0-rc.6
golang.org/x/crypto v0.57.0
diff --git a/backend/go.sum b/backend/go.sum
index dac7628d9..883fe507e 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -746,8 +746,8 @@ go.getarcane.app/sys/cgroup v0.2.3 h1:+eGLUC+3Ct+BNcPBQwC/g/psDOzjWN2vUr6KhKyNWg
go.getarcane.app/sys/cgroup v0.2.3/go.mod h1:1ksFb/psBkQlOsS9D6OFydd9Evpb0mCoJzyCyb9RoL8=
go.getarcane.app/sys/crypto v0.2.1 h1:A2HFmCRnDAj4/gl96apUifmw95verB5HCaPyNsHSAl8=
go.getarcane.app/sys/crypto v0.2.1/go.mod h1:bA7dHfhnUCXl06+RxBJjwtoLR01J9WSZft6yoVnW4jE=
-go.getarcane.app/updater v0.10.0 h1:6Nh5mo9QupiZAYQpJIZSUGftDmbjNBZqJfLzcB2pAvc=
-go.getarcane.app/updater v0.10.0/go.mod h1:F7KT3jTCLKc5PS7dNPTSigqe9RglgVevkJVWSAmafHE=
+go.getarcane.app/updater v0.10.1 h1:NgWueoPciGg8fFdy0AAFxkEzQgULCiZW0UtteFM2x30=
+go.getarcane.app/updater v0.10.1/go.mod h1:F7KT3jTCLKc5PS7dNPTSigqe9RglgVevkJVWSAmafHE=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
diff --git a/backend/internal/container/service_test.go b/backend/internal/container/service_test.go
index be127ccfb..00c8b903e 100644
--- a/backend/internal/container/service_test.go
+++ b/backend/internal/container/service_test.go
@@ -603,14 +603,13 @@ func TestBuildSummariesUsesContainerTagPolicyUpdates(t *testing.T) {
}
updates := map[string]*imagetypes.UpdateInfo{
"shared-image": {HasUpdate: true, UpdateType: "digest"},
- "container::first": {HasUpdate: true, UpdateType: "tag", LatestVersion: "3.2.0"},
"container::second": {HasUpdate: true, UpdateType: "tag", LatestVersion: "4.0.0"},
}
items := service.BuildSummaries(t.Context(), containers, updates, "", nil)
- require.Equal(t, "tag", items[0].UpdateStrategy)
+ require.Equal(t, "digest", items[0].UpdateStrategy, "an unlabeled container follows the digest")
require.Equal(t, "tag", items[1].UpdateStrategy)
require.Equal(t, "digest", items[3].UpdateStrategy)
- require.Equal(t, "3.2.0", items[0].UpdateInfo.LatestVersion)
+ require.Equal(t, "digest", items[0].UpdateInfo.UpdateType)
require.Equal(t, "4.0.0", items[1].UpdateInfo.LatestVersion)
require.Nil(t, items[2].UpdateInfo)
require.Equal(t, "digest", items[3].UpdateInfo.UpdateType)
diff --git a/backend/internal/dashboard/service_test.go b/backend/internal/dashboard/service_test.go
index 7432a539c..385d9b558 100644
--- a/backend/internal/dashboard/service_test.go
+++ b/backend/internal/dashboard/service_test.go
@@ -445,8 +445,8 @@ func TestPendingContainerCountUsesScopedTagRecords(t *testing.T) {
require.NoError(t, db.Create(&records).Error)
service := &DashboardService{db: db}
containers := []dockercontainer.Summary{
- {ID: "first", Image: "app:1.2.3", ImageID: "shared", Labels: map[string]string{}},
- {ID: "unchecked", Image: "app:1.2.3", ImageID: "shared"},
+ {ID: "first", Image: "app:1.2.3", ImageID: "shared", Labels: map[string]string{labels.LabelUpdateStrategy: "auto"}},
+ {ID: "unchecked", Image: "app:1.2.3", ImageID: "shared", Labels: map[string]string{labels.LabelUpdateStrategy: "auto"}},
}
count, err := service.getPendingContainerUpdatesCountInternal(t.Context(), containers)
require.NoError(t, err)
diff --git a/backend/internal/imageupdate/service_test.go b/backend/internal/imageupdate/service_test.go
index 7047a10b3..5832194f8 100644
--- a/backend/internal/imageupdate/service_test.go
+++ b/backend/internal/imageupdate/service_test.go
@@ -69,6 +69,9 @@ func (f *fakeRegistryDaemonClient) DistributionInspect(ctx context.Context, imag
return f.distributionInspectFn(ctx, imageRef, options)
}
+// autoLabels opts a test container into tag-based update checks.
+var autoLabels = map[string]string{labels.LabelUpdateStrategy: "auto"}
+
func newImageUpdateTestDockerClientInternal(t *testing.T, server *httptest.Server) *client.Client {
t.Helper()
cli, err := client.New(
@@ -2380,7 +2383,7 @@ func TestContainerTagChecksPersistIndependentPoliciesInternal(t *testing.T) {
imageRef := registryURL.Host + "/team/app:1.0.0"
imageID := digest.FromString("shared").String()
values := map[string]map[string]string{
- "one": {},
+ "one": {labels.LabelUpdateStrategy: "auto"},
"two": {labels.LabelUpdateStrategy: "auto", labels.LabelUpdateConstraint: "2.x"},
}
dockerServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -2425,6 +2428,8 @@ func TestContainerTagChecksPersistIndependentPoliciesInternal(t *testing.T) {
single, checkErr := svc.CheckImageUpdate(t.Context(), imageRef)
require.NoError(t, checkErr)
require.True(t, single.HasUpdate)
+ require.Equal(t, UpdateTypeTag, single.UpdateType)
+ require.Equal(t, "1.1.0", single.LatestVersion, "the first container candidate promotes the image result")
require.NotEmpty(t, single.Error, "keep the old-tag digest error visible")
require.Len(t, single.ContainerUpdates, 2)
// The image-level digest error is stored independently of container candidates.
@@ -2463,6 +2468,8 @@ func TestContainerAggregationPreservesImageResultInternal(t *testing.T) {
scoped := &imageupdate.Response{ImageRef: "docker.io/library/alpine:3.20.0", HasUpdate: true, UpdateType: UpdateTypeTag, CurrentVersion: "3.20.0", LatestVersion: "3.20.1"}
attachContainerUpdatesInternal(results, map[string]*imageupdate.Response{"tagged": scoped})
require.True(t, original.HasUpdate)
+ require.Equal(t, UpdateTypeTag, original.UpdateType)
+ require.Equal(t, "3.20.1", original.LatestVersion)
require.Same(t, scoped, original.ContainerUpdates["tagged"])
require.NotNil(t, original.ImageUpdate)
require.False(t, original.ImageUpdate.HasUpdate, "untagged siblings must keep the original digest result")
@@ -2507,11 +2514,11 @@ func TestContainerTagChecksUseRegistryTagTimeoutInternal(t *testing.T) {
w.Header().Set("Content-Type", "application/json")
switch {
case strings.HasSuffix(r.URL.Path, "/containers/json"):
- require.NoError(t, json.NewEncoder(w).Encode([]dockertypescontainer.Summary{{ID: "one", Image: imageRef, ImageID: imageID}}))
+ require.NoError(t, json.NewEncoder(w).Encode([]dockertypescontainer.Summary{{ID: "one", Image: imageRef, ImageID: imageID, Labels: autoLabels}}))
case strings.Contains(r.URL.Path, "/images/"):
require.NoError(t, json.NewEncoder(w).Encode(dockertypesimage.InspectResponse{ID: imageID, RepoTags: []string{imageRef}}))
case strings.Contains(r.URL.Path, "/containers/"):
- require.NoError(t, json.NewEncoder(w).Encode(dockertypescontainer.InspectResponse{ID: "one", Image: imageID, Config: &dockertypescontainer.Config{Image: imageRef}}))
+ require.NoError(t, json.NewEncoder(w).Encode(dockertypescontainer.InspectResponse{ID: "one", Image: imageID, Config: &dockertypescontainer.Config{Image: imageRef, Labels: autoLabels}}))
default:
http.NotFound(w, r)
}
@@ -2574,13 +2581,13 @@ func TestContainerTagChecksPersistResultsFinishedBeforeScanDeadlineInternal(t *t
switch {
case strings.HasSuffix(r.URL.Path, "/containers/json"):
require.NoError(t, json.NewEncoder(w).Encode([]dockertypescontainer.Summary{
- {ID: "fast", Image: imageRefs["fast"], ImageID: imageIDs["fast"]},
- {ID: "slow", Image: imageRefs["slow"], ImageID: imageIDs["slow"]},
+ {ID: "fast", Image: imageRefs["fast"], ImageID: imageIDs["fast"], Labels: autoLabels},
+ {ID: "slow", Image: imageRefs["slow"], ImageID: imageIDs["slow"], Labels: autoLabels},
}))
case strings.Contains(r.URL.Path, "/images/"):
require.NoError(t, json.NewEncoder(w).Encode(dockertypesimage.InspectResponse{ID: imageIDs[name], RepoTags: []string{imageRefs[name]}}))
case strings.Contains(r.URL.Path, "/containers/"):
- require.NoError(t, json.NewEncoder(w).Encode(dockertypescontainer.InspectResponse{ID: name, Image: imageIDs[name], Config: &dockertypescontainer.Config{Image: imageRefs[name]}}))
+ require.NoError(t, json.NewEncoder(w).Encode(dockertypescontainer.InspectResponse{ID: name, Image: imageIDs[name], Config: &dockertypescontainer.Config{Image: imageRefs[name], Labels: autoLabels}}))
default:
http.NotFound(w, r)
}
diff --git a/backend/internal/imageupdate/tag_updates.go b/backend/internal/imageupdate/tag_updates.go
index 7460d57a1..eabc317bc 100644
--- a/backend/internal/imageupdate/tag_updates.go
+++ b/backend/internal/imageupdate/tag_updates.go
@@ -327,12 +327,17 @@ func (s *ImageUpdateService) saveContainerTagResultInternal(ctx context.Context,
// attachContainerUpdatesInternal binds each container's policy result to the
// image result sharing its normalized reference. The image-only snapshot is
// taken before the first container result is attached so it stays untouched.
+// A container candidate promotes the image result to its version update when
+// the image itself has none.
func attachContainerUpdatesInternal(results map[string]*imageupdatetypes.Response, containerUpdates map[string]*imageupdatetypes.Response) {
containerIDsByRef := make(map[string][]string, len(containerUpdates))
for id, update := range containerUpdates {
normalized := refs.NormalizeImageUpdateRef(update.ImageRef)
containerIDsByRef[normalized] = append(containerIDsByRef[normalized], id)
}
+ for _, ids := range containerIDsByRef {
+ slices.Sort(ids)
+ }
for imageRef, result := range results {
for _, id := range containerIDsByRef[refs.NormalizeImageUpdateRef(imageRef)] {
update := containerUpdates[id]
@@ -345,9 +350,15 @@ func attachContainerUpdatesInternal(results map[string]*imageupdatetypes.Respons
result.ContainerUpdates = map[string]*imageupdatetypes.Response{}
}
result.ContainerUpdates[id] = update
- if update.HasUpdate {
- result.HasUpdate = true
+ if !update.HasUpdate {
+ continue
+ }
+ if !result.HasUpdate {
+ result.UpdateType = update.UpdateType
+ result.CurrentVersion = update.CurrentVersion
+ result.LatestVersion = update.LatestVersion
}
+ result.HasUpdate = true
}
}
}
diff --git a/backend/internal/project/service_test.go b/backend/internal/project/service_test.go
index 0b2121179..f904d88dd 100644
--- a/backend/internal/project/service_test.go
+++ b/backend/internal/project/service_test.go
@@ -7483,11 +7483,10 @@ func TestDiscoveredProjectTagUpdatesRemainScoped(t *testing.T) {
require.Equal(t, target, detail.UpdateInfo.UpdateInfoByRef["example:3.1.0"].LatestVersion)
delete(containers[1].Labels, labels.LabelUpdateStrategy)
rows = buildDiscoveredComposeProjectUpdateRowsInternal(t.Context(), containers, nil, imageSvc, "")
- require.Len(t, rows, 1, "removing tag strategy retains automatic stable-version updates")
- require.True(t, rows[0].UpdateInfo.HasUpdate)
+ require.Empty(t, rows, "removing the strategy label falls back to digest checks")
detail.RuntimeServices[0].ContainerLabels = containers[1].Labels
service.enrichProjectUpdateInfoInternal(t.Context(), &detail)
- require.True(t, detail.UpdateInfo.HasUpdate, "default auto is equivalent to explicit tag for a stable full version")
+ require.False(t, detail.UpdateInfo.HasUpdate, "an undeclared strategy no longer inherits a tag record")
for _, policy := range []map[string]string{{labels.LabelUpdateStrategy: "digest"}, {labels.LabelUpdateStrategy: "tag", labels.LabelUpdateConstraint: "3.1.x"}, {labels.LabelUpdateStrategy: "tag", labels.LabelUpdateTagPattern: ".*"}, {labels.LabelUpdateStrategy: "tag", labels.LabelUpdater: "off"}} {
current := map[string]string{"com.docker.compose.project": "first-project", "com.docker.compose.service": "web"}
for key, value := range policy {
@@ -7568,7 +7567,7 @@ func TestProjectServiceManualUpdateDiscoversTags(t *testing.T) {
{name: "new tag", tags: []string{"1.2.0", "1.3.0", "2.0.0"}, wantRef: "docker.io/library/app:1.3.0", wantChanged: true, wantCalls: 1},
{name: "same tag digest fallback", tags: []string{"1.2.0", "2.0.0"}, wantRef: "app:1.2.0", wantCalls: 1},
{name: "planned dependency does not discover tags", tags: []string{"1.2.0", "1.3.0"}, wantRef: "app:1.2.0", skipDiscovery: true},
- {name: "unlabeled automatic tag", tags: []string{"1.2.0", "1.3.0", "2.0.0"}, wantRef: "docker.io/library/app:1.3.0", wantChanged: true, wantCalls: 1, omitLabels: true},
+ {name: "unlabeled digest default", tags: []string{"1.2.0", "1.3.0", "2.0.0"}, wantRef: "app:1.2.0", omitLabels: true},
{name: "explicit automatic tag", tags: []string{"1.2.0", "1.3.0", "2.0.0"}, wantRef: "docker.io/library/app:1.3.0", wantChanged: true, wantCalls: 1, strategy: "auto"},
{name: "explicit digest optout", tags: []string{"1.2.0", "1.3.0"}, wantRef: "app:1.2.0", strategy: "digest"},
} {
@@ -7729,18 +7728,18 @@ func TestConfiguredProjectUsesScheduledRuntimeChecks(t *testing.T) {
require.NoError(t, err)
require.NoError(t, settingsService.SetStringSetting(ctx, "projectsDirectory", directory))
path := createComposeProjectDir(t, directory, "scheduled-project")
- sourceLabels := composetypes.Labels{}
- source := "services:\n web:\n image: " + tt.sourceRef + "\n"
+ sourceLabels := composetypes.Labels{labels.LabelUpdateStrategy: "auto"}
+ source := "services:\n web:\n image: " + tt.sourceRef + "\n labels:\n com.getarcaneapp.arcane.updater.strategy: auto\n"
if tt.sourceConstraint != "" {
sourceLabels[labels.LabelUpdateConstraint] = tt.sourceConstraint
- source += " labels:\n com.getarcaneapp.arcane.updater.constraint: " + tt.sourceConstraint + "\n"
+ source += " com.getarcaneapp.arcane.updater.constraint: " + tt.sourceConstraint + "\n"
}
require.NoError(t, os.WriteFile(filepath.Join(path, "compose.yaml"), []byte(source), 0o600))
proj := Project{ID: "scheduled-project", Name: "scheduled-project", Path: path}
require.NoError(t, db.Create(&proj).Error)
target := "3.2.0"
- require.NoError(t, db.Create(&imageupdate.ImageUpdateRecord{ID: "container::scheduled", ContainerID: "scheduled", ImageID: "shared", PolicyKey: imageref.UpdatePolicyKey("example:3.1.0", nil), Repository: "docker.io/library/example", Tag: "3.1.0", LatestVersion: &target, HasUpdate: true, UpdateType: "tag", CheckTime: time.Now()}).Error)
- runtimeLabels := map[string]string{"com.docker.compose.project": "scheduled-project", "com.docker.compose.service": "web"}
+ require.NoError(t, db.Create(&imageupdate.ImageUpdateRecord{ID: "container::scheduled", ContainerID: "scheduled", ImageID: "shared", PolicyKey: imageref.UpdatePolicyKey("example:3.1.0", map[string]string{labels.LabelUpdateStrategy: "auto"}), Repository: "docker.io/library/example", Tag: "3.1.0", LatestVersion: &target, HasUpdate: true, UpdateType: "tag", CheckTime: time.Now()}).Error)
+ runtimeLabels := map[string]string{"com.docker.compose.project": "scheduled-project", "com.docker.compose.service": "web", labels.LabelUpdateStrategy: "auto"}
if tt.runtimeConstraint != "" {
runtimeLabels[labels.LabelUpdateConstraint] = tt.runtimeConstraint
}
diff --git a/backend/internal/updater/service_test.go b/backend/internal/updater/service_test.go
index 19ccfb47e..7d434b529 100644
--- a/backend/internal/updater/service_test.go
+++ b/backend/internal/updater/service_test.go
@@ -899,10 +899,12 @@ func TestUpdaterService_ApplyPending_ProjectFailureDoesNotBlockOtherProjectsInte
failedLabels := map[string]string{
"com.docker.compose.project": "proj-fail",
"com.docker.compose.service": "app",
+ labels.LabelUpdateStrategy: "auto",
}
updatedLabels := map[string]string{
"com.docker.compose.project": "proj-success",
"com.docker.compose.service": "app",
+ labels.LabelUpdateStrategy: "auto",
}
containers := []container.Summary{
@@ -1062,6 +1064,7 @@ func TestUpdaterService_ApplyPending_RoutesLegacyArcaneServerThroughSelfUpgradeI
"com.docker.compose.project": "arcane",
"com.docker.compose.service": "server",
labels.LabelArcaneLegacyServer: "true",
+ labels.LabelUpdateStrategy: "auto",
}
containers := []container.Summary{
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 0239eff50..569417926 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -3621,7 +3621,7 @@
"editor_compose_updater_enabled_detail": "Enable image updates",
"editor_compose_updater_enabled_info": "Boolean. Set to false to disable image updates for the affected services.",
"editor_compose_updater_strategy_detail": "Update strategy",
- "editor_compose_updater_strategy_info": "Defaults to auto: complete stable semantic version tags follow newer eligible tags; moving tags such as latest and alpine follow digest changes. Set digest to keep the current tag, or tag to require version-based selection.",
+ "editor_compose_updater_strategy_info": "Defaults to digest: the configured tag is kept and only its image digest is followed. Set auto to let complete stable semantic version tags follow newer eligible tags, or tag to require version-based selection. A constraint or tag-pattern without a strategy also enables version-based selection.",
"editor_compose_updater_constraint_detail": "Version constraint",
"editor_compose_updater_constraint_info": "Semantic version constraint for tag updates, such as 3.x or >=3.1.0 <4.0.0. Without a constraint, updates stay within the current major, or the current minor for 0.x.",
"editor_compose_updater_tag_pattern_detail": "Tag pattern",
diff --git a/frontend/src/lib/components/code-editor/analysis/compose-schema.ts b/frontend/src/lib/components/code-editor/analysis/compose-schema.ts
index 470e04ab1..81eadce55 100644
--- a/frontend/src/lib/components/code-editor/analysis/compose-schema.ts
+++ b/frontend/src/lib/components/code-editor/analysis/compose-schema.ts
@@ -429,7 +429,7 @@ function getArcaneSchemaDocForPath(path: Array<string | number>): SchemaDoc | nu
return {
title: `${title}.${field.label}`,
description: field.info,
- ...(field.label === 'strategy' ? { defaultValue: 'auto' } : {})
+ ...(field.label === 'strategy' ? { defaultValue: 'digest' } : {})
};
}
return null;
diff --git a/go.work.sum b/go.work.sum
index 14c7165b9..864282fc7 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -2682,8 +2682,8 @@ go.getarcane.app/updater v0.8.0 h1:8R79Pxj9jiH9NBRwvGJAeiG1DFcdwATKM8MN/V6Sz2Q=
go.getarcane.app/updater v0.8.0/go.mod h1:Hci6Hziz1tublccxm48pKvhxmmg0n3GC6tPMu4bYl3c=
go.getarcane.app/updater v0.9.1 h1:kQsBIKRAEsCv1xgt7BMClStuNDj8JB2TrjY4djhgTa4=
go.getarcane.app/updater v0.9.1/go.mod h1:rMRAzw2KX5S8Ptjs4HAoN7inIHqxdSFsCHcrQWWK+vw=
-go.getarcane.app/updater v0.10.0 h1:6Nh5mo9QupiZAYQpJIZSUGftDmbjNBZqJfLzcB2pAvc=
-go.getarcane.app/updater v0.10.0/go.mod h1:F7KT3jTCLKc5PS7dNPTSigqe9RglgVevkJVWSAmafHE=
+go.getarcane.app/updater v0.10.1 h1:NgWueoPciGg8fFdy0AAFxkEzQgULCiZW0UtteFM2x30=
+go.getarcane.app/updater v0.10.1/go.mod h1:F7KT3jTCLKc5PS7dNPTSigqe9RglgVevkJVWSAmafHE=
go.lsp.dev/jsonrpc2 v0.10.0 h1:Pr/YcXJoEOTMc/b6OTmcR1DPJ3mSWl/SWiU1Cct6VmI=
go.lsp.dev/jsonrpc2 v0.10.0/go.mod h1:fmEzIdXPi/rf6d4uFcayi8HpFP1nBF99ERP1htC72Ac=
go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 h1:hCzQgh6UcwbKgNSRurYWSqh8MufqRRPODRBblutn4TE=