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

fix(rules): refactor rules to become aware of jvmIds #1347

Merged
merged 4 commits into from
Feb 2, 2023

Conversation

maxcao13
Copy link
Member

@maxcao13 maxcao13 commented Jan 31, 2023

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

Fixes: #1092

Description of the change:

Rules are not aware of jvmIds and will do operations more than once on targets if there exist more than one jvmId unique target within the discovery storage. This PR allows rules to do only do operations on jvmId unique targets with non-null jvmIds. This should work since the discovery storage is updated with non-null jvmIds whenever credentials are posted correctly and targets with the same jvmId are the same jvm.

However there is one problem in that when Cryostat restarts, the custom targets that are persisted never update their own jvmId when Cryostat comes back up, and so there will be a mismatch of jvmIds and the custom target will have a "stale" id. I'm not sure what is the best way to deal with this. Maybe on built-in discovery startup, test target connections for their jvmId again? I'm not too sure about the race conditions for that problem for now.

Motivation for the change:

JvmIds are unique to jvms. We don't want rule operations, for example deleting/stopping a recording, to apply more than once on a target jvm as that is extra overhead cost.

How to manually test:

  1. Run CRYOSTAT_IMAGE=quay.io... sh smoketest.sh...
  2. Create a target "cryostat:9093"
  3. Create a rule with matchExpression=="true"
  4. Enable the rule.
  5. Disable the rule or delete the rule. The logger should no longer show an error.

@maxcao13 maxcao13 marked this pull request as ready for review February 2, 2023 17:44
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

Test image available:

$ CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1347-6eaccdfdab6310f462ee604b8ef6e5657766ac0a sh smoketest.sh

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

Test image available:

$ CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1347-c08be005bab3fc64d865fd4f700c7b04baf47a1f sh smoketest.sh

…e queries, added jvmId support for rules, fixed duplicate jvmId target filtering predicate func

Signed-off-by: Max Cao <macao@redhat.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

Test image available:

$ CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1347-929edbffbfede3967c6e6acd24e32e8211e29d34 sh smoketest.sh

@andrewazores andrewazores merged commit b7f27d2 into cryostatio:main Feb 2, 2023
@maxcao13 maxcao13 deleted the jvmid-rules branch February 2, 2023 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Task] Automated Rules should be JvmID-aware
2 participants