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(recordingOptions): scope customizers to each Target #341

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Mar 22, 2024

Welcome to Cryostat3! 👋

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 all commits using a GPG signature

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


Fixes: #184

Description of the change:

Refactors the RecordingOptionsCustomizer implementation so that there is an internal in-memory cache Map<Target, RecordingOptionsCustomizer>. This way, the PATCH /api/v1/:connectUrl/recordingOptions request can set recording options defaults (for the "advanced options" of maxAge/maxSize/toDisk) for each target. Cache entries are evicted if the target is lost. These settings are only held in-memory and not persisted.

Motivation for the change:

Usually, clients do not actually set defaults on targets like this, instead simply setting these options on each recording in the same request as creating the recording. However, the API does expose this endpoint for setting per-target defaults, and so the implementation should actually respect this and ensure that the defaults are per-target rather than global to the server.

How to manually test:

  1. Run CRYOSTAT_IMAGE=quay.io... bash smoketest.bash...
  2. Nothing should visibly change in the UI on its own, because the web-client never calls this PATCH endpoint.

However, using curl or http you can make a manual request to this PATCH and the corresponding GET to see that the changes are reflected. If you do make such a PATCH then the default settings displayed in the UI under Recordings > Create should match the updated defaults you set.

 http -v --auth=user:pass :8080/api/v3/targets/1/recordingOptions
GET /api/v3/targets/1/recordingOptions HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br
Authorization: Basic dXNlcjpwYXNz
Connection: keep-alive
Host: localhost:8080
User-Agent: HTTPie/3.2.2



HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Encoding: gzip
Content-Length: 61
Content-Type: application/json;charset=UTF-8
Date: Fri, 22 Mar 2024 18:27:09 GMT
Gap-Auth: user

{
    "maxAge": 0,
    "maxSize": 0,
    "toDisk": false
}

$ http -v --auth=user:pass -f PATCH :8080/api/v3/targets/1/recordingOptions maxAge=90 maxSize=1000000
PATCH /api/v3/targets/1/recordingOptions HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br
Authorization: Basic dXNlcjpwYXNz
Connection: keep-alive
Content-Length: 25
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: localhost:8080
User-Agent: HTTPie/3.2.2

maxAge=90&maxSize=1000000

HTTP/1.1 200 OK
Content-Length: 46
Content-Type: application/json;charset=UTF-8
Date: Fri, 22 Mar 2024 18:27:58 GMT
Gap-Auth: user

{
    "maxAge": 90,
    "maxSize": 1000000,
    "toDisk": false
}

$ http -v --auth=user:pass :8080/api/v3/targets/1/recordingOptions
GET /api/v3/targets/1/recordingOptions HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br
Authorization: Basic dXNlcjpwYXNz
Connection: keep-alive
Host: localhost:8080
User-Agent: HTTPie/3.2.2



HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Encoding: gzip
Content-Length: 65
Content-Type: application/json;charset=UTF-8
Date: Fri, 22 Mar 2024 18:28:06 GMT
Gap-Auth: user

{
    "maxAge": 90,
    "maxSize": 1000000,
    "toDisk": false
}

This would previously already work, however the difference is that the updated PATCH settings would previously end up applying to all targets (despite the connectUrl or targetId in the request path), whereas now they apply to individual targets.

@andrewazores
Copy link
Member Author

/build_test

Copy link

Workflow started at 3/22/2024, 2:30:45 PM. View Actions Run.

Copy link

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

Copy link

No OpenAPI schema changes detected.

@andrewazores andrewazores force-pushed the patch-recordingoptions branch from 7b1584f to 5ca347e Compare March 22, 2024 18:35
Copy link

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

@andrewazores andrewazores force-pushed the patch-recordingoptions branch from 5ca347e to 7ff32db Compare March 27, 2024 17:43
Copy link
Member

@mwangggg mwangggg left a comment

Choose a reason for hiding this comment

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

rebase needed- looks good otherwise

@andrewazores andrewazores force-pushed the patch-recordingoptions branch from 7ff32db to 31ed317 Compare April 15, 2024 13:19
@andrewazores
Copy link
Member Author

/build_test

Copy link

Workflow started at 4/15/2024, 9:20:25 AM. View Actions Run.

Copy link

No OpenAPI schema changes detected.

Copy link

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

@andrewazores andrewazores merged commit 7f3116c into cryostatio:main Apr 15, 2024
8 checks passed
@andrewazores andrewazores deleted the patch-recordingoptions branch April 15, 2024 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question] Remove PATCH recordingOptions endpoints for setting defaults?
2 participants