Skip to content

RANGER-4458: Usersync Webapp, metrics and Docker changes - #1103

Merged
pradeepagrawal8184 merged 3 commits into
apache:masterfrom
Sanket-Shelar:RANGER-4458-RANGER-5701-RANGER-5702-usersync-webapp
Aug 21, 2026
Merged

RANGER-4458: Usersync Webapp, metrics and Docker changes#1103
pradeepagrawal8184 merged 3 commits into
apache:masterfrom
Sanket-Shelar:RANGER-4458-RANGER-5701-RANGER-5702-usersync-webapp

Conversation

@Sanket-Shelar

@Sanket-Shelar Sanket-Shelar commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Converted usersync to webapp module, added docker changes for usersync webapp and added metrics for usersync.

How was this patch tested?

Manual build passing and tested on docker.


RANGER-4458: Ranger Usersync - Convert to Web Application
RANGER-5701: Support for Usersync as WebApp in docker containers
RANGER-5702: Add/ Update metric details for Ranger UserSync

@kumaab

kumaab commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Please add test scenarios that were tested in docker with this change. thanks.

@Sanket-Shelar

Sanket-Shelar commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Validated the following scenarios in the Docker environment:

UserSync with Unix source — confirmed the existing Unix-based sync flow continues to work as expected.
UserSync with LDAP source — verified LDAP sync using the local OpenLDAP setup.
UserSync metrics APIs — tested the new metrics endpoints and confirmed they respond as expected.
Please let me know if there are any additional scenarios you would like me to cover before this is merged.

@Sanket-Shelar
Sanket-Shelar force-pushed the RANGER-4458-RANGER-5701-RANGER-5702-usersync-webapp branch from 44cc8fb to 8b04499 Compare July 29, 2026 13:19
@Sanket-Shelar
Sanket-Shelar force-pushed the RANGER-4458-RANGER-5701-RANGER-5702-usersync-webapp branch 2 times, most recently from de1d8d3 to 3ac85df Compare July 31, 2026 06:34
@Sanket-Shelar

Copy link
Copy Markdown
Contributor Author

The local build has passed successfully. With the updated patch I have also completed the following testing:

  1. Verified the changes in a Docker environment using both Unix and LDAP sources.
  2. Successfully tested the new usersync metrics APIs.

@Sanket-Shelar
Sanket-Shelar force-pushed the RANGER-4458-RANGER-5701-RANGER-5702-usersync-webapp branch from 3ac85df to dac07aa Compare August 10, 2026 14:59
@Sanket-Shelar
Sanket-Shelar force-pushed the RANGER-4458-RANGER-5701-RANGER-5702-usersync-webapp branch from dac07aa to df2a2ef Compare August 11, 2026 12:13
@pradeepagrawal8184 pradeepagrawal8184 changed the title Usersync Webapp, metrics and Docker changes RANGER-4458: Usersync Webapp, metrics and Docker changes Aug 11, 2026
@pradeepagrawal8184

