cryostatio / cryostat

Other
7 stars 8 forks source link

fix(jvmId): correct query for Targets with null jvmId #496

Closed andrewazores closed 3 weeks ago

andrewazores commented 4 weeks ago

Welcome to Cryostat3! 👋

Before contributing, make sure you have:

To recreate commits with GPG signature git fetch upstream && git rebase --force --gpg-sign upstream/main


Fixes: #495

Description of the change:

Corrects a database query. Previously it queried with find("id", (String) null), which generates a SQL query like select from Target where jvmId = null and returns no results, even when there are targets with null JVM IDs. The new query is slightly different: select from Target where jvmId is null, with the is null being the significant difference. With this the database query correctly comes back with the targets with a null JVM ID.

https://stackoverflow.com/questions/9581745/sql-is-null-and-null

Motivation for the change:

This fixes the Target persist hook that is responsible for checking if newly stored credentials apply to targets, checking for targets which do not yet have a JVM ID, and then using the new credentials to try to set the target's JVM ID.

How to manually test:

  1. Check out and build PR
  2. ./smoketest.bash -Ot
  3. Go to Topology, confirm that two of the vertx-fib-demo targets have a warning icon and no JVM ID
  4. Go to Security and define a new credential: target.alias.contains('andrew'), admin:adminpass123. The CredentialsStored notification should appear, and so should a target update notification for each target
  5. Go back to Topology. The two targets should now have no warning icon and should have a JVM ID
andrewazores commented 4 weeks ago

/build_test

github-actions[bot] commented 4 weeks ago

Workflow started at 6/5/2024, 1:15:44 PM. View Actions Run.

github-actions[bot] commented 4 weeks ago

No GraphQL schema changes detected.

github-actions[bot] commented 4 weeks ago

No OpenAPI schema changes detected.

github-actions[bot] commented 4 weeks ago

CI build and push: All tests pass ✅ (JDK17) https://github.com/cryostatio/cryostat3/actions/runs/9388437939