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

ARTEMIS-4160 Handle hostnames with invalid char sequences. #4362

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

davidlanouette
Copy link
Contributor

The hostname gets put into an xml comment in the jolokia-access.xml file. If the hostname has invalid char sequences for an xml comment, jolokia will fail at load time because the xml file is invalid.

Signed-off-by: David Lanouette David.Lanouette@RedHat.com

@davidlanouette
Copy link
Contributor Author

Hi all. This is my first PR for this project, and I didn't find anything that talked about needing a Bugzilla bug before submitting.


We ran into this issue. We have hosts with "--" in the name, and that ended up in the comment in the jolokia-access.xml file as a comment. That's an invalid char sequence for an xml comment.

I've tried to handle other illegal char sequences too.

I hope this PR is useful.

@jbertram
Copy link
Contributor

jbertram commented Feb 8, 2023

@davidlanouette, thanks for the contribution! Most changes will, in fact, need an associated Jira (we don't use Bugzilla). See more details in our Hacking Guide. I went ahead and created one for you.

@davidlanouette davidlanouette changed the title Handle hostnames with invalid char sequences. ARTEMIS-4160 Handle hostnames with invalid char sequences. Feb 9, 2023
@davidlanouette
Copy link
Contributor Author

@jbertram Do I need to get a jira login and update the bug before it gets reviewed?

@brusdev
Copy link
Member

brusdev commented Feb 10, 2023

@gtully this is the same issue we have seen ArtemisCloud.io test suite

@davidlanouette
Copy link
Contributor Author

davidlanouette commented Feb 10, 2023

this is the same issue we have seen ArtemisCloud.io test suite

That is where we found this originally. The pod name had "--" in the middle of the name. We ended up needing to add an init container with a simple script that modified the jolokia-access.xml file.

@brusdev
Copy link
Member

brusdev commented Feb 13, 2023

@davidlanouette your previous test would be good to avoid future regressions, could you add it back?

@davidlanouette
Copy link
Contributor Author

@davidlanouette your previous test would be good to avoid future regressions, could you add it back?

Yes, I'll add it back, but with some tweaks to test the whole file.

@davidlanouette
Copy link
Contributor Author

@jbertram @brusdev

Can I get someone to take a look at this PR again?

I've added a test that will create the full jolokia-access.xml file, then test that it's valid xml.

I'll likely do the same for the other xml files, but in another PR.

Copy link
Member

@brusdev brusdev left a comment

Choose a reason for hiding this comment

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

The test shoud use org.apache.activemq.artemis.utils.XmlProvider to create a DocumentBuilder

@brusdev
Copy link
Member

brusdev commented Feb 16, 2023

There are 57 Checkstyle violations, you can check violations executing mvn clean install -Pdev -DskipTests

@davidlanouette
Copy link
Contributor Author

@brusdev Thanks for the feedback. I'll address the xml DocumentBuilder and the checkstyle violations.

@davidlanouette
Copy link
Contributor Author

@brusdev all issues you pointed out have been resolved.

I think the checks are waiting for someone to approve them. The checks ui shows "This workflow is awaiting approval from a maintainer in #4362"

Copy link
Member

@brusdev brusdev left a comment

Choose a reason for hiding this comment

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

Some suggestions to remove the TODO: Refactor that code to it's own method. comment

@davidlanouette
Copy link
Contributor Author

@brusdev thanks for the feedback. I've incorporated it with the latest commit.

@brusdev
Copy link
Member

brusdev commented Feb 21, 2023

@davidlanouette this PR LGTM, could you rebease your branch and squash your commits?

Previously, the code added a comment with the host name in it.
Sometimes hostnames don't follow the xml standards for comments.
Specifically, having a double dash ("--") in the host name would cause
an error when jolokia tried to load the config file - because it was
invalid xml.

The simple solution was to not put the host name into the comment.

A unit test has been included to ensure the same thing doesn't happen in the
future.

Signed-off-by: David Lanouette <David.Lanouette@RedHat.com>
@davidlanouette
Copy link
Contributor Author

@brusdev Thanks for all the help getting my first PR for this project complete. @jbertram Thanks for your help too.

@brusdev brusdev merged commit 7e1f6c1 into apache:main Feb 22, 2023
@brusdev
Copy link
Member

brusdev commented Feb 22, 2023

@davidlanouette thanks for your contribution.

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