Copy link
Copy Markdown
Contributor
# Severity Location Issue
1 Critical ranger-usersync-services.sh:100 Log dir check uses literal RANGER_USERSYNC_LOG_DIR instead of "${RANGER_USERSYNC_LOG_DIR}". Directory may never be created.
2 High spring-security.xml:26-36 /api/metrics/** has no security="none" or permitAll. Admin uses <security:http pattern="/service/metrics/**" security="none" />. Metrics scraping may fail or redirect to /login.
3 High MetricCacheUtil.java HashMap counters are written from the sync thread and read from Tomcat/REST threads with no synchronization. Risk of lost updates or corruption.
4 High PolicyMgrUserGroupBuilder.getUserGroupAuditInfo() AUDIT_COUNT_SUCCESS is incremented unconditionally after failures; null responses can also NPE in JsonUtils.jsonToObject().
5 High UserSyncMetricsWrapper.java Missing RangerMetricsContainerSource (KMS adds it explicitly). Tomcat connection/thread metrics won’t appear in Prometheus/JSON output.
6 High ranger_usersync.py Still launches UnixAuthenticationService with lib/* classpath. Ambari/Monarch installs won’t use the new webapp entry point.
7 High ranger-usersync-services.sh VERSION still uses ${cdir}/lib; classpath still includes stale ${cdir}/lib/* after assembly moved jars to ews/lib.

@pradeepagrawal8184 pradeepagrawal8184 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please check the above issues

@kumaab kumaab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Sanket-Shelar for the patch, added few comments.


if [ ! -d RANGER_USERSYNC_LOG_DIR ]; then
mkdir -p $RANGER_USERSYNC_LOG_DIR
chmod 777 $RANGER_USERSYNC_LOG_DIR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

777 gives all perms to everyone, use appropriate perms (minimally required).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checked other scripts in the project and added permission 755

@Sanket-Shelar
Sanket-Shelar force-pushed the RANGER-4458-RANGER-5701-RANGER-5702-usersync-webapp branch from df2a2ef to dfa7430 Compare August 17, 2026 12:11
@Sanket-Shelar

Copy link
Copy Markdown
Contributor Author

Severity Location Issue

1 Critical ranger-usersync-services.sh:100 Log dir check uses literal RANGER_USERSYNC_LOG_DIR instead of "${RANGER_USERSYNC_LOG_DIR}". Directory may never be created.
2 High spring-security.xml:26-36 /api/metrics/** has no security="none" or permitAll. Admin uses <security:http pattern="/service/metrics/**" security="none" />. Metrics scraping may fail or redirect to /login.
3 High MetricCacheUtil.java HashMap counters are written from the sync thread and read from Tomcat/REST threads with no synchronization. Risk of lost updates or corruption.
4 High PolicyMgrUserGroupBuilder.getUserGroupAuditInfo() AUDIT_COUNT_SUCCESS is incremented unconditionally after failures; null responses can also NPE in JsonUtils.jsonToObject().
5 High UserSyncMetricsWrapper.java Missing RangerMetricsContainerSource (KMS adds it explicitly). Tomcat connection/thread metrics won’t appear in Prometheus/JSON output.
6 High ranger_usersync.py Still launches UnixAuthenticationService with lib/* classpath. Ambari/Monarch installs won’t use the new webapp entry point.
7 High ranger-usersync-services.sh VERSION still uses ${cdir}/lib; classpath still includes stale ${cdir}/lib/* after assembly moved jars to ews/lib.

Addressed #1#4, #6, and #7. For #5, we deferred RangerMetricsContainerSource because it depends on Admin/KMS’s server.tomcat.EmbeddedServer, which UserSync does not use; adding it broke Docker startup (NoClassDefFoundError). UserSync API/cache/sync metrics remain available;

}
}

public Map<String, Long> getMetric(MetricType metricType) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Return defensive copies from getMetric()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated getMetric() to return an unmodifiable defensive copy. Introduced a private getInternalMetric() so incrementMetric() continues to update the live maps.

Comment thread unixauthservice/scripts/ranger-usersync-services.sh Outdated
@Sanket-Shelar
Sanket-Shelar force-pushed the RANGER-4458-RANGER-5701-RANGER-5702-usersync-webapp branch from dfa7430 to bd5f684 Compare August 20, 2026 12:34
public Map<String, Long> getMetric(MetricType metricType) {
Map<String, Long> metric = getInternalMetric(metricType);

return metric == null ? null : Map.copyOf(metric);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MetricCacheUtil.getMetric() can return null — RangerUserSyncSourceApis.refresh() would NPE on totalApiCount.keySet(). Safer to return Collections.emptyMap() instead of null.

@pradeepagrawal8184
pradeepagrawal8184 merged commit c5e10da into apache:master Aug 21, 2026
3 of 4 checks passed
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