Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4817 from hashicorp/backport/maint/better-msgs-on…
Browse files Browse the repository at this point in the history
…-no-runner-acks/randomly-touching-porpoise

This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-waypoint committed Jun 20, 2023
2 parents e2ab746 + 9131b62 commit 1fef3dd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/jobstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (s *stream) Run(ctx context.Context) (*pb.Job_Result, error) {
// too long and show a UI message. For example, if we're queued for a long
// time we notify the user we're queued.
var stateEventTimer *time.Timer
var jobWaitTimer *time.Timer

// The UI that will translate terminal events into UI calls.
ui := s.ui
Expand Down Expand Up @@ -168,6 +169,10 @@ func (s *stream) Run(ctx context.Context) (*pb.Job_Result, error) {
stateEventTimer.Stop()
stateEventTimer = nil
}
if jobWaitTimer != nil {
jobWaitTimer.Stop()
jobWaitTimer = nil
}

// Check if this job has been assigned a runner for the first time
if event.State != nil &&
Expand Down Expand Up @@ -227,6 +232,27 @@ func (s *stream) Run(ctx context.Context) (*pb.Job_Result, error) {
"If you interrupt this command, the job will still run in the background.",
terminal.WithInfoStyle())
})

// We're waiting, let's give more context to the user
jobWaitTimer = time.AfterFunc(noRunnerAckEventPause, func() {
ui.Output("")
ui.Output(
"The system has waited a long time (> 60 seconds) with no runner activity \n"+
"accepting the job. There could be many reasons for this, one of which \n"+
"could be that the selected runner profile is no longer valid or the runner \n"+
"on the platform is stuck or unavailable.",
terminal.WithWarningStyle())
ui.Output("")
ui.Output(
"If this command continues to be stuck, double check that the selected \n"+
"runner profile is still valid, and that the runner exists within your \n"+
"selected platform and is available to receieve and execute jobs.",
terminal.WithWarningStyle())
ui.Output("")
ui.Output(
"Runner profiles can be managed and inspected with \"waypoint runner profile\".",
terminal.WithWarningStyle())
})
}

case pb.Job_WAITING:
Expand Down Expand Up @@ -263,3 +289,9 @@ func (s *stream) Run(ctx context.Context) (*pb.Job_Result, error) {
// to accomidate the additional time before the job was picked up when testing in
// local Docker.
const stateEventPause = 3000 * time.Millisecond

// If no runner has accepted a job after 1 minute, it might be that the runner
// profile selected is no longer valid or the runner no longer exists. Generally
// active runners should be picking up tasks right away. Our jobs have a 2 minute
// timeout, so if it's taken at least 1 minute, something is probably up.
const noRunnerAckEventPause = 1 * time.Minute

0 comments on commit 1fef3dd

Please sign in to comment.