Skip to content

Modern Docker Management, Designed for Everyone

fix: ignore update opt-outs for manual updater runs (#4564)

Kyle Mendell819076c59870
diff --git a/backend/go.mod b/backend/go.mod
index fdf1abf8b..415033db4 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -75,7 +75,7 @@ require (
go.getarcane.app/streams v0.4.6
go.getarcane.app/sys/cgroup v0.2.5
go.getarcane.app/sys/crypto v0.3.3
- go.getarcane.app/updater v0.11.12
+ go.getarcane.app/updater v0.11.13
go.opentelemetry.io/contrib/bridges/otelslog v0.21.0
go.opentelemetry.io/contrib/exporters/autoexport v0.72.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0
diff --git a/backend/go.sum b/backend/go.sum
index 64612a0b7..5ab2d29ab 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -771,8 +771,8 @@ go.getarcane.app/sys/cgroup v0.2.5 h1:iI1qURe+kOgTRN75sxkpPePjJwlxAx3c9e9kEwKAVn
go.getarcane.app/sys/cgroup v0.2.5/go.mod h1:hJyCjpx04VcaaSvkRsMvZl5OLUlAQ60K5gEy1ctuU4U=
go.getarcane.app/sys/crypto v0.3.3 h1:rG41svssyuGvZToJbkTAsc5bUiirrYlD9tG1FkBU50s=
go.getarcane.app/sys/crypto v0.3.3/go.mod h1:Bx1xZHSv35mnqbz+j+x3GJIufy2HAuPiKYhiVstiw8o=
-go.getarcane.app/updater v0.11.12 h1:ABKiCWRoJg1Q56xAYgyHcTyAIQGUvkk5CWioJctwe5w=
-go.getarcane.app/updater v0.11.12/go.mod h1:UTQkoU+lsLFa52eEdwRB0DEtWtx3DhprX7oyndh7gAE=
+go.getarcane.app/updater v0.11.13 h1:KhdFfXlxIfQPTy/ECKM3eduyD4K71MOtC9hEfuvqeSg=
+go.getarcane.app/updater v0.11.13/go.mod h1:UTQkoU+lsLFa52eEdwRB0DEtWtx3DhprX7oyndh7gAE=
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/updater/handler.go b/backend/internal/updater/handler.go
index 2af599103..32da440f1 100644
--- a/backend/internal/updater/handler.go
+++ b/backend/internal/updater/handler.go
@@ -25,6 +25,7 @@ type UpdaterHandler struct {
type RunUpdaterInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
+ Automatic bool `query:"automatic" doc:"Honor updater opt-out labels and excluded containers, as automatic runs do"`
Body *updater.Options `doc:"Updater run options"`
}
@@ -50,7 +51,13 @@ type GetUpdaterHistoryInput struct {
// RunUpdater applies pending container updates.
func (h *UpdaterHandler) RunUpdater(ctx context.Context, input *RunUpdaterInput) (*handlerutil.Out[*updater.Result], error) {
- out, err := h.updaterService.ApplyPending(utils.ActivityRuntimeContext(ctx, h.appCtx), kit.FromPtr(input.Body))
+ out, err := h.updaterService.ApplyPending(utils.ActivityRuntimeContext(ctx, h.appCtx), updater.Options{
+ Type: kit.FromPtr(input.Body).Type,
+ ResourceIds: kit.FromPtr(input.Body).ResourceIds,
+ ForceUpdate: kit.FromPtr(input.Body).ForceUpdate,
+ DryRun: kit.FromPtr(input.Body).DryRun,
+ IgnoreSettingsExclusions: !input.Automatic,
+ })
if err != nil {
apiErr := common.ToAPIError(err)
return nil, huma.NewError(apiErr.HTTPStatus(), "Failed to run updater: "+apiErr.Message)
diff --git a/backend/internal/updater/service.go b/backend/internal/updater/service.go
index 236517cb4..af24dbcba 100644
--- a/backend/internal/updater/service.go
+++ b/backend/internal/updater/service.go
@@ -76,8 +76,8 @@ var (
}
updateLabelPolicy = updater.LabelPolicy{
- IsUpdateDisabledFunc: func(l map[string]string) bool {
- return labels.IsUpdateDisabled(l) || podman.QuadletUnit(l) != ""
+ UnmanagedReasonFunc: func(l map[string]string) string {
+ return kit.Ternary(podman.QuadletUnit(l) != "", "managed by a Podman quadlet; updates run through Podman auto-update", "")
},
}
)
@@ -127,6 +127,7 @@ type (
updateAdmissionKey struct{}
updateProgressKey struct{}
scopedPendingKey struct{}
+ ignoreSettingsExclusionsKey struct{}
updateProgress struct {
mu sync.Mutex
@@ -311,7 +312,7 @@ func (s *UpdaterService) ApplyPending(ctx context.Context, options arcaneupdater
// as one batch, capped by a whole-run timeout.
func (s *UpdaterService) applyBatch(ctx context.Context, options arcaneupdater.Options, out *arcaneupdater.Result) error {
batch := &containerUpdateBatch{}
- ctx = context.WithValue(ctx, containerUpdateBatchContextKey{}, batch)
+ ctx = context.WithValue(context.WithValue(ctx, containerUpdateBatchContextKey{}, batch), ignoreSettingsExclusionsKey{}, options.IgnoreSettingsExclusions)
defer func() {
batch.Lock()
entries := batch.entries
@@ -344,7 +345,11 @@ func (s *UpdaterService) applyBatch(ctx context.Context, options arcaneupdater.O
return applyErr
}
} else {
- moduleResult, engineErr := s.engine.ApplyPending(runCtx, updater.Options{Force: options.ForceUpdate, DryRun: options.DryRun})
+ moduleResult, engineErr := s.engine.ApplyPending(runCtx, updater.Options{
+ Force: options.ForceUpdate,
+ DryRun: options.DryRun,
+ IgnoreSettingsExclusions: options.IgnoreSettingsExclusions,
+ })
if moduleResult == nil {
return cmp.Or(engineErr, errors.New("updater returned no batch result"))
}
@@ -552,7 +557,10 @@ func (s *UpdaterService) applyScopedUpdates(ctx context.Context, options arcaneu
}
if len(scoped) > 0 {
- moduleResult, engineErr := s.engine.ApplyPending(context.WithValue(ctx, scopedPendingKey{}, scoped), updater.Options{DryRun: options.DryRun})
+ moduleResult, engineErr := s.engine.ApplyPending(context.WithValue(ctx, scopedPendingKey{}, scoped), updater.Options{
+ DryRun: options.DryRun,
+ IgnoreSettingsExclusions: options.IgnoreSettingsExclusions,
+ })
if moduleResult == nil {
return cmp.Or(engineErr, errors.New("updater returned no batch result"))
}
@@ -596,7 +604,11 @@ func (s *UpdaterService) applyScopedUpdates(ctx context.Context, options arcaneu
}); progressErr != nil {
return progressErr
}
- moduleResult, engineErr := s.engine.UpdateContainer(ctx, containerID, updater.Options{Force: options.ForceUpdate, DryRun: options.DryRun})
+ moduleResult, engineErr := s.engine.UpdateContainer(ctx, containerID, updater.Options{
+ Force: options.ForceUpdate,
+ DryRun: options.DryRun,
+ IgnoreSettingsExclusions: options.IgnoreSettingsExclusions,
+ })
partial := resultFromModule(moduleResult)
checked += partial.Checked
updated += partial.Updated
@@ -1500,6 +1512,7 @@ func (s *UpdaterService) CollectUsedImages(ctx context.Context) (map[string]stru
func (s *UpdaterService) collectUsedImagesFromContainers(ctx context.Context, out map[string]struct{}) error {
excludedContainers := docker.ExcludedContainerNameSet(s.deps.Settings.GetStringSetting(ctx, "autoUpdateExcludedContainers", ""))
+ ignoreOptOuts, _ := ctx.Value(ignoreSettingsExclusionsKey{}).(bool)
listResult, err := s.deps.Docker.Call(ctx, func(ctx context.Context, dockerClient *client.Client) (client.ContainerListResult, error) {
return dockerClient.ContainerList(ctx, client.ContainerListOptions{})
})
@@ -1510,12 +1523,12 @@ func (s *UpdaterService) collectUsedImagesFromContainers(ctx context.Context, ou
// Containers sharing an image add the same tags, so each image is inspected once.
inspectedImages := map[string]struct{}{}
for _, summary := range listResult.Items {
- if labels.IsUpdateDisabled(summary.Labels) {
+ if !ignoreOptOuts && labels.IsUpdateDisabled(summary.Labels) {
slog.DebugContext(ctx, "collectUsedImagesFromContainers: container opted out by labels", "containerId", summary.ID)
continue
}
- if docker.ContainerNameExcluded(summary.Names, excludedContainers) {
+ if !ignoreOptOuts && docker.ContainerNameExcluded(summary.Names, excludedContainers) {
slog.DebugContext(ctx, "collectUsedImagesFromContainers: skipping excluded container", "containerId", summary.ID, "names", summary.Names)
continue
}
@@ -1534,7 +1547,7 @@ func (s *UpdaterService) collectUsedImagesFromContainers(ctx context.Context, ou
slog.DebugContext(ctx, "collectUsedImagesFromContainers: container inspect failed", "containerId", summary.ID, "error", inspectErr)
continue
}
- if labels.IsUpdateDisabled(kit.FromPtr(inspectResult.Container.Config).Labels) {
+ if !ignoreOptOuts && labels.IsUpdateDisabled(kit.FromPtr(inspectResult.Container.Config).Labels) {
slog.DebugContext(ctx, "collectUsedImagesFromContainers: container inspect labels opted out", "containerId", summary.ID)
continue
}
@@ -1587,8 +1600,9 @@ func (s *UpdaterService) collectUsedImagesFromProjects(ctx context.Context, out
return err
}
+ ignoreOptOuts, _ := ctx.Value(ignoreSettingsExclusionsKey{}).(bool)
for _, summary := range composeContainers {
- if _, isActive := activeProjectNames[docker.ComposeProjectLabel(summary.Labels)]; !isActive || labels.IsUpdateDisabled(summary.Labels) {
+ if _, isActive := activeProjectNames[docker.ComposeProjectLabel(summary.Labels)]; !isActive || (!ignoreOptOuts && labels.IsUpdateDisabled(summary.Labels)) {
continue
}
imageRef := strings.TrimSpace(summary.Image)
diff --git a/backend/internal/updater/service_test.go b/backend/internal/updater/service_test.go
index 5724f4d1f..5de2db28d 100644
--- a/backend/internal/updater/service_test.go
+++ b/backend/internal/updater/service_test.go
@@ -1361,21 +1361,21 @@ func TestUpdaterService_ApplyPending_RoutesLegacyArcaneServerThroughSelfUpgrade(
assert.Empty(t, projectUpdater.calls, "legacy Arcane server should not be updated through project services")
}
-func TestUpdateLabelPolicyDisablesQuadletContainers(t *testing.T) {
+func TestUpdateLabelPolicyMarksQuadletContainersUnmanaged(t *testing.T) {
tests := []struct {
- name string
- labels map[string]string
- want bool
+ name string
+ labels map[string]string
+ unmanaged bool
}{
{name: "unlabelled", labels: map[string]string{}},
- {name: "quadlet unit", labels: map[string]string{podman.SystemdUnitLabel: "web.service"}, want: true},
+ {name: "quadlet unit", labels: map[string]string{podman.SystemdUnitLabel: "web.service"}, unmanaged: true},
{name: "empty quadlet unit", labels: map[string]string{podman.SystemdUnitLabel: ""}},
- {name: "updater opt out", labels: map[string]string{labels.LabelUpdater: "false"}, want: true},
+ {name: "updater opt out", labels: map[string]string{labels.LabelUpdater: "false"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- assert.Equal(t, tt.want, updateLabelPolicy.IsUpdateDisabled(tt.labels))
+ assert.Equal(t, tt.unmanaged, updateLabelPolicy.UnmanagedReason(tt.labels) != "")
})
}
}
diff --git a/backend/internal/webhook/service.go b/backend/internal/webhook/service.go
index bb6f4e23c..2dbc6808a 100644
--- a/backend/internal/webhook/service.go
+++ b/backend/internal/webhook/service.go
@@ -686,7 +686,7 @@ func remoteWebhookRequestInternal(wh *Webhook, actionType string) (method, path
if actionType != WebhookActionTypeRun {
return "", "", false, ErrWebhookInvalidAction
}
- return http.MethodPost, apiPrefix + "/updater/run", true, nil
+ return http.MethodPost, apiPrefix + "/updater/run?automatic=true", true, nil
case WebhookTargetTypeGitOps:
if actionType != WebhookActionTypeSync {
return "", "", false, ErrWebhookInvalidAction
diff --git a/backend/internal/webhook/service_test.go b/backend/internal/webhook/service_test.go
index 7c323689c..d6ec63baf 100644
--- a/backend/internal/webhook/service_test.go
+++ b/backend/internal/webhook/service_test.go
@@ -798,7 +798,7 @@ func TestRemoteWebhookRequestInternal(t *testing.T) {
wh: Webhook{TargetType: WebhookTargetTypeUpdater},
actionType: WebhookActionTypeRun,
wantMethod: "POST",
- wantPath: "/api/environments/0/updater/run",
+ wantPath: "/api/environments/0/updater/run?automatic=true",
wantResult: true,
},
{
diff --git a/types/updater/updater.go b/types/updater/updater.go
index 44f7bb2b9..4e017a411 100644
--- a/types/updater/updater.go
+++ b/types/updater/updater.go
@@ -50,6 +50,8 @@ type Options struct {
// DryRun performs a dry run without applying updates
DryRun bool `json:"dryRun,omitempty"`
+
+ IgnoreSettingsExclusions bool `json:"-"`
}
// ResourceResult represents the result of an update operation on a single resource.