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

wasm binary version enhanced traces #53

Merged
merged 1 commit into from
Jun 10, 2024
Merged

wasm binary version enhanced traces #53

merged 1 commit into from
Jun 10, 2024

Conversation

eguzki
Copy link
Contributor

@eguzki eguzki commented May 29, 2024

What

Generates log line with traceable version of the wasm module

Kuadrant wasm module v0.5.0-dev (7ea94e90) ["+with-serde"] release root-context #1: VM started

Format being:

v{VERSION} ({GIT_HASH}) {FEATURES} {PROFILE}

Rules for <VERSION>

main branch no longer has meaningless v0.1.0. It has v<next-unreleased-version>-dev. So if the current release is v0.4.0, Cargo.toml file would have something like this

version = "0.5.0-dev"

thatdev suffix means it is still under development.

The v0.5.0 release process would have an extra step to bump the version to version = "v0.5.0" and main would be bumped to Version = "v0.6.0-dev"

Rules for <GIT_HASH>

The build process first tries

GIT_SHA = `git rev-parse HEAD`

if it succeeded, it tries to check for "dirty" files (not committed files used in the build)

GIT_DIRTY = `git diff --stat`

So GIT_HASH is either

GIT_HASH = $(GIT_SHA)

or

GIT_HASH = $(GIT_SHA)-dirty

If it fails (because there is no git in the build process), it tries to read env var GITHUB_SHA, so

GIT_HASH = $(GITHUB_SHA)

It fallsback to NO_SHA when even the GITHUB_SHA env var does not exist.

These rules are implemented in https://github.com/Kuadrant/limitador

Verification steps

  • Build module with git available and no dirty files:
rm target/wasm32-unknown-unknown/release/wasm_shim.wasm
make development 2>&1 | grep "Kuadrant wasm module"

The output should be something like

envoy-1      | [2024-06-05 16:20:33.435][1][info][wasm] [source/extensions/common/wasm/context.cc:1167] wasm log kuadrant_wasm vm.sentinel.kuadrant_wasm: Kuadrant wasm module v0.5.0-dev (7ea94e90) ["+with-serde"] release root-context #1: VM started

highlighting here the important bits: Kuadrant wasm module v0.5.0-dev (7ea94e90) ["+with-serde"] release

  • Build module with git available and some dirty files:
make stop-development
rm target/wasm32-unknown-unknown/release/wasm_shim.wasm
echo "extra line" >> README.md 
make development 2>&1 | grep "Kuadrant wasm module"

The output should be something like

envoy-1      | [2024-06-05 16:26:26.370][68][info][wasm] [source/extensions/common/wasm/context.cc:1167] wasm log kuadrant_wasm vm.sentinel.kuadrant_wasm: Kuadrant wasm module v0.5.0-dev (7ea94e90-dirty) ["+with-serde"] release root-context #1: VM started

highlighting here the important bits: Kuadrant wasm module v0.5.0-dev (7ea94e90-dirty) ["+with-serde"] release

  • Build module when git is not available and GITHUB_SHA=v10.0.0

🚨 make sure your git repo does not have anything pending to be pushed. It is better to follow these steps on a just cloned repo.

make stop-development
rm target/wasm32-unknown-unknown/release/wasm_shim.wasm
rm -rf .git
GITHUB_SHA=v10.0.0 make development 2>&1 | grep "Kuadrant wasm module"

The output should be something like

envoy-1      | [2024-06-05 16:29:49.065][1][info][wasm] [source/extensions/common/wasm/context.cc:1167] wasm log kuadrant_wasm vm.sentinel.kuadrant_wasm: Kuadrant wasm module v0.5.0-dev (v10.0.0) ["+with-serde"] release root-context #1: VM started

highlighting here the important bits: Kuadrant wasm module v0.5.0-dev (v10.0.0) ["+with-serde"] release

@eguzki eguzki requested a review from a team May 29, 2024 09:59
@eguzki eguzki marked this pull request as ready for review June 5, 2024 16:30
@eguzki eguzki requested a review from alexsnaps June 6, 2024 09:29
@eguzki eguzki force-pushed the logging-version branch from 7ea94e9 to 15dc348 Compare June 6, 2024 10:03
@eguzki
Copy link
Contributor Author

eguzki commented Jun 10, 2024

ready for another review @Kuadrant/engineering

Copy link
Member

@didierofrivia didierofrivia left a comment

Choose a reason for hiding this comment

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

code looks good to me, haven't tried the verification steps tho. 🌯

@eguzki eguzki merged commit ddb9dc0 into main Jun 10, 2024
6 checks passed
@eguzki eguzki deleted the logging-version branch June 10, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants