diff --git a/internal/services/runservice/action/action.go b/internal/services/runservice/action/action.go index 024a574..34c0609 100644 --- a/internal/services/runservice/action/action.go +++ b/internal/services/runservice/action/action.go @@ -135,6 +135,7 @@ type RunCreateRequest struct { Group string SetupErrors []string StaticEnvironment map[string]string + CacheGroup string // existing run fields RunID string @@ -210,6 +211,7 @@ func (h *ActionHandler) newRun(ctx context.Context, req *RunCreateRequest) (*typ StaticEnvironment: req.StaticEnvironment, Environment: req.Environment, Annotations: req.Annotations, + CacheGroup: req.CacheGroup, } run := genRun(rc) diff --git a/internal/services/runservice/api/api.go b/internal/services/runservice/api/api.go index 79bbf44..33f8219 100644 --- a/internal/services/runservice/api/api.go +++ b/internal/services/runservice/api/api.go @@ -515,6 +515,7 @@ type RunCreateRequest struct { Group string `json:"group"` SetupErrors []string `json:"setup_errors"` StaticEnvironment map[string]string `json:"static_environment"` + CacheGroup string `json:"cache_group"` // existing run fields RunID string `json:"run_id"` @@ -556,6 +557,7 @@ func (h *RunCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { Group: req.Group, SetupErrors: req.SetupErrors, StaticEnvironment: req.StaticEnvironment, + CacheGroup: req.CacheGroup, RunID: req.RunID, FromStart: req.FromStart, diff --git a/internal/services/runservice/scheduler.go b/internal/services/runservice/scheduler.go index a149ac1..23e9106 100644 --- a/internal/services/runservice/scheduler.go +++ b/internal/services/runservice/scheduler.go @@ -335,6 +335,11 @@ func (s *Runservice) genExecutorTask(ctx context.Context, r *types.Run, rt *type // run config Environment variables ovverride every other environment variable mergeEnv(environment, rc.Environment) + cachePrefix := store.OSTRootGroup(r.Group) + if rc.CacheGroup != "" { + cachePrefix = rc.CacheGroup + } + et := &types.ExecutorTask{ // The executorTask ID must be the same as the runTask ID so we can detect if // there's already an executorTask scheduled for that run task and we can get @@ -349,7 +354,7 @@ func (s *Runservice) genExecutorTask(ctx context.Context, r *types.Run, rt *type Shell: rct.Shell, User: rct.User, Steps: rct.Steps, - CachePrefix: store.OSTRootGroup(r.Group), + CachePrefix: cachePrefix, Status: types.ExecutorTaskStatus{ Phase: types.ExecutorTaskPhaseNotStarted, Steps: make([]*types.ExecutorTaskStepStatus, len(rct.Steps)), diff --git a/internal/services/runservice/types/types.go b/internal/services/runservice/types/types.go index d670824..3acda1f 100644 --- a/internal/services/runservice/types/types.go +++ b/internal/services/runservice/types/types.go @@ -306,6 +306,9 @@ type RunConfig struct { Environment map[string]string `json:"environment,omitempty"` Tasks map[string]*RunConfigTask `json:"tasks,omitempty"` + + // CacheGroup is the cache group where the run caches belongs + CacheGroup string `json:"cache_group,omitempty"` } func (rc *RunConfig) DeepCopy() *RunConfig {