Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: environment update context deadline, and out of bounds text in dialog (#3005)
Kyle Mendell63a4d16c090c
diff --git a/backend/internal/services/system_upgrade_service.go b/backend/internal/services/system_upgrade_service.goindex d530d519f..ec6547aeb 100644--- a/backend/internal/services/system_upgrade_service.go+++ b/backend/internal/services/system_upgrade_service.go@@ -19,6 +19,7 @@ import ("github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane""github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/timeouts"vuln "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/vuln"+ "github.com/getarcaneapp/arcane/backend/v2/pkg/remenv""github.com/getarcaneapp/arcane/types/v2/version"containertypes "github.com/moby/moby/api/types/container"mounttypes "github.com/moby/moby/api/types/mount"@@ -680,7 +681,7 @@ func (s *SystemUpgradeService) upgradeAgentInternal(ctx context.Context, env *Enerr := env.ProxyJSONRequest(versionCtx, envID, http.MethodGet, "/api/app-version", nil, &info)cancel()if err != nil {- result.Status = models.EnvironmentUpdateResultStatusSkippedOffline+ result.Status = updateAllAgentFailureStatusInternal(err)result.Error = truncateUpdateAllErrorInternal(err)return}@@ -714,6 +715,26 @@ func (s *SystemUpgradeService) upgradeAgentInternal(ctx context.Context, env *En}}+// updateAllAgentFailureStatusInternal classifies a failed agent pre-check. An+// environment we actually reached but whose request failed or timed out is a real+// failure, not an offline skip: poll-mode agents connect on demand, so a slow+// tunnel round-trip surfaces here as a deadline even though the agent is online.+// Only errors that look like the environment was never reachable (no tunnel,+// connection refused, DNS failure, …) stay an offline skip.+func updateAllAgentFailureStatusInternal(err error) models.EnvironmentUpdateResultStatus {+ // The tunnel/connection was established but the request did not finish: it+ // either timed out or was canceled (e.g. the parent context was aborted).+ if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) {+ return models.EnvironmentUpdateResultStatusFailed+ }+ // The environment answered with a non-success status — reached, not offline.+ var statusErr *remenv.StatusError+ if errors.As(err, &statusErr) {+ return models.EnvironmentUpdateResultStatusFailed+ }+ return models.EnvironmentUpdateResultStatusSkippedOffline+}+// confirmAgentUpgradedInternal polls the agent's version until it changes from the// pre-upgrade baseline or the wait window elapses.func (s *SystemUpgradeService) confirmAgentUpgradedInternal(ctx context.Context, env *EnvironmentService, envID, baselineVersion, baselineDigest string) bool {diff --git a/backend/internal/services/system_upgrade_service_test.go b/backend/internal/services/system_upgrade_service_test.goindex acd8e10e1..1c46eb278 100644--- a/backend/internal/services/system_upgrade_service_test.go+++ b/backend/internal/services/system_upgrade_service_test.go@@ -3,9 +3,12 @@ package servicesimport ("context""errors"+ "fmt""testing""github.com/getarcaneapp/arcane/backend/v2/internal/common"+ "github.com/getarcaneapp/arcane/backend/v2/internal/models"+ "github.com/getarcaneapp/arcane/backend/v2/pkg/remenv"containertypes "github.com/moby/moby/api/types/container"mounttypes "github.com/moby/moby/api/types/mount"networktypes "github.com/moby/moby/api/types/network"@@ -271,3 +274,30 @@ func TestResolveSystemUpgraderRuntimeOptionsInternal_UnixDockerHostResolutionErrrequire.Error(t, err)require.Contains(t, err.Error(), "resolve unix socket source")}++// TestUpdateAllAgentFailureStatus verifies that a reachable-but-failed agent (e.g.+// a poll-mode environment whose tunnel round-trip timed out) is reported as a real+// failure rather than mislabeled "offline — skipped".+func TestUpdateAllAgentFailureStatus(t *testing.T) {+ // Mirrors the real wrapping: executeRemoteRequest -> TransportError ->+ // "tunnel request failed" -> context.DeadlineExceeded.+ tunnelTimeout := fmt.Errorf("failed to send request to environment oracle-cloud: %w",+ &remenv.TransportError{Err: fmt.Errorf("tunnel request failed: %w", context.DeadlineExceeded)})++ tests := []struct {+ name string+ err error+ want models.EnvironmentUpdateResultStatus+ }{+ {"tunnel request timed out", tunnelTimeout, models.EnvironmentUpdateResultStatusFailed},+ {"request canceled mid-flight", fmt.Errorf("tunnel request failed: %w", context.Canceled), models.EnvironmentUpdateResultStatusFailed},+ {"non-success status from agent", &remenv.StatusError{StatusCode: 502}, models.EnvironmentUpdateResultStatusFailed},+ {"agent never connected", &remenv.TransportError{Err: errors.New("edge agent is not connected")}, models.EnvironmentUpdateResultStatusSkippedOffline},+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ require.Equal(t, tt.want, updateAllAgentFailureStatusInternal(tt.err))+ })+ }+}diff --git a/frontend/src/routes/(app)/environments/update-all-dialog.svelte b/frontend/src/routes/(app)/environments/update-all-dialog.svelteindex 88800c59d..97b61ff5e 100644--- a/frontend/src/routes/(app)/environments/update-all-dialog.svelte+++ b/frontend/src/routes/(app)/environments/update-all-dialog.svelte@@ -225,14 +225,14 @@{/if}</span>- <div class="flex min-w-0 flex-1 flex-col">- <span class="truncate font-medium">{result.environmentName}</span>+ <div class="min-w-0 flex-1">+ <span class="block truncate font-medium">{result.environmentName}</span>{#if result.status === 'updating'}<div class="bg-muted mt-1.5 h-1 overflow-hidden rounded-full"><div class="update-all-capbar bg-primary h-full rounded-full"></div></div>{:else if result.error}- <span class="text-muted-foreground truncate text-xs">{result.error}</span>+ <span class="text-muted-foreground block truncate text-xs" title={result.error}>{result.error}</span>{/if}</div>