Skip to content

Commit

Permalink
HBASE-26160: Configurable disallowlist for live editing of loglevels
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeaudreault committed Aug 1, 2021
1 parent b248730 commit 156fd05
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
String logName = ServletUtil.getParameter(request, "log");
String level = ServletUtil.getParameter(request, "level");

String[] readOnlyLogLevels = conf.getStrings("hbase.ui.readonly.logLevels");

if (logName != null) {
out.println("<p>Results:</p>");
out.println(MARKER
Expand All @@ -345,6 +347,12 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
out.println(MARKER
+ "Log Class: <b>" + log.getClass().getName() +"</b><br />");
if (level != null) {
if (!isLogLevelChangeAllowed(logName, readOnlyLogLevels)) {
response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED,
"Modification of logger " + logName + " not allowed.");
return;
}

out.println(MARKER + "Submitted Level: <b>" + level + "</b><br />");
}
process(log, level, out);
Expand All @@ -360,6 +368,18 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
out.close();
}

private boolean isLogLevelChangeAllowed(String logger, String[] readOnlyLogLevels) {
if (readOnlyLogLevels == null) {
return true;
}
for (String readOnlyLogLevel : readOnlyLogLevels) {
if (readOnlyLogLevel.equals(logger)) {
return false;
}
}
return true;
}

static final String FORMS = "<div class='container-fluid content'>\n"
+ "<div class='row inner_header'>\n" + "<div class='page-header'>\n"
+ "<h1>Get/Set Log Level</h1>\n" + "</div>\n" + "</div>\n" + "Actions:" + "<p>"
Expand Down

0 comments on commit 156fd05

Please sign in to comment.