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

New rule definitions trigger on existing targets #538

Merged
merged 10 commits into from
Jul 2, 2021

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Jun 24, 2021

With this change, adding a new rule definition causes that rule to become immediately activated for any matching targets that are already known. Prior to this change adding a new rule definition would only affect targets that (re)appear after the rule was added.

Example:

  1. Run smoketest.sh
$ http --verify=false -f https://0.0.0.0:8181/api/v2/rules name=foorule description="Rule for testing" targetAlias=es.andrewazor.demo.Main eventSpecifier="template=Continuous"
HTTP/1.1 201 Created
content-encoding: gzip
content-length: 94
location: /api/v2/rules/foorule

{"meta":{"type":"text/plain","status":"Created"},"data":{"result":"foorule"}}
  1. Check that the vertx sample app listening on 9093 has a new recording named auto_foorule. The other vertx apps on 9094 and 9095 require credentials, so they will not have matching recordings, but Cryostat's logs should reveal that it attempted to start recordings on them and failed due to the lack of credentials.

@andrewazores andrewazores marked this pull request as draft June 24, 2021 13:57
@andrewazores andrewazores force-pushed the new-rule-old-target branch 2 times, most recently from 70a3753 to 40fc7c4 Compare June 24, 2021 19:09
@andrewazores andrewazores marked this pull request as ready for review June 24, 2021 19:11
@andrewazores andrewazores changed the title [draft] New rule definitions trigger on existing targets New rule definitions trigger on existing targets Jun 24, 2021
@jan-law
Copy link
Contributor

jan-law commented Jun 25, 2021

Checking my understanding: Is the purpose of the RecordingCreationHelper to create a new recording, aka apply a new rule, to matching targets without going through the web client?

@andrewazores
Copy link
Member Author

Pretty much, yes. The API handler for creating recordings used to process the POST request and form and then also handle all of the actual logic of creating the recording. It made sense to extract that out to somewhere reusable so that automatic rules can perform the same logic, but without having to do an HTTP request to ourselves and deal with a nested request/response (client -> cryostat -> cryostat -> client).

@andrewazores andrewazores force-pushed the new-rule-old-target branch from da6dc3e to fed0d01 Compare June 30, 2021 17:37
@andrewazores
Copy link
Member Author

Rebased, the only conflict was just imports in the MainModule.

@andrewazores andrewazores force-pushed the new-rule-old-target branch from fed0d01 to 1ab03b5 Compare June 30, 2021 17:46
Copy link
Contributor

@jan-law jan-law 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! Will wait until @hareetd has had a chance to review this thoroughly

Copy link
Contributor

@hareetd hareetd 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!

@andrewazores andrewazores merged commit f309b94 into cryostatio:main Jul 2, 2021
@andrewazores andrewazores deleted the new-rule-old-target branch July 2, 2021 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants