Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/configuration_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ redis:
# environment variable)
url: redis://foo:bar@redis.example.net:6379

# TTL for the project locks
project_ttl: 168h

# TTL for the ref locks
ref_ttl: 1h

# TTL for the metric locks
metric_ttl: 1h

# TTL for the task locks
task_ttl: 30m

# URL and Token with sufficient permissions to access
# your GitLab's projects pipelines informations (optional)
gitlab:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ type Redis struct {
ProjectTTL time.Duration `default:"168h" yaml:"project_ttl"`
RefTTL time.Duration `default:"1h" yaml:"ref_ttl"`
MetricTTL time.Duration `default:"1h" yaml:"metric_ttl"`
TaskTTL time.Duration `default:"0" yaml:"task_ttl"`
}

// Pull ..
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func New(ctx context.Context, cfg config.Config, version string) (c Controller,
Project: cfg.Redis.ProjectTTL,
Ref: cfg.Redis.RefTTL,
Metric: cfg.Redis.MetricTTL,
Task: cfg.Redis.TaskTTL,
}))
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/store/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type RedisTTLConfig struct {
Project time.Duration
Ref time.Duration
Metric time.Duration
Task time.Duration
}

func WithTTLConfig(opt *RedisTTLConfig) func(*RedisStoreConfig) {
Expand Down Expand Up @@ -464,7 +465,7 @@ func (r *Redis) QueueTask(ctx context.Context, tt schemas.TaskType, taskUUID, pr
k := getRedisQueueKey(tt, taskUUID)

// We attempt to set the key, if it already exists, we do not overwrite it
set, err = r.SetNX(ctx, k, processUUID, 0).Result()
set, err = r.SetNX(ctx, k, processUUID, r.StoreConfig.TTLConfig.Task).Result()
if err != nil || set {
return
}
Expand All @@ -487,7 +488,7 @@ func (r *Redis) QueueTask(ctx context.Context, tt schemas.TaskType, taskUUID, pr
}

if !uuidIsAlive {
if _, err = r.Set(ctx, k, processUUID, 0).Result(); err != nil {
if _, err = r.Set(ctx, k, processUUID, r.StoreConfig.TTLConfig.Task).Result(); err != nil {
return
}

Expand Down