Skip to content

Commit dd416d8

Browse files
authored
Merge branch 'main' into preetam/orch-stages
2 parents 11f5357 + 0e2d740 commit dd416d8

21 files changed

Lines changed: 543 additions & 34 deletions

File tree

entity/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ go_library(
88
"build.go",
99
"change_provider.go",
1010
"request.go",
11+
"speculation_tree.go",
1112
],
1213
importpath = "github.com/uber/submitqueue/entity",
1314
visibility = ["//visibility:public"],

entity/speculation_tree.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package entity
2+
3+
// SpeculationPathAction defines the possible actions for a speculation path.
4+
type SpeculationPathAction string
5+
6+
const (
7+
// SpeculationPathActionUnknown is the default zero value for SpeculationPathAction.
8+
SpeculationPathActionUnknown SpeculationPathAction = ""
9+
// TODO: Add comprehensive list of actions
10+
)
11+
12+
// SpeculationInfo represents metadata about a single speculation path, including the path through the dependency graph, its current state, and the predicted build score.
13+
type SpeculationInfo struct {
14+
// Path represents the speculation path; which is an ordered list of batches.
15+
Path []string
16+
// Action is a state that this path is in.
17+
Action SpeculationPathAction
18+
// Score is score for this speculation path.
19+
Score float32
20+
}
21+
22+
// SpeculationTree represents the set of speculation paths constructed for a batch based on its dependency graph.
23+
type SpeculationTree struct {
24+
// BatchID is the batch for which this speculation tree is constructed.
25+
BatchID string
26+
// Speculations is a list of speculation paths for this batch based on a graph of its
27+
// dependents.
28+
//
29+
// For e.g - Consider batches - queueA/batch/1, queueA/batch/2, queueA/batch/3
30+
// such that - queueA/batch/2 and queueA/batch/3 depend on queueA/batch/1
31+
//
32+
// Speculations for queueA/batch/1 - [{Path: []string{"queueA/batch/1"}, State: "scheduled", Score: 0.1}]
33+
// Speculations for queueA/batch/2 - [{Path: []string{"queueA/batch/2"}, State: "scheduled", Score: 0.9}, {Path: []string{"queueA/batch/1", "queueA/batch/2"}, State: "scheduled", Score: 0.3}]
34+
// Speculations for queueA/batch/3 - [{Path: []string{"queueA/batch/3"}, State: "scheduled", Score: 0.9}, {Path: []string{"queueA/batch/1", "queueA/batch/3"}, State: "scheduled", Score: 0.3}]
35+
//
36+
Speculations []SpeculationInfo
37+
}

example/server/docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ services:
1818
ports:
1919
- "3306" # Random ephemeral port to avoid conflicts
2020
healthcheck:
21-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-proot"]
21+
# Use 127.0.0.1 (TCP) instead of localhost (Unix socket). MySQL treats
22+
# "localhost" as a socket connection, which can be ready before the TCP
23+
# listener — causing dependent services that connect over TCP to fail.
24+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-proot"]
2225
interval: 5s
2326
timeout: 5s
2427
retries: 10
@@ -33,7 +36,7 @@ services:
3336
ports:
3437
- "3306" # Random ephemeral port to avoid conflicts
3538
healthcheck:
36-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-proot"]
39+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-proot"]
3740
interval: 5s
3841
timeout: 5s
3942
retries: 10

example/server/gateway/docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ services:
1818
ports:
1919
- "3306" # Random ephemeral port to avoid conflicts
2020
healthcheck:
21-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-proot"]
21+
# Use 127.0.0.1 (TCP) instead of localhost (Unix socket). MySQL treats
22+
# "localhost" as a socket connection, which can be ready before the TCP
23+
# listener — causing dependent services that connect over TCP to fail.
24+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-proot"]
2225
interval: 5s
2326
timeout: 5s
2427
retries: 10
@@ -33,7 +36,7 @@ services:
3336
ports:
3437
- "3306" # Random ephemeral port to avoid conflicts
3538
healthcheck:
36-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-proot"]
39+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-proot"]
3740
interval: 5s
3841
timeout: 5s
3942
retries: 10

