-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add global job timeout #512
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
narbs91
reviewed
Feb 14, 2025
650a203
to
e226757
Compare
narbs91
reviewed
Feb 18, 2025
narbs91
approved these changes
Feb 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The cancelled filter query now includes the include cancelled, which was our mechanism for requesting all job offers. The cancelled filter query includes all when nil, or cancelled or not when true or false.
54f69f7
to
cd2b588
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request makes the following changes:
JOB_TIMEOUT_SECONDS
configJobTimedOut
terminal agreement stateActive
job offer query filterCancelled
job offer query filterIncludeCancelled
filter and integrate it intoCancelled
We have also made a couple of related changes and small cleanups:
solve
functionBoolPointer
language helper to more easily construct pointers to boolsThe primary goal of this pull request is adding a global job timeout for jobs that are stuck, stale, or abandoned. The global timeout will be superseded by timeouts in module specs and job offers when we have implemented them.
We have also added new
Active
andCancelled
job offer query filters in support of the global timeout.Task/Issue reference
Closes: #511
Test plan
Start the base services. Start the solver with the job offer timeout set to ten seconds:
Submit a job without a resource provider running. The job should fail and report a job timed out error message.
Start a resource provider and run another job. Again, the job should be cancelled, but this time in flight. The job creator should see the error message and the resource provider should repost their resource offer.
See the details below if you would like to confirm the activity through metrics and traces.
Details
Active
andCancelled
job offer filter queriesWe have added two new job offer filter queries.
When
Active
istrue
, only jobs inDealNegotiating
,DealAgreed
, orResultsSubmitted
states are included.Query active job offers from the solver server with the
active
querstring param. In local development:curl http://localhost:8081/api/v1/job_offers?active=true
The
Cancelled
query filter is a*bool
where:nil
includes all jobstrue
includes jobs inJobOfferCancelled
andJobTimedOut
statesfalse
includes jobs not in aJobOfferCancelled
orJobTimedOut
stateWe removed the
IncludeCancelled
filter query which is now performed whenCancelled
isnil
.Query jobs on the solver server using the
cancelled
querystring param. In local development:JobTimedOut
agreement stateWe have added a new
JobTimedOut
agreement state to describe jobs that were cancelled because they expired.We considered using the existing
JobOfferCancelled
state, but it is not coherent when we want to mark resource offers and deals with an expired state. In addition, our mechanism for reporting what happened to the job creator is limited, soJobTimedOut
serves as a tag to help us log a good error message for the job creator.When a job times out before a deal was made, the job offer is marked with the
JobTimedOut
state. When a deal has already been made, the job offer, resource offer, and deal are all marked with theJobTimedOut
state.If a resource provider attempts to upload files or report results for an expired job, the solver server rejects their post with an error reporting the job as timed out.
JOB_TIMEOUT_SECONDS
configWe have added a new config to set the global timeout in seconds. The default value is ten minutes.
Set the job timeout with an environment variable of CLI option. For example, to expire jobs after 30 seconds:
Observability
The deal metrics have been updated to reflect overall job metrics. We want to include metrics about job offers that were never in a deal, and we record these from jobs that expired or were cancelled.
The metrics are reported in an updated
Solver Metrics
dashboard:The updated dashboard is available in this observability pull request: https://github.com/Lilypad-Tech/observability/pull/27
Metrics are not enabled by default in local development, but they can be turned on with:
We have also included traces over our new
cancelExpiredJobs
solver controller function. Traces are also disabled by default in local development, but can be enabled with the--disable-telemetry=false
CLI option.The traces can be queried by searching TraceQL with the
cancel_expired_jobs
span name and a non-empty expired jobs span attribute:When a job is cancelled before a match, the trace will look like:
If a job is cancelled after a match, it will also report a deal ID:
Related issues or PRs
Observability dashboard PR: https://github.com/Lilypad-Tech/observability/pull/27