feat: Check offer creation times for recency #523
Merged
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:
CreatedAt
time is recentCreatedAt
time is recentisTimestampRecent
helper to check timestamps fall into a time window near nowTestIsTimestampRecent
testSERVER_OFFER_TIMESTAMP_DIFF_SECONDS
configThis pull request checks that job and resource offers report a creation time that is recent.
We have also renamed the
ANURA_ADDRESSES
config toSERVER_ANURA_ADDRESSES
.Task/Issue reference
Implements: #506
Test plan
Start the stack. Run a job. This should succeed with the resource offer and job offer received by the solver within the default 30 second diff.
We have added a temporary commit (bc0ff33) to demonstrate the failure case. Replace this line with the one below it to set the diff to 1ms, the restart the stack and run a job. In my local tests, this diff is small enough to trigger a failure. Hopefully true on your machine too. 🤞
Details
Configs
We have added a
SERVER_OFFER_TIMESTAMP_DIFF_SECONDS
config that can be set as a CLI option or environment variable:Creation time check
We check that offer
CreatedAt
times are recent within a time window set bySERVER_OFFER_TIMESTAMP_DIFF_SECONDS
. The time window startsSERVER_OFFER_TIMESTAMP_DIFF_SECONDS
before the check time and endsSERVER_OFFER_TIMESTAMP_DIFF_SECONDS
after.Related issues or PRs
Epic: https://github.com/Lilypad-Tech/internal/issues/348