Skip to content

Add key rotation and expiry columns to worker_oauth table - #584

Open
Dev10-sys wants to merge 2 commits into
chaoss:mainfrom
Dev10-sys:feat/worker-oauth-key-dates
Open

Dev10-sys wants to merge 2 commits into
chaoss:mainfrom
Dev10-sys:feat/worker-oauth-key-dates

Conversation

@Dev10-sys

@Dev10-sys Dev10-sys commented Nov 22, 2026 •

Copy link
Copy Markdown

Description
This PR adds two new columns to the worker_oauth table in the operations schema to help track API key lifecycle as requested in #573:

  • last_rotated: Nullable timestamp of when the key was last rotated or added (defaults to NULL on existing records so unrotated keys are accurately represented).
  • expiry_date: Nullable timestamp for platforms/tokens that have an expiration date.

I also added:

  • An is_expired property on WorkerOauth to easily check if a key has expired against current UTC time.
  • Alembic migration 47_add_key_rotation_and_expiry_to_worker_oauth.py with upgrade and downgrade steps.
  • Unit tests covering the model attributes and expiration logic with various timezones.

This PR fixes #573

Notes for Reviewers
Updated last_rotated to nullable=True without a DB-level server default based on review feedback.

Signed commits

  • Yes, I signed my commits.

Generative AI disclosure

Please select one option:

  • This contribution was NOT assisted or created by Generative AI tools.
  • This contribution was assisted or created by Generative AI tools.

Add last_rotated and expiry_date columns to operations.worker_oauth to track when keys are rotated and when they expire, along with Alembic migration 47 and model tests.

Fixes chaoss#573

Signed-off-by: Dev10-sys <kalpanagola9897@gmail.com>
@Dev10-sys
Dev10-sys requested a review from MoralCode as a code owner November 22, 2026 09:53
@@ -0,0 +1,50 @@
"""Add last_rotated and expiry_date columns to worker_oauth table

Revision ID: 47

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FYI - i already have a chain of PRs (#575 and #580 ) that are likely to land first - maybe we can slot this in behind that once we figure out the details?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sounds like a plan! Once #575 and #580 merge into main, I'll rebase this branch and bump the revision ID to slot right behind them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO we dont need a unit test for migration files. theyre excluded from testing/coverage anyway and should not generally be changing once they are created/tested

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed, removed the migration tests from test_worker_oauth.py and kept only the model/expiry logic tests.

Update last_rotated column in worker_oauth to be nullable without a database-level server default, avoiding unintended backfill of current timestamps on existing keys. Remove migration unit tests as alembic migrations are excluded from test coverage.

Signed-off-by: Dev10-sys <kalpanagola9897@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Add columns to worker_oauth to track last key rotation date and key expiry date

2 participants