Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: incorrect paths for activity syncing
Kyle Mendell9d0607443271
diff --git a/backend/internal/middleware/environment_middleware.go b/backend/internal/middleware/environment_middleware.goindex e0a1b6eec..668eedcfc 100644--- a/backend/internal/middleware/environment_middleware.go+++ b/backend/internal/middleware/environment_middleware.go@@ -200,6 +200,10 @@ func (m *EnvironmentMiddleware) hasResourcePath(c echo.Context, envID string) bo}func isManagementPathInternal(suffix string) bool {+ if suffix == "/activities" || strings.HasPrefix(suffix, "/activities/") {+ return true+ }+if strings.HasPrefix(suffix, "/notifications") {return true}diff --git a/backend/internal/middleware/environment_middleware_test.go b/backend/internal/middleware/environment_middleware_test.goindex 3d3f91ed2..3dddc1ca8 100644--- a/backend/internal/middleware/environment_middleware_test.go+++ b/backend/internal/middleware/environment_middleware_test.go@@ -144,6 +144,51 @@ func TestEnvironmentMiddleware_KeepsNotificationEndpointsLocal(t *testing.T) {assert.True(t, localHandlerHit)}+func TestEnvironmentMiddleware_KeepsActivityEndpointsLocal(t *testing.T) {+ tests := []struct {+ name string+ method string+ route string+ path string+ }{+ {+ name: "list activities",+ method: http.MethodGet,+ route: "/environments/:id/activities",+ path: "/api/environments/env-edge/activities?limit=50",+ },+ {+ name: "stream activities",+ method: http.MethodGet,+ route: "/environments/:id/activities/stream",+ path: "/api/environments/env-edge/activities/stream?limit=50",+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ middleware := newTestEnvironmentMiddleware()+ router := echo.New()+ api := attachMiddleware(router, middleware)++ localHandlerHit := false+ api.Add(tt.method, tt.route, func(c echo.Context) error {+ localHandlerHit = true+ return c.JSON(http.StatusOK, map[string]any{"success": true})+ })++ req := httptest.NewRequest(tt.method, tt.path, nil)+ recorder := httptest.NewRecorder()++ router.ServeHTTP(recorder, req)++ assert.Equal(t, http.StatusOK, recorder.Code)+ assert.Contains(t, recorder.Body.String(), "\"success\":true")+ assert.True(t, localHandlerHit)+ })+ }+}+func TestEnvironmentMiddleware_ProxyWebSocketRejectsEdgeTargetsWithoutTunnel(t *testing.T) {middleware := newTestEnvironmentMiddleware()e := echo.New()diff --git a/backend/pkg/libarcane/edge/commands.go b/backend/pkg/libarcane/edge/commands.goindex 54a83df86..f7ac6ce68 100644--- a/backend/pkg/libarcane/edge/commands.go+++ b/backend/pkg/libarcane/edge/commands.go@@ -10,6 +10,7 @@ type commandRoute struct {PathPattern stringCommandName stringStream bool+ LocalOnly bool}var commandRoutes = []commandRoute{@@ -48,6 +49,12 @@ var commandRoutes = []commandRoute{{Method: http.MethodPost, PathPattern: "/api/environments/{id}/image-updates/check-all", CommandName: "image_update.check_all"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/image-updates/summary", CommandName: "image_update.summary"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/activities", CommandName: "activity.list"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/activities/stream", LocalOnly: true},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/activities/{activityId}", CommandName: "activity.inspect"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/activities/{activityId}/cancel", CommandName: "activity.cancel"},+ {Method: http.MethodDelete, PathPattern: "/api/environments/{id}/activities/history", CommandName: "activity.history.clear"},+{Method: http.MethodPost, PathPattern: "/api/environments/{id}/images/{imageId}/vulnerabilities/scan", CommandName: "vulnerability.scan"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/images/{imageId}/vulnerabilities", CommandName: "vulnerability.list"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/images/{imageId}/vulnerabilities/summary", CommandName: "vulnerability.summary"},@@ -195,6 +202,10 @@ func ResolveEdgeCommandName(method, requestPath string, stream bool) (string, boreturn "", false}+ if route.LocalOnly {+ return "", false+ }+return route.CommandName, true}@@ -207,6 +218,9 @@ func AdvertisedEdgeCommands() []string {seen := make(map[string]struct{}, len(commandRoutes))commands := make([]string, 0, len(commandRoutes))for _, route := range commandRoutes {+ if route.LocalOnly {+ continue+ }if _, ok := seen[route.CommandName]; ok {continue}diff --git a/backend/pkg/libarcane/edge/commands_test.go b/backend/pkg/libarcane/edge/commands_test.goindex 4e26467cc..130b36a63 100644--- a/backend/pkg/libarcane/edge/commands_test.go+++ b/backend/pkg/libarcane/edge/commands_test.go@@ -25,6 +25,11 @@ func TestResolveEdgeCommandName(t *testing.T) {{name: "project logs stream", method: "GET", path: "/api/environments/0/ws/projects/p1/logs", stream: true, command: "project.logs.stream", shouldHit: true},{name: "project updates", method: "GET", path: "/api/environments/0/projects/p1/updates", command: "project.updates", shouldHit: true},{name: "project archive", method: "POST", path: "/api/environments/0/projects/p1/archive", command: "project.archive", shouldHit: true},+ {name: "activity list", method: "GET", path: "/api/environments/0/activities?limit=50", command: "activity.list", shouldHit: true},+ {name: "activity inspect", method: "GET", path: "/api/environments/0/activities/activity-1", command: "activity.inspect", shouldHit: true},+ {name: "activity cancel", method: "POST", path: "/api/environments/0/activities/activity-1/cancel", command: "activity.cancel", shouldHit: true},+ {name: "activity history clear", method: "DELETE", path: "/api/environments/0/activities/history", command: "activity.history.clear", shouldHit: true},+ {name: "activity stream remains manager local", method: "GET", path: "/api/environments/0/activities/stream?limit=50", shouldHit: false},{name: "health", method: "HEAD", path: "/api/environments/0/system/health", command: "system.health", shouldHit: true},{name: "unknown", method: "PATCH", path: "/api/environments/0/containers", shouldHit: false},}