example/server/orchestrator/docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ services:
1818
ports:
1919
- "3306" # Random ephemeral port to avoid conflicts
2020
healthcheck:
21-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-proot"]
21+
# Use 127.0.0.1 (TCP) instead of localhost (Unix socket). MySQL treats
22+
# "localhost" as a socket connection, which can be ready before the TCP
23+
# listener — causing dependent services that connect over TCP to fail.
24+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-proot"]
2225
interval: 5s
2326
timeout: 5s
2427
retries: 10
@@ -33,7 +36,7 @@ services:
3336
ports:
3437
- "3306" # Random ephemeral port to avoid conflicts
3538
healthcheck:
36-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-proot"]
39+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-proot"]
3740
interval: 5s
3841
timeout: 5s
3942
retries: 10

extension/storage/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ load("@rules_go//go:def.bzl", "go_library")
33
go_library(
44
name = "storage",
55
srcs = [
6+
"batch_dependent_store.go",
7+
"batch_store.go",
8+
"build_store.go",
69
"change_provider_store.go",
710
"request_store.go",
811
"storage.go",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package storage
2+
3+
import (
4+
"context"
5+
6+
"github.com/uber/submitqueue/entity"
7+
)
8+
9+
// BatchDependentStore is an interface that defines methods for managing batch dependent information in the database.
10+
type BatchDependentStore interface {
11+
// Get retrieves the batch dependent by batch ID.
12+
// Returns ErrNotFound if the batch dependent is not found.
13+
Get(ctx context.Context, batchID string) (entity.BatchDependent, error)
14+
15+
// Create creates a new batch dependent.
16+
// Returns ErrAlreadyExists if the entry already exists.
17+
Create(ctx context.Context, batchDependent entity.BatchDependent) error
18+
19+
// There is no update function since once created, data is only ever read from this
20+
// store.
21+
}

extension/storage/batch_store.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package storage
2+
3+
import (
4+
"context"
5+
6+
"github.com/uber/submitqueue/entity"
7+
)
8+
9+
// BatchStore is an interface that defines methods for managing batches in the database.
10+
type BatchStore interface {
11+
// Get retrieves a batch by ID. Returns ErrNotFound if the batch is not found.
12+
Get(ctx context.Context, id string) (entity.Batch, error)
13+
14+
// Create creates a new batch. The batch must have a unique ID already assigned.
15+
// Returns ErrAlreadyExists if a batch with the same ID already exists.
16+
Create(ctx context.Context, batch entity.Batch) error
17+
18+
// UpdateState updates the state of a batch if the current version matches the expected version. If versions do not match, returns ErrVersionMismatch.
19+
// The implementation should increment the version by 1 atomically with the state update.
20+
UpdateState(ctx context.Context, id string, version int32, newState entity.BatchState) error
21+
}

extension/storage/build_store.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package storage
2+
3+
import (
4+
"context"
5+
6+
"github.com/uber/submitqueue/entity"
7+
)
8+
9+
// BuildStore is an interface that defines methods for managing builds in the database.
10+
type BuildStore interface {
11+
// Get retrieves a build by ID. Returns ErrNotFound if the build is not found.
12+
Get(ctx context.Context, id string) (entity.Build, error)
13+
14+
// Create creates a new build. The build must have a unique ID already assigned.
15+
// Returns ErrAlreadyExists if a build with the same ID already exists.
16+
Create(ctx context.Context, build entity.Build) error
17+
18+
// UpdateStatus updates the status of a build.
19+
UpdateStatus(ctx context.Context, id string, newStatus entity.BuildStatus) error
20+
}

extension/storage/mysql/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ load("@rules_go//go:def.bzl", "go_library")
33
go_library(
44
name = "mysql",
55
srcs = [
6+
"batch_dependent_store.go",
7+
"batch_store.go",
8+
"build_store.go",
69
"change_provider_store.go",
710
"request_store.go",
811
"storage.go",

0 commit comments

Comments
 (0)