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(versions): record own build info/version as properties, validate server version #508

Merged
merged 8 commits into from
Oct 15, 2024

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Oct 4, 2024

Fixes #504
Fixes #505

At build time, the following bits of information are recorded into resources files which are included in the distribution JAR:

  • pom.xml version, ie the Agent's own version string
  • pom.xml cryostat.server.version.min and cryostat.server.version.max, the minimum (inclusive) and maximum (exclusive) Cryostat server versions that this Agent version is expected to work with. Currently set to 4.0.0 and 5.0.0 respectively, forming the range [4.0.0, 5.0.0), so that any Cryostat server version 4.y.z should be within range. These are set as pom.xml properties rather than in the microprofile-config.properties so that they are build-time immutable.
  • current git commit hash

The Agent reads its own version string and logs this at startup. It loads all of these values and sets them as various system properties so that they can be retrieved generically later on. Finally, when it attempts to register itself with the Cryostat server, it performs a GET /health check against the server to obtain the server's cryostatVersion string, then parses that to a semantic version, and compares that to the expected server version range. If the actual server version is outside of the expected range then the agent logs a warning.

2024-10-04 18:07:44:382 +0000 [cryostat-agent-main] INFO io.cryostat.agent.Agent - Cryostat Agent version 0.5.0-SNAPSHOT starting...
...
2024-10-04 18:08:25:018 +0000 [cryostat-agent-worker-2] DEBUG io.cryostat.agent.Registration - Connected to Cryostat server: version 4.0.0 , build abfc597f1a7ad93093f7ead616766d56b4333809

Screenshot_2024-10-04_14-12-10

@andrewazores andrewazores added feat New feature or request safe-to-test labels Oct 4, 2024
@github-actions github-actions bot added the needs-triage Needs thorough attention from code reviewers label Oct 4, 2024
@andrewazores andrewazores removed the needs-triage Needs thorough attention from code reviewers label Oct 4, 2024
@andrewazores andrewazores force-pushed the buildinfo branch 2 times, most recently from d54e971 to 3666bb1 Compare October 4, 2024 17:53
@andrewazores andrewazores marked this pull request as ready for review October 4, 2024 18:17
@andrewazores andrewazores requested a review from a team as a code owner October 4, 2024 18:17
@andrewazores andrewazores requested a review from a team October 4, 2024 18:17
Copy link
Contributor

@Josh-Matsuoka Josh-Matsuoka left a comment

Choose a reason for hiding this comment

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

I think the fixme in BuildInfo is probably worthwhile, we should open an issue for core to keep track of it. Other than that LGTM

@andrewazores andrewazores merged commit 948ed98 into cryostatio:main Oct 15, 2024
9 checks passed
@andrewazores andrewazores deleted the buildinfo branch October 15, 2024 20:18
@ebaron
Copy link
Member

ebaron commented Oct 16, 2024

I'm getting an error upon agent startup after this change:

Exception in thread "cryostat-agent-main" Exception in thread "cryostat-agent-main" java.lang.NumberFormatException: For input string: "0-SNAPSHOT"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
	at java.base/java.lang.Integer.parseInt(Integer.java:668)
	at java.base/java.lang.Integer.parseInt(Integer.java:786)
	at io.cryostat.agent.VersionInfo$Semver.fromString(VersionInfo.java:109)
	at io.cryostat.agent.VersionInfo.load(VersionInfo.java:50)
	at io.cryostat.agent.Agent.accept(Agent.java:210)
	at io.cryostat.agent.Agent.lambda$agentmain$0(Agent.java:160)
	at java.base/java.lang.Thread.run(Thread.java:840)
java.lang.NumberFormatException: For input string: "0-SNAPSHOT"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
	at java.base/java.lang.Integer.parseInt(Integer.java:668)
	at java.base/java.lang.Integer.parseInt(Integer.java:786)
	at io.cryostat.agent.VersionInfo$Semver.fromString(VersionInfo.java:109)
	at io.cryostat.agent.VersionInfo.load(VersionInfo.java:50)
	at io.cryostat.agent.Agent.accept(Agent.java:210)
	at io.cryostat.agent.Agent.lambda$agentmain$0(Agent.java:160)
	at java.base/java.lang.Thread.run(Thread.java:840)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request safe-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] Build info properties [Request] Cryostat server version validation
3 participants