Skip to content

feat(discovery): add endpoint for plugins to check their registration #1425

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

Merged
merged 2 commits into from
Mar 30, 2023

Conversation

andrewazores
Copy link
Member

Welcome to Cryostat! 👋

Before contributing, make sure you have:

  • Read the contributing guidelines
  • Linked a relevant issue which this PR resolves
  • Linked any other relevant issues, PR's, or documentation, if any
  • Resolved all conflicts, if any
  • Rebased your branch PR on top of the latest upstream main branch
  • Attached at least one of the following labels to the PR: [chore, ci, docs, feat, fix, test]
  • Signed the last commit: git commit --amend --signoff

Related to cryostatio/cryostat-agent#85

Description of the change:

This adds a GET endpoint that plugins can use with their existing registration ID and token to check their registration status. The API response is 200 if the plugin is registered and the token is still valid, 401 if the token is invalid, and 404 if the token is somehow valid but the plugin is not registered (this should be impossible - if the plugin is not registered then any token it still has should be invalid).

Motivation for the change:

This is used by the -agent to perform its own periodic heartbeat checks on the Cryostat server at a slower cadence. If the plugin notices that it cannot reach Cryostat, or that Cryostat no longer recognizes it as a registered plugin, then the -agent re-enters its original unregistered state and begins trying to more quickly re-register itself with the Cryostat server it is configured for.

How to manually test:

Patch shometest.sh like so:

diff --git a/smoketest.sh b/smoketest.sh
index 4aebf722..6465b53e 100755
--- a/smoketest.sh
+++ b/smoketest.sh
@@ -179,6 +179,7 @@ runDemoApps() {
         --env CRYOSTAT_AGENT_TRUST_ALL="true" \
         --env CRYOSTAT_AGENT_AUTHORIZATION="Basic $(echo user:pass | base64)" \
         --env CRYOSTAT_AGENT_REGISTRATION_PREFER_JMX="true" \
+        --env CRYOSTAT_AGENT_REGISTRATION_CHECK_MS="15000" \
         --rm -d quay.io/andrewazores/quarkus-test:latest
 
     # copy a jboss-client.jar into /clientlib first

to make one of the sample agent applications perform this check more frequently so it's easier to catch.

  1. Run CRYOSTAT_IMAGE=quay.io... sh smoketest.sh...
  2. Check the server logs and agent logs. There should be frequent GET requests to the new endpoint, which should succeed.
  3. TODO figure out a decent way to set up an environment where the Cryostat server can be taken down and restarted without also taking down the agents.

@github-actions
Copy link
Contributor

Test image available:

$ CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1425-0f7f509e7b1590cc62c774f2e06ed99d219ac4cc sh smoketest.sh

Copy link
Member

@maxcao13 maxcao13 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@github-actions
Copy link
Contributor

Test image available:

$ CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1425-66ae507d9f6e0d8745bbee8d97e6a070e07c058a sh smoketest.sh

@andrewazores andrewazores merged commit c5974a5 into cryostatio:main Mar 30, 2023
@andrewazores andrewazores deleted the plugin-registration-check branch March 31, 2023 00:31
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
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants