-
Notifications
You must be signed in to change notification settings - Fork 31
fix(target): handle creating short form custom target #1875
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
Conversation
00cb5a5
to
6e42912
Compare
/build_test |
Workflow started at 2/16/2024, 2:30:57 PM. View Actions Run. |
https://github.com/cryostatio/cryostat/actions/runs/7935345026 Looks like a unit test needs updating. |
/build_test |
Workflow started at 2/16/2024, 5:45:37 PM. View Actions Run. |
To run smoketest:
|
|
Looks like this is the root cause of the itest failures, I think the rest might be cascading failures because this failed and didn't clean up after itself:
|
/build_test |
Workflow started at 2/20/2024, 8:46:10 PM. View Actions Run. |
/build_test |
Workflow started at 2/20/2024, 8:51:57 PM. View Actions Run. |
To run smoketest:
|
To run smoketest:
|
|
/retest |
Workflow started at 2/20/2024, 9:50:12 PM. View Actions Run. |
|
|
/build_test |
Workflow started at 2/21/2024, 6:02:02 AM. View Actions Run. |
@@ -341,9 +349,11 @@ void shouldBeAbleToDeleteTarget() | |||
} | |||
}); | |||
|
|||
String jmxServiceUrl = "service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi"; | |||
String encodedUrl = URLEncoder.encode(jmxServiceUrl, StandardCharsets.UTF_8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite its name, URLEncoder is not actually the right tool for this job:
https://docs.oracle.com/javase/8/docs/api/java/net/URLEncoder.html
Utility class for HTML form encoding. This class contains static methods for converting a String to the application/x-www-form-urlencoded MIME format.
I think it's better to use URLEncodedUtils:
if (StringUtils.isBlank(connectUrl)) { | ||
throw new ApiException(400, "\"connectUrl\" form parameter must be provided"); | ||
} | ||
// check incase custom target has short form connection url (i.e `localhost:0`, | ||
// etc) | ||
if (connectUrl.matches("localhost:\\d+")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex pattern should not match only localhost
- it could be any hostname, or domain name, or IP address here instead.
We'll need to come up with some way to distinguish these "short forms" from fully formed URLs somehow, with a precise definition. I guess what is common to all these options is that they have a host/domain/IP and a port only, and there is no URL scheme/protocol, path, query, etc. So we know the characters :
and /
and any whitespace will not appear in the left hand side since these could only be from the scheme or path, and only numbers will appear on the right hand side for the port. Maybe something like this:
connectUrl = connectUrl.strip();
boolean isShortForm = connectUrl.matches("^[^\\s/:]+:\\d+$");
/build_test |
Workflow started at 2/21/2024, 1:07:25 PM. View Actions Run. |
To run smoketest:
|
|
Trying to figure out why the tests fail here but not locally. Even added print logs locally to see and everything is as expected.
Also logs show correct and expected output opposite from what is shown on the workflow errors!
|
7e3af7d
to
69c274f
Compare
Could there be something like trailing newlines (or other invisible whitespace) characters that are breaking the comparison assertions? |
I thought this would be the issue too, I checked but dint see any.. I will check again. |
Try adding a |
/build_test |
Workflow started at 2/21/2024, 3:09:38 PM. View Actions Run. |
To run smoketest:
|
|
/build_test |
Workflow started at 2/21/2024, 8:09:52 PM. View Actions Run. |
To run smoketest:
|
|
Welcome to Cryostat! 👋
Before contributing, make sure you have:
main
branch[chore, ci, docs, feat, fix, test]
To recreate commits with GPG signature
git fetch upstream && git rebase --force --gpg-sign upstream/main
Fixes: #1867
Description of the change:
Handle bug when short form custom target i.e
localhost:0
is created.Motivation for the change:
mentioned by @cmah88: https://github.com/cryostatio/cryostat/issues/1867#issue-2101109011
How to manually test: