jackMintao commented on code in PR #8936:
URL: https://github.com/apache/hbase/pull/8936#discussion_r4800719567
##########
hbase-server/src/main/resources/hbase-webapps/master/hbck.jsp:
##########
@@ -39,27 +39,37 @@
<%@ page import="org.apache.hadoop.hbase.master.janitor.CatalogJanitorReport"
%>
<%@ page import="java.util.Optional" %>
<%@ page import="org.apache.hadoop.hbase.util.EnvironmentEdgeManager" %>
-<%@ page
import="org.apache.hbase.thirdparty.com.google.protobuf.ServiceException" %>
+<%@ page import="java.io.IOException" %>
+<%@ page import="org.apache.hadoop.hbase.http.InfoServer" %>
<%
final String cacheParameterValue = request.getParameter("cache");
final HMaster master = (HMaster)
getServletContext().getAttribute(HMaster.MASTER);
pageContext.setAttribute("pageTitle", "HBase Master HBCK Report: " +
master.getServerName());
- String hbckChoreErrorMessage = null;
+ final boolean canModifyUI =
+ InfoServer.canUserModifyUI(request, getServletContext(),
master.getConfiguration());
String catalogJanitorErrorMessage = null;
- if (!Boolean.parseBoolean(cacheParameterValue)) {
- // Run the two reporters inline w/ drawing of the page. If exception, will
show in page draw.
- try {
- master.getMasterRpcServices().runHbckChore(null, null);
- } catch (ServiceException se) {
- hbckChoreErrorMessage = "Failed generating a new hbck_chore report;
using cache; try again or run hbck_chore_run in the shell: " + se.getMessage();
- }
- try {
- master.getMasterRpcServices().runCatalogScan(null, null);
- } catch (ServiceException se) {
- catalogJanitorErrorMessage = "Failed generating a new catalogjanitor
report; using cache; try again or run catalogjanitor_run in the shell: " +
se.getMessage();
- }
+ String triggerSkippedMessage = null;
+ final HbckChore hbckChore = master.getHbckChore();
+ final CatalogJanitor cj = master.getCatalogJanitor();
+ if (!Boolean.parseBoolean(cacheParameterValue) && master.isInitialized()) {
+ if (!canModifyUI) {
+ triggerSkippedMessage = "This master UI is read-only or you are not
authorized to modify it; "
+ + "showing cached reports. Run hbck_chore_run and catalogjanitor_run
from the HBase shell "
+ + "as an authorized user to generate new reports.";
+ } else {
+ // Run the two reporters inline w/ drawing of the page. If exception,
will show in page draw.
+ if (hbckChore != null) {
+ hbckChore.runChore();
+ }
+ if (cj != null) {
+ try {
+ cj.scan();
Review Comment:
Agreed — this was not intended. The UI admin list is not HBase ADMIN, and
cj.scan() performs metadata GC.
After the UI gate, the page now checks
AccessChecker.requirePermission(webUser, ..., Permission.Action.ADMIN) for
the
chore actions (via a shared MasterUIAuthorization helper). On
AccessDeniedException
it shows the info message and skips both runChore() and cj.scan().
Added a test with a UI admin that has no HBase ADMIN (uiadmin), plus a normal
user; both assert that the reports are not regenerated (HbckReport /
CatalogJanitorReport unchanged).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]