Skip to content

Report when the deployed policyengine.py version went live #4083

Closed

Description

@PavelMakarchuk

Problem

Nothing reports how long the API has served its current policyengine.py (.py) version. GET /v2/tax-benefit-models/by-country/{country} reports the version, but not since when. A deploy timestamp would not help: the API deploys a new Cloud Run revision several times a day while .py stays the same, so "last deployed" is nearly always today.

The app-v2 developer-tools Deployments page (PolicyEngine/policyengine-app-v2#1450) shows, for each core service, which .py, country model and data build it serves. It already shows "live since" for the household API (from its /versions deployed_at); the API has no equivalent.

Proposal

  • At candidate deploy, read the .py version from uv.lock, and read DEPLOYED_POLICYENGINE_VERSION and POLICYENGINE_VERSION_LIVE_SINCE from the revision that serves 100% of traffic (steps.previous.outputs.revision). Keep its date when the .py version is unchanged; use the deploy time for a new version; leave it unknown when the serving revision has no recorded date. Pass both as Cloud Run environment variables.
  • Add GET /deployment next to /health, returning the installed .py version, its live-since date and the Cloud Run revision (K_REVISION).

Done when

  • A deploy that keeps the .py version keeps the date; a deploy that changes it (or a first deploy) sets a new date; a serving revision without a recorded date, or a failed lookup, leaves the date unknown rather than wrong, and never fails the deploy.
  • GET /deployment returns the three fields; the date is null on a revision deployed before this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions