Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,13 @@ private void doDeleteXXPluginInfo(RangerPluginInfo pluginInfo) {
}
}

public void doDeleteXXPluginInfo(Long id) {
XXPluginInfo xObj = rangerDaoManager.getXXPluginInfo().getById(id);
if (xObj != null) {
rangerDaoManager.getXXPluginInfo().remove(xObj.getId());
}
}

private String getRemoteAddress(final HttpServletRequest request) {
String ret = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2852,6 +2852,48 @@ public RangerPluginInfoList getPluginsInfo(@Context HttpServletRequest request)
return ret;
}

@DELETE
@Path("/plugins/info")
@Produces("application/json")
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public void deletePluginsInfo(@Context HttpServletRequest request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest moving this method to AdminREST.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be done.

LOG.debug("==> ServiceREST.deletePluginsInfo()");

RangerPluginInfoList ret = null;
SearchFilter filter = searchUtil.getSearchFilter(request, pluginInfoService.getSortFields());

try {
PList<RangerPluginInfo> paginatedPluginsInfo = pluginInfoService.searchRangerPluginInfo(filter);
if (paginatedPluginsInfo != null) {
for (RangerPluginInfo rangerPluginInfo : paginatedPluginsInfo.getList()) {
if (rangerPluginInfo != null) {
deletePluginsInfo(rangerPluginInfo.getId());
LOG.debug("Deleted rangerPluginInfo:[{}]", rangerPluginInfo);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a info level log here:

LOG.info("Deleted {} pluginInfo records, for criteria={}", paginatedPluginsInfo.getList().size(), filter);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do in the next patch.

}
} catch (WebApplicationException excp) {
throw excp;
} catch (Throwable excp) {
LOG.error("deletePluginsInfo() failed", excp);

throw restErrorUtil.createRESTException(excp.getMessage());
}

LOG.debug("<== ServiceREST.deletePluginsInfo()");
}

@DELETE
@Path("/plugins/info/{id}")
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public void deletePluginsInfo(@PathParam("id") Long id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to expose ithis method via REST, given id is an internal field (i.e, generated by Ranger/DB)?

Copy link
Contributor Author

@pradeepagrawal8184 pradeepagrawal8184 Oct 3, 2025

Choose a reason for hiding this comment

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

This REST is designed keeping in the mind that option can be exposed in future on the RANGER UI to delete the selected row. Currently there is no option in the UI to delete the stale entries.
If this should not be exposed at all then we can remove the REST part of it and make it private.

if the concern is that such REST APIs should not be there then there are many such APIs which exists in ranger.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok. I suggest to introduce this API when we add UI for this.

LOG.debug("==> ServiceREST.deletePluginsInfo({})", id);

assetMgr.doDeleteXXPluginInfo(id);

LOG.debug("<== ServiceREST.deletePluginsInfo() - [id={}]", id);
}

public void blockIfGdsService(String serviceName) {
String serviceType = daoManager.getXXServiceDef().findServiceDefTypeByServiceName(serviceName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class RangerAPIList {
public static final String GET_POLICY_VERSION_LIST = "ServiceREST.getPolicyVersionList";
public static final String GET_POLICY_FOR_VERSION_NO = "ServiceREST.getPolicyForVersionNumber";
public static final String GET_PLUGINS_INFO = "ServiceREST.getPluginsInfo";
public static final String DELETE_PLUGINS_INFO = "ServiceREST.deletePluginsInfo";
public static final String GET_METRICS_BY_TYPE = "ServiceREST.getMetricByType";
public static final String DELETE_CLUSTER_SERVICES = "ServiceREST.deleteClusterServices";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ private void mapAuditWithAPIs() {
apiAssociatedWithAudit.add(RangerAPIList.GET_POLICY_FROM_EVENT_TIME);
apiAssociatedWithAudit.add(RangerAPIList.GET_POLICY_VERSION_LIST);
apiAssociatedWithAudit.add(RangerAPIList.GET_PLUGINS_INFO);
apiAssociatedWithAudit.add(RangerAPIList.DELETE_PLUGINS_INFO);
apiAssociatedWithAudit.add(RangerAPIList.GET_SERVICE);
apiAssociatedWithAudit.add(RangerAPIList.GET_SERVICE_BY_NAME);
apiAssociatedWithAudit.add(RangerAPIList.GET_SERVICE_DEF);
Expand Down
Loading