-
Notifications
You must be signed in to change notification settings - Fork 31
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(archives): add target-specific archive API endpoints #1047
fix(archives): add target-specific archive API endpoints #1047
Conversation
This PR/issue depends on:
|
There are still some minor kinks to iron out, I'm hoping to have the implementation done and working by tomorrow, likely won't have time to add new tests (I'm updating existing tests as I go). |
src/main/java/io/cryostat/recordings/RecordingArchiveHelper.java
Outdated
Show resolved
Hide resolved
Thanks for taking this on and getting so much of it done in the final stretch of your internship, @hareetd . This looks quite good as it is, and I'm really looking forward to getting it merged because it's also an important milestone for #520/cryostat-agent. |
@andrewazores No problem, it was a fun way to end off the internship :-). Also, good to hear that it's an important part of those features, it'll definitely be nice to have a more clear link between targets and their archived data. Well, this is my final sign-off. Best of luck with Cryostat and hopefully our paths cross in the future! |
I think we can start on this! There is also front-end work so I will talk with @maxcao13 to divide the work to get them done. |
To avoid such issue, we start to disable these handlers by setting Edit: With this, Cryostat will return |
Perhaps the most client-friendly thing to do for the next release is to mark the class as |
Oh boy, that's a bunch of conflicts :/ Can we also add some logic either to these new handlers or within ex. |
Yeah, I've been dreading these conflicts cause I've been working on both :-)
For sure, thanks for the feedback. I'm wondering about task 6, I think all we need to do about the uploading metadata issue now is to update the web-client to handle the recent merge https://github.com/cryostatio/cryostat/pull/1063 with this associated PR cryostatio/cryostat-web#499 ? |
I believe so, yes. |
If we do it this way, the endpoints won't be able to work if the Also, if a user still wanted to delete an archived recording from their fs (from the command line), but the target was gone and removed from the database, I don't think either solutions would work. What do you think? |
Command line (curl, httpie) vs web-client shouldn't matter, in the end they're both talking to the API as the source of data about what is present and what actions can be performed.
So we can apply the transformation of Though, this now has me wondering what to do about push-only agents. They won't publish JMXServiceURLs and won't be connectable over JMX, so Cryostat won't be able to compute a Perhaps we need another set of similar endpoints for agents to push JFR files to? Rather than using the
Fair - so just don't enforce that check on the deletion action, but do enforce it on the upload. |
I'll probably start to use the jvmIds here as well because of https://github.com/cryostatio/cryostat/issues/972
Seems reasonable, I guess that should be another PR for later. |
Ignoring tests, thoughts on the structure or anything else? The reason I have the migration and Something else I added is a "metadata-like" file in each I still need to update the web-client and update tests. |
Sure, this all makes sense. I will note that the nature of the
I think this solution is fine. The subdirectory name could really explode in length if we encode the URL and append that on top of something else like an ID hash. If URLs are particularly long we might even run into the Linux filename length limit. |
src/main/java/io/cryostat/net/reports/RemoteReportGenerator.java
Outdated
Show resolved
Hide resolved
src/main/java/io/cryostat/net/web/http/api/v1/RecordingUploadPostHandler.java
Outdated
Show resolved
Hide resolved
I missed this in the other PR but noticed that you deprecated the |
src/main/java/io/cryostat/net/web/http/api/beta/RecordingDeleteHandler.java
Outdated
Show resolved
Hide resolved
…se of getJvmId on non-reachable targets -> instead just return empty lists, changed ArchivedRecordingInfo to have non encoded serviceuri field now that the subdirectories are not no longer encoded targetIds, removed debugging prints
…and uts, fixed bugs
Just to confirm my understanding - the purpose of the |
Yes, that's exactly right. |
Okay, I think that's okay for now. We will want to revisit that in the future and replace the stored connectUrl with some other properties about the JVM - maybe everything else that goes into the hash other than the startup time, for example. The reason for that is that the connectUrl may actually change in between lifecycles of the conceptually "same" target application instance. In an OpenShift environment we use the IP address of the target to come up with the connectUrl, and it's very possible that the IP address changes when the application comes back online, so the archives wouldn't get transferred. This would necessitate connecting to every application that appears and retrieving those properties from it in order to compare it to every single archive we have, so that's definitely not ideal because for large installations with a lot of services coming and going and a lot of archives it becomes very slow and I/O intensive. On the other hand, when we have the Cryostat Agent pushing data into the archives, maybe the Agent can be a little smarter and compute its own hash ID for itself and use that as the sourceTarget so that the data can be properly correlated across instances. |
Ah but wait, if we look at the JVM properties other than the startup time and the connectUrl (which encodes information about the IP address or hostname), then how can we tell apart different replicas of the same microservice? I think they would all look the same, so we wouldn't be able to distinguish archives between instances anymore in that case. Bah. The Agent is looking better and better every day. |
Fixes #1046
Depends on cryostatio/cryostat-web#499
Summary:
I've added five new
beta
target-specific archived recording handlers:RecordingDeleteHandler
,RecordingUploadPostHandler
,RecordingGetHandler
,RecordingGetWithJwtHandler
,ReportGetHandler
andReportGetWithJwtHandler
. They're essentially equivalent to theirv1
/v2
counterparts, except with an addedsourceTarget
request parameter that expects the JMX connection URL of the source target for the archived recording in question.The
WebServer
now points to thebeta
RecordingGetHandler
andReportGetHandler
endpoints when theWebServer#getArchivedDownloadUrl
andWebServer#getArchivedReportUrl
methods are called, respectively. This means archived recording-related notifications will now contain target-specific download URLs. Notifications have also been updated so that thetarget
field is equal to"uploads"
rather than the empty string for uploaded recordings. This is because for the new target-specific handlers thesourceTarget
parameter cannot be set to the empty string in place of aconnectUrl
for uploaded recordings. Since the"uploads"
string is the logical alternative to use for this parameter, in order to maintain consistency, notifications also explicitly identify a recording as having originated as an upload directly into Cryostat's archives.The implementation should still preserve the functionality of the older, non-target-specific
v1
/v2
handlers. I didn't have time to manually test but unit and integration tests are all passing. In the case where such an endpoint is called, the archives are searched using only the recording name, which is still error-prone for the reasons discussed in [Task] Deleting archived recordings can delete wrong file for identically-named but distinct files cryostat-web#445. Perhaps these handlers should now be marked as deprecated?For the cached report path, if no
sourceTarget
is provided the report is placed inside a newdefault
subdirectory which is itself inside the temporary directory provided by theWebServer
. Uploaded recordings are placed inside anuploads
subdirectory and target-specific recordings inside a subdirectory named according to the target's Base32 encodedconnectUrl
. See my comment below on issues with creating these subdirectories.The web-client in fix(archives): use target-specific archive API endpoints cryostat-web#499 has been updated to use the new
beta
handlers in place of the old ones (I might have missed something though, so please double-check). Unfortunately, the View Report functionality is broken as it keeps timing out with the report not being delivered. However, I'm experiencing this behavior on the main branch as well, so could be a general issue or an error on my part. The report dropdown generation works as expected.original comment by @andrewazores: cryostatio/cryostat-web#445 (comment)
I ran out of time to implement this request. New tests and HTTP API documentation also need to be added still.
TODOs [Max, Thuan]: