Skip to content
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: Check offer creation times for recency #523

Merged
merged 6 commits into from
Feb 25, 2025

Conversation

bgins
Copy link
Contributor

@bgins bgins commented Feb 21, 2025

Summary

This pull request makes the following changes:

  • Check job offer CreatedAt time is recent
  • Check resource offer CreatedAt time is recent
  • Add isTimestampRecent helper to check timestamps fall into a time window near now
    • Add TestIsTimestampRecent test
  • Add SERVER_OFFER_TIMESTAMP_DIFF_SECONDS config

This pull request checks that job and resource offers report a creation time that is recent.

We have also renamed the ANURA_ADDRESSES config to SERVER_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:

./stack solver --server-offer-timestamp-diff-seconds 10
SERVER_OFFER_TIMESTAMP_DIFF_SECONDS=10 ./stack solver

Creation time check

We check that offer CreatedAt times are recent within a time window set by SERVER_OFFER_TIMESTAMP_DIFF_SECONDS. The time window starts SERVER_OFFER_TIMESTAMP_DIFF_SECONDS before the check time and ends SERVER_OFFER_TIMESTAMP_DIFF_SECONDS after.

Related issues or PRs

Epic: https://github.com/Lilypad-Tech/internal/issues/348

@cla-bot cla-bot bot added the cla-signed label Feb 21, 2025
@bgins bgins mentioned this pull request Feb 22, 2025
7 tasks
@bgins bgins force-pushed the bgins/feat-add-offer-recency-check branch from 61621a9 to 6d1f277 Compare February 24, 2025 16:48
@bgins bgins marked this pull request as ready for review February 24, 2025 17:09
@bgins bgins requested a review from a team as a code owner February 24, 2025 17:09
Copy link
Contributor

@kelindi kelindi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@bgins bgins force-pushed the bgins/feat-add-offer-recency-check branch 2 times, most recently from af5ea69 to 85bbb8a Compare February 25, 2025 21:26
@bgins bgins merged commit eaa5509 into main Feb 25, 2025
5 checks passed
@bgins bgins deleted the bgins/feat-add-offer-recency-check branch February 25, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants