Skip to content

Commit f296296

Browse files
Deprecate debug flag in favor of more direct upstream-monitor flag.
Summary: - Changes this flag's behavior to only affect whether we monitor upstream for aborts, not whether we push data (like metrics and snapshot status) to Changes. - Increase the upstream monitoring time from 3 to 10 seconds. Test Plan: unit tests + staging Reviewers: kylec, anupc Reviewed By: anupc Subscribers: changesbot Differential Revision: https://tails.corp.dropbox.com/D147437
1 parent 0d39448 commit f296296

File tree

5 files changed

+12
-26
lines changed

5 files changed

+12
-26
lines changed

client/config.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var (
1515
server string
1616
jobstepID string
1717
artifactSearchPath string
18+
upstreamMonitor bool
1819
debug bool
1920
ignoreSnapshots bool
2021
)
@@ -35,7 +36,7 @@ type Config struct {
3536
Server string
3637
JobstepID string
3738
ArtifactSearchPath string
38-
Debug bool
39+
UpstreamMonitor bool
3940
Snapshot struct {
4041
ID string
4142
}
@@ -148,7 +149,11 @@ func GetConfig() (*Config, error) {
148149
conf.Server = server
149150
conf.JobstepID = jobstepID
150151
conf.ArtifactSearchPath = artifactSearchPath
151-
conf.Debug = debug
152+
conf.UpstreamMonitor = upstreamMonitor
153+
// deprecated flag
154+
if debug {
155+
conf.UpstreamMonitor = false
156+
}
152157

153158
if ignoreSnapshots {
154159
conf.Snapshot.ID = ""
@@ -160,6 +165,7 @@ func init() {
160165
flag.StringVar(&server, "server", "", "URL to get config from")
161166
flag.StringVar(&jobstepID, "jobstep_id", "", "Job ID whose commands are to be executed")
162167
flag.StringVar(&artifactSearchPath, "artifact-search-path", "", "Folder where artifacts will be searched for relative to adapter root")
163-
flag.BoolVar(&debug, "debug", false, "Indicates that the client is running in debug mode and should not report results upstream")
168+
flag.BoolVar(&upstreamMonitor, "upstream-monitor", true, "Indicates whether the client should monitor upstream for aborts")
169+
flag.BoolVar(&debug, "debug", false, "DEPRECATED. debug=true is the same as upstreamMonitor=false.")
164170
flag.BoolVar(&ignoreSnapshots, "no-snapshots", false, "Ignore any existing snapshots, and build a fresh environment")
165171
}

client/reporter/defaultreporter.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@ var (
4747
// them at the endpoint. More importantly, however, because the
4848
// requests are sent in a separate goroutine, the methods here may
4949
// succeed even when the endpoing requests fail.
50-
//
51-
// In debug mode, endpoint requests are still queued in the publish
52-
// channel but never sent by the publishing goroutine, which allows
53-
// the reporter to run without actually connecting
54-
// to the changes server. TODO(nate): why is this useful?
5550
type DefaultReporter struct {
5651
// Note that this is not safe to send to after Shutdown() is called.
5752
PublishChannel chan ReportPayload
58-
Debug bool
5953
jobstepID string
6054
publishUri string
6155
shutdownChannel chan struct{}
@@ -188,14 +182,8 @@ func (r *DefaultReporter) SendPayload(rp ReportPayload) error {
188182
}
189183

190184
// Continually listens to the publish channel and sends the payloads
191-
// if we aren't in debug mode.
192185
func transportSend(r *DefaultReporter) {
193186
for rp := range r.PublishChannel {
194-
// dont send reports when running in debug mode
195-
if r.Debug {
196-
continue
197-
}
198-
199187
r.SendPayload(rp)
200188
}
201189
r.shutdownChannel <- struct{}{}
@@ -211,12 +199,7 @@ func (r *DefaultReporter) Init(c *client.Config) {
211199
r.shutdownChannel = make(chan struct{})
212200
r.jobstepID = c.JobstepID
213201
r.PublishChannel = make(chan ReportPayload, maxPendingReports)
214-
r.Debug = c.Debug
215-
// Initialize the goroutine that actually sends the requests. We spawn
216-
// this even when in debug mode to prevent the payloads from
217-
// massively queueing. Since we by default use a queue with a maximum
218-
// limit, once it reaches that limit writes will block causing the
219-
// main goroutine to halt forever.
202+
// Initialize the goroutine that actually sends the requests.
220203
go transportSend(r)
221204
}
222205

engine/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (e *Engine) runBuildPlan() (Result, error) {
241241

242242
// We need to ensure that we're able to abort the build if upstream suggests
243243
// that it's been cancelled.
244-
if !e.config.Debug {
244+
if e.config.UpstreamMonitor {
245245
go func() {
246246
um := &UpstreamMonitor{
247247
Config: e.config,

engine/upstream_monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (um *UpstreamMonitor) WaitUntilAbort() error {
4747
}
4848
}
4949

50-
time.Sleep(3 * time.Second)
50+
time.Sleep(10 * time.Second)
5151
}
5252
}
5353

reporter/mesos/reporter.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ func (r *Reporter) PushLogChunk(source string, payload []byte) {
4545
form := make(map[string]string)
4646
form["source"] = source
4747
form["text"] = string(payload)
48-
if r.Debug {
49-
log.Print(string(payload))
50-
}
5148
r.PublishChannel <- reporter.ReportPayload{Path: r.JobstepAPIPath() + "logappend/", Data: form, Filename: ""}
5249
}
5350

0 commit comments

Comments
 (0)