Skip to content

Commit d83b67c

Browse files
committed
fix(spec): count only the database container's disk as its storage
- a sidecar of the db role without the data mount (CockroachDB's init container) counted its 30 GB boot disk and the validator took that as the node's storage; TPC-C 1000 WH was refused on a 302 GB data disk
1 parent e75121b commit d83b67c

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎pipelines/spec/resources.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ func databaseStorage(r Run) map[string]float64 {
288288
if strings.Contains(c.Name, "exporter") || (c.Role != "db" && !strings.HasPrefix(c.Role, "db-")) {
289289
continue
290290
}
291+
// Only the database holds the data; a sidecar of its role (an init
292+
// container, a helper) has no data mount and would count the boot disk.
293+
if c.Kind != "" && c.Kind != ContainerKindDatabase {
294+
continue
295+
}
291296
m, ok := r.MachineByName()[c.Machine]
292297
if !ok {
293298
continue

‎pipelines/spec/resources_test.go‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,20 @@ func TestCapacityCoexistingFamiliesAndStaticDimensions(t *testing.T) {
111111
t.Fatalf("coexisting estimate %+v", e)
112112
}
113113
}
114+
115+
// A sidecar of the database role without the data mount (CockroachDB's init
116+
// container) does not shrink the storage the database has: TPC-C 1000 WH on
117+
// a 302 GB disk was refused against the init container's 30 GB boot disk.
118+
func TestDatabaseStorageIgnoresSidecars(t *testing.T) {
119+
t.Parallel()
120+
r := capacityRun()
121+
r.Machines[0].Disks[0].GB = 302
122+
r.Containers[0].Kind = ContainerKindDatabase
123+
r.Containers = append(r.Containers, Container{Name: "db-1-init", Role: "db", Kind: ContainerKindAddon, Machine: "db-1", Image: "init:1"})
124+
r.Workload.Segments = []json.RawMessage{json.RawMessage(`{"name":"main","workload":{"script":"tpcc/tx","scale_factor":1000},"run":{"vus":1,"duration":"1m"}}`)}
125+
for _, i := range CheckResources(r) {
126+
if i.Code == "capacity_insufficient" {
127+
t.Fatalf("the sidecar counted as the database's storage: %+v", i)
128+
}
129+
}
130+
}

0 commit comments

Comments
 (0)