-
Notifications
You must be signed in to change notification settings - Fork 4
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
Testnet/Mainnet Deployments Should Contain Version Metadata derived from Polykey-CLI #93
Conversation
Where We're At
|
I thought having a generic metadata for PolykeyAgent would have been fine. And aren't we doing source substitution, not environment variables? |
Why not just a generic metadata for the The other option is to enable some form modular extensibility as we mentioned earlier - a sort of fixed point override to our RPC handlers, since separation of responsibility right now means PK CLI has no way of adding new methods to the RPC that is being exported from the Polykey core library. There was some discussion about this earlier when @tegefaulkes asked about the tradeoffs puttin the RPC definitions into the Polykey Core library. |
that is what i have done, it is shown as the |
`cliAgentCommitHash` is now available on `CommandStatus` for the sake of versioning feat: added commitHash label to docker build CI script ci: made pipelines work on this branch for testing fix: addded git to shell.nix feat: commitHash exposed from `agentStatus` handler via RPC middleware fix: renamed to cliAgentCommitHash for less ambiguity chore: lintfix fix: npm run build now uses the COMMIT_HASH environment variable if already defined chore: bump polykey to v1.2.1-alpha.45 fix: `CommandStatus` now uses the `versionMetadata` from `agentStatus` RPC call fix: `pkg` script doesn't require COMMIT_HASH environment variable fix: `commitHash` is now derived from the `commitHash.nix` derivation fix: removed testing conditions to CI jobs
267a563
to
261f76f
Compare
Description
This PR aims to add
commitHash
version metadata for the sake of deployment tracking to PK-CLI deployments.To do this, Polykey-Network-Status has to poll ECR for new image versions, knowing that the deployment has started when a new image has been detected, and has finished once a reconnection has been detected on the WebSocket connections to Polykey Nodes. This has a slight downside, being that you assume that an ECR image push will always be a deployment, and that an ECR image push will start around the same time as the ECS service deployment.
This option entails defining the commitHash at build time in scripts/build.js:
https://medium.com/@RobertoSilvaZ/adding-environments-vars-to-esbuild-b2a8e11b601e
However, the PK library, which handles the calls to agentStatus, reporting the version of the node, has no way of knowing what the commitHash of whatever is using it is (PK-CLI). Therefore, PK must expose a way for users of the library to define custom rpcMiddlewares to modify the response of agentStatus to include the version.
To get this hash,
COMMIT_HASH
should be defined as the output ofgit rev-parse HEAD
usingcross-env
. This needs to be done in both thebuild
script, but all those that can potentially be used to run polykey in local development (test
,polykey
,ts-node
, etc).The commit hash needs to also be defined as metadata on the image.
This should be done by passing it via
--argstr
onnix-build
.The labels should be then defined within the
config
ofbuildImage
:NixOS/nixpkgs#20852
The labels can be gotten from ECR by obtaining the digest. This involves multiple API calls:
aws/containers-roadmap#178 (comment)
Once polling ECR has returned a new commitHash not listed in our PostgresDB database, we should add information about it into the db. This might include deployment commencement time, etc. A successful deployment will cause PolykeyClients connected to previous deployments on Polykey Network Status to be disconnected. So when we detect that a client has been detected, we want to reconnect to the new deployment, and check for the commitHash returned by an RPC call that contains it. If it matches an deployment entry in our DB created earlier from polling ECR, we can append the deployment finish time to it.
Issues Fixed
Tasks
These tasks are to be moved to a separate PR in PKNS
Final checklist