Skip to content
Draft
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
34 changes: 34 additions & 0 deletions stovepipe/core/queueconfig/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"build_analysis.go",
"build_signal.go",
"config.go",
"duration.go",
"issue_track.go",
"process.go",
],
importpath = "github.com/uber/submitqueue/stovepipe/core/queueconfig",
visibility = ["//visibility:public"],
deps = ["//stovepipe/entity:go_default_library"],
)

go_test(
name = "go_default_test",
srcs = [
"build_analysis_test.go",
"build_signal_test.go",
"config_test.go",
"duration_test.go",
"issue_track_test.go",
"process_test.go",
],
embed = [":go_default_library"],
deps = [
"//stovepipe/entity:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
],
)
42 changes: 42 additions & 0 deletions stovepipe/core/queueconfig/build_analysis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package queueconfig

import (
"fmt"
"time"

"github.com/uber/submitqueue/stovepipe/entity"
)

// BuildAnalysisOverrides contains optional configuration for the build-analysis stage.
// Nil fields inherit their previous value; explicit values are retained for validation.
type BuildAnalysisOverrides struct {
// PollDelay overrides the interval between successful analysis passes using whole milliseconds.
PollDelay *time.Duration `yaml:"pollDelay"`
}

// Apply copies base and replaces explicitly supplied settings.
// Durations that cannot be represented as whole milliseconds return an error.
func (o BuildAnalysisOverrides) Apply(base entity.BuildAnalysisConfig) (entity.BuildAnalysisConfig, error) {
pollDelayMs, err := durationMilliseconds(o.PollDelay, base.PollDelayMs)
if err != nil {
return entity.BuildAnalysisConfig{}, fmt.Errorf("pollDelay: %w", err)
}

base.PollDelayMs = pollDelayMs

return base, nil
}
55 changes: 55 additions & 0 deletions stovepipe/core/queueconfig/build_analysis_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package queueconfig

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber/submitqueue/stovepipe/entity"
)

func TestBuildAnalysisOverridesApply(t *testing.T) {
base := entity.BuildAnalysisConfig{
PollDelayMs: 10,
}

inherited, err := (BuildAnalysisOverrides{}).Apply(base)
require.NoError(t, err)
assert.Equal(t, base, inherited)

t.Run("PollDelay", func(t *testing.T) {
value := 25 * time.Millisecond
original := base
override := BuildAnalysisOverrides{PollDelay: &value}

got, err := override.Apply(base)
require.NoError(t, err)
want := base
want.PollDelayMs = value.Milliseconds()

assert.Equal(t, want, got)
assert.Equal(t, original, base)

value = 0
assert.Equal(t, int64(25), got.PollDelayMs)

zero, err := override.Apply(base)
require.NoError(t, err)
assert.Zero(t, zero.PollDelayMs)
})
}
52 changes: 52 additions & 0 deletions stovepipe/core/queueconfig/build_signal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package queueconfig

import (
"fmt"
"time"

"github.com/uber/submitqueue/stovepipe/entity"
)

// BuildSignalOverrides contains optional configuration for the build-signal stage.
// Nil fields inherit their previous value; explicit values are retained for validation.
type BuildSignalOverrides struct {
// AcceptedPollDelay overrides the polling interval for accepted builds using whole milliseconds.
AcceptedPollDelay *time.Duration `yaml:"acceptedPollDelay"`

// RunningPollDelay overrides the polling interval for running builds using whole milliseconds.
RunningPollDelay *time.Duration `yaml:"runningPollDelay"`
}

// Apply copies base and replaces explicitly supplied settings.
// Durations that cannot be represented as whole milliseconds return an error.
func (o BuildSignalOverrides) Apply(base entity.BuildSignalConfig) (entity.BuildSignalConfig, error) {
acceptedPollDelayMs, err := durationMilliseconds(o.AcceptedPollDelay, base.AcceptedPollDelayMs)
if err != nil {
return entity.BuildSignalConfig{}, fmt.Errorf("acceptedPollDelay: %w", err)
}

base.AcceptedPollDelayMs = acceptedPollDelayMs

runningPollDelayMs, err := durationMilliseconds(o.RunningPollDelay, base.RunningPollDelayMs)
if err != nil {
return entity.BuildSignalConfig{}, fmt.Errorf("runningPollDelay: %w", err)
}

base.RunningPollDelayMs = runningPollDelayMs

return base, nil
}
77 changes: 77 additions & 0 deletions stovepipe/core/queueconfig/build_signal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package queueconfig

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber/submitqueue/stovepipe/entity"
)

func TestBuildSignalOverridesApply(t *testing.T) {
base := entity.BuildSignalConfig{
AcceptedPollDelayMs: 10,
RunningPollDelayMs: 11,
}

inherited, err := (BuildSignalOverrides{}).Apply(base)
require.NoError(t, err)
assert.Equal(t, base, inherited)

t.Run("AcceptedPollDelay", func(t *testing.T) {
value := 25 * time.Millisecond
original := base
override := BuildSignalOverrides{AcceptedPollDelay: &value}

got, err := override.Apply(base)
require.NoError(t, err)
want := base
want.AcceptedPollDelayMs = value.Milliseconds()

assert.Equal(t, want, got)
assert.Equal(t, original, base)

value = 0
assert.Equal(t, int64(25), got.AcceptedPollDelayMs)

zero, err := override.Apply(base)
require.NoError(t, err)
assert.Zero(t, zero.AcceptedPollDelayMs)
})

t.Run("RunningPollDelay", func(t *testing.T) {
value := 25 * time.Millisecond
original := base
override := BuildSignalOverrides{RunningPollDelay: &value}

got, err := override.Apply(base)
require.NoError(t, err)
want := base
want.RunningPollDelayMs = value.Milliseconds()

assert.Equal(t, want, got)
assert.Equal(t, original, base)

value = 0
assert.Equal(t, int64(25), got.RunningPollDelayMs)

zero, err := override.Apply(base)
require.NoError(t, err)
assert.Zero(t, zero.RunningPollDelayMs)
})
}
68 changes: 68 additions & 0 deletions stovepipe/core/queueconfig/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package queueconfig

import (
"fmt"

"github.com/uber/submitqueue/stovepipe/entity"
)

// Overrides contains optional configuration grouped by stage.
// Apply does not validate partial layers; validate the resolved result instead.
type Overrides struct {
// Process contains optional configuration for the process stage.
Process ProcessOverrides `yaml:"process"`

// BuildSignal contains optional configuration for the build-signal stage.
BuildSignal BuildSignalOverrides `yaml:"buildSignal"`

// BuildAnalysis contains optional configuration for the build-analysis stage.
BuildAnalysis BuildAnalysisOverrides `yaml:"buildAnalysis"`

// IssueTrack contains optional configuration for the issue-tracking stage.
IssueTrack IssueTrackOverrides `yaml:"issueTrack"`
}

// Apply copies base and applies each stage's overrides.
// Durations that cannot be represented as whole milliseconds return an error.
func (o Overrides) Apply(base entity.StageConfig) (entity.StageConfig, error) {
process, err := o.Process.Apply(base.Process)
if err != nil {
return entity.StageConfig{}, fmt.Errorf("process: %w", err)
}

buildSignal, err := o.BuildSignal.Apply(base.BuildSignal)
if err != nil {
return entity.StageConfig{}, fmt.Errorf("buildSignal: %w", err)
}

buildAnalysis, err := o.BuildAnalysis.Apply(base.BuildAnalysis)
if err != nil {
return entity.StageConfig{}, fmt.Errorf("buildAnalysis: %w", err)
}

issueTrack, err := o.IssueTrack.Apply(base.IssueTrack)
if err != nil {
return entity.StageConfig{}, fmt.Errorf("issueTrack: %w", err)
}

return entity.StageConfig{
Process: process,
BuildSignal: buildSignal,
BuildAnalysis: buildAnalysis,
IssueTrack: issueTrack,
}, nil
}
Loading