Skip to content

Commit 5102969

Browse files
craig[bot]healthy-pod
andcommitted
107645: teamcity-trigger: limit the number of triggers per unit time r=rickystewart a=healthy-pod This code change limits the number of triggered stress runs per every 10 minutes to 20 runs. The goal of this is to avoid overloading TeamCity. Part of: DEVINF-834 Release note: None Epic: none Co-authored-by: healthy-pod <[email protected]>
2 parents 310951b + cc4fabe commit 5102969

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pkg/cmd/teamcity-trigger/main.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ func main() {
108108
}
109109

110110
func runTC(queueBuild func(string, map[string]string)) {
111+
// queueBuildThenWait sets a limit on the rate at which we trigger TC stress
112+
// build config to avoid overloading TC [see DEVINF-834].
113+
currentTriggerCount := 0
114+
queueBuildThenWait := func(buildID string, opts map[string]string) {
115+
if currentTriggerCount == 20 {
116+
currentTriggerCount = 0
117+
time.Sleep(time.Minute * 10)
118+
}
119+
currentTriggerCount += 1
120+
queueBuild(buildID, opts)
121+
}
111122
targets, err := exec.Command("bazel", "query", "kind(go_test, //pkg/...)", "--output=label").Output()
112123
if err != nil {
113124
log.Fatal(err)
@@ -163,11 +174,11 @@ func runTC(queueBuild func(string, map[string]string)) {
163174

164175
opts["env.STRESSFLAGS"] = fmt.Sprintf("-maxruns %d -maxtime %s -maxfails %d -p %d",
165176
maxRuns, maxTime, maxFails, parallelism)
166-
queueBuild(buildID, opts)
177+
queueBuildThenWait(buildID, opts)
167178

168179
// Run non-race build with deadlock detection.
169180
opts["env.TAGS"] = "deadlock"
170-
queueBuild(buildID, opts)
181+
queueBuildThenWait(buildID, opts)
171182
delete(opts, "env.TAGS")
172183

173184
// Run race build. With run with -p 1 to avoid overloading the machine.
@@ -179,7 +190,7 @@ func runTC(queueBuild func(string, map[string]string)) {
179190
opts["env.STRESSFLAGS"] = fmt.Sprintf("-maxruns %d -maxtime %s -maxfails %d -p %d",
180191
maxRuns, maxTime, maxFails, noParallelism)
181192
opts["env.TAGS"] = "race"
182-
queueBuild(buildID, opts)
193+
queueBuildThenWait(buildID, opts)
183194
delete(opts, "env.TAGS")
184195
}
185196
}

0 commit comments

Comments
 (0)