Skip to content

RANGER-5549: replace use of com.kstruct.gethostname4j library#911

Merged
mneethiraj merged 5 commits intoapache:masterfrom
mneethiraj:RANGER-5549
Apr 10, 2026
Merged

RANGER-5549: replace use of com.kstruct.gethostname4j library#911
mneethiraj merged 5 commits intoapache:masterfrom
mneethiraj:RANGER-5549

Conversation

@mneethiraj
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Replaced use of com.kstruct.gethostname4j.Hostname.getHostname() with env variable lookup HOSTNAME or COMPUTERNAME), with fallback to InetAddress.getLocalHost().getHostName().

How was this patch tested?

Using docker setup, verified that plugins report correct hostname in audit logs.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Replaces usage of com.kstruct.gethostname4j for agent hostname detection with environment-variable lookup (HOSTNAME / COMPUTERNAME) and a Java networking fallback, and removes the associated native/JNA dependencies from builds and assemblies.

Changes:

  • Removed gethostname4j and JNA dependencies/version properties from Maven poms and distribution assembly descriptors.
  • Updated RangerRESTUtils to resolve hostname via env vars with fallback to InetAddress.getLocalHost().getHostName().
  • Updated the audit handler unit test to assert that agentHostname is non-blank rather than a hardcoded value.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ranger-presto-plugin-shim/pom.xml Drops gethostname4j dependency from Presto plugin shim module.
ranger-examples/distro/src/main/assembly/sample-client.xml Removes gethostname4j/JNA from the example distro assembly includes.
pom.xml Removes gethostname4j and JNA version properties from the parent pom.
distro/src/main/assembly/usersync.xml Removes gethostname4j/JNA from usersync assembly includes.
distro/src/main/assembly/tagsync.xml Removes gethostname4j/JNA from tagsync assembly includes.
distro/src/main/assembly/storm-agent.xml Removes gethostname4j/JNA from storm agent assembly includes.
distro/src/main/assembly/sample-client.xml Removes gethostname4j/JNA from sample client assembly includes.
distro/src/main/assembly/ranger-tools.xml Removes gethostname4j/JNA from ranger tools assembly includes.
distro/src/main/assembly/plugin-yarn.xml Removes gethostname4j/JNA from yarn plugin assembly includes.
distro/src/main/assembly/plugin-trino.xml Removes gethostname4j/JNA from trino plugin assembly includes.
distro/src/main/assembly/plugin-sqoop.xml Removes gethostname4j/JNA from sqoop plugin assembly includes.
distro/src/main/assembly/plugin-solr.xml Removes gethostname4j/JNA from solr plugin assembly includes.
distro/src/main/assembly/plugin-presto.xml Removes gethostname4j/JNA from presto plugin assembly includes.
distro/src/main/assembly/plugin-ozone.xml Removes gethostname4j/JNA from ozone plugin assembly includes.
distro/src/main/assembly/plugin-kylin.xml Removes gethostname4j/JNA from kylin plugin assembly includes.
distro/src/main/assembly/plugin-kms.xml Removes gethostname4j/JNA from KMS plugin assembly includes.
distro/src/main/assembly/plugin-kafka.xml Removes gethostname4j/JNA from kafka plugin assembly includes.
distro/src/main/assembly/plugin-elasticsearch.xml Removes gethostname4j/JNA from elasticsearch plugin assembly includes.
distro/src/main/assembly/plugin-atlas.xml Removes gethostname4j/JNA from atlas plugin assembly includes.
distro/src/main/assembly/pdp.xml Removes native hostname lookup includes (gethostname4j/JNA) from PDP assembly.
distro/src/main/assembly/knox-agent.xml Removes gethostname4j/JNA from knox agent assembly includes.
distro/src/main/assembly/kms.xml Removes gethostname4j/JNA from kms assembly includes.
distro/src/main/assembly/hive-agent.xml Removes gethostname4j/JNA from hive agent assembly includes.
distro/src/main/assembly/hdfs-agent.xml Removes gethostname4j/JNA from hdfs agent assembly includes.
distro/src/main/assembly/hbase-agent.xml Removes gethostname4j/JNA from hbase agent assembly includes.
distro/src/main/assembly/admin-web.xml Removes gethostname4j/JNA from admin web assembly includes.
agents-common/src/test/java/org/apache/ranger/plugin/audit/TestRangerDefaultAuditHandler.java Adjusts test to validate non-blank agent hostname instead of a fixed value.
agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTUtils.java Implements hostname resolution without gethostname4j and wires it into getAgentHostname().
agents-common/pom.xml Drops gethostname4j and JNA dependencies from agents-common.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mneethiraj mneethiraj merged commit b8eb7b4 into apache:master Apr 10, 2026
3 of 4 checks passed
mneethiraj added a commit that referenced this pull request Apr 10, 2026
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.

4 participants