Skip to content
Permalink
Browse files
Merge pull request #2546 from daniel-beck/configurable-admin-monitors
[FIX JENKINS-38301] Add configuration for disabling admin monitors
  • Loading branch information
daniel-beck committed Sep 20, 2016
2 parents 38de41d + 0fc375e commit 123d22493107ef29e14ef26acc2974c918f93657
Showing with 206 additions and 1 deletion.
  1. +10 −0 core/src/main/java/hudson/PluginManager.java
  2. +5 −0 core/src/main/java/hudson/PluginWrapper.java
  3. +5 −0 core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java
  4. +5 −0 core/src/main/java/hudson/diagnosis/ReverseProxySetupMonitor.java
  5. +6 −0 core/src/main/java/hudson/diagnosis/TooManyJobsButNoView.java
  6. +6 −0 core/src/main/java/hudson/model/UpdateCenter.java
  7. +5 −0 core/src/main/java/hudson/node_monitors/MonitorMarkedNodeOffline.java
  8. +6 −0 core/src/main/java/hudson/triggers/SCMTrigger.java
  9. +6 −0 core/src/main/java/jenkins/diagnostics/CompletedInitializationMonitor.java
  10. +6 −0 core/src/main/java/jenkins/diagnostics/SecurityIsOffMonitor.java
  11. +56 −0 core/src/main/java/jenkins/management/AdministrativeMonitorsConfiguration.java
  12. +5 −0 core/src/main/java/jenkins/model/DownloadSettings.java
  13. +1 −1 core/src/main/java/jenkins/security/s2m/AdminCallableMonitor.java
  14. +5 −0 core/src/main/java/jenkins/security/s2m/MasterKillSwitchWarning.java
  15. +5 −0 core/src/main/resources/hudson/Messages.properties
  16. +4 −0 core/src/main/resources/hudson/diagnosis/Messages.properties
  17. +2 −0 core/src/main/resources/hudson/model/Messages.properties
  18. +1 −0 core/src/main/resources/hudson/node_monitors/Messages.properties
  19. +1 −0 core/src/main/resources/hudson/triggers/Messages.properties
  20. +2 −0 core/src/main/resources/jenkins/diagnostics/Messages.properties
  21. +55 −0 core/src/main/resources/jenkins/management/AdministrativeMonitorsConfiguration/config.groovy
  22. +5 −0 core/src/main/resources/jenkins/management/AdministrativeMonitorsConfiguration/config.properties
  23. +2 −0 core/src/main/resources/jenkins/model/Messages.properties
  24. +2 −0 core/src/main/resources/jenkins/security/s2m/Messages.properties
@@ -1950,6 +1950,11 @@ public String getExceptionString() {
@Extension @Symbol("pluginCycleDependencies")
public static final class PluginCycleDependenciesMonitor extends AdministrativeMonitor {

@Override
public String getDisplayName() {
return Messages.PluginManager_PluginCycleDependenciesMonitor_DisplayName();
}

private transient volatile boolean isActive = false;

private transient volatile List<PluginWrapper> pluginsWithCycle;
@@ -2009,6 +2014,11 @@ public boolean isActivated() {
return !pluginsToBeUpdated.isEmpty();
}

@Override
public String getDisplayName() {
return Messages.PluginManager_PluginUpdateMonitor_DisplayName();
}

/**
* adds a message about a plugin to the manage screen
* @param pluginName the plugins name
@@ -748,6 +748,11 @@ public boolean isActivated() {
return !plugins.isEmpty();
}

@Override
public String getDisplayName() {
return Messages.PluginWrapper_PluginWrapperAdministrativeMonitor_DisplayName();
}

public Collection<PluginWrapper> getPlugins() {
return plugins.values();
}
@@ -50,6 +50,11 @@
@Extension @Symbol("nullId")
public class NullIdDescriptorMonitor extends AdministrativeMonitor {

@Override
public String getDisplayName() {
return Messages.NullIdDescriptorMonitor_DisplayName();
}

private final List<Descriptor> problems = new ArrayList<Descriptor>();

@Override
@@ -93,5 +93,10 @@ public HttpResponse doAct(@QueryParameter String no) throws IOException {
return new HttpRedirect("https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+says+my+reverse+proxy+setup+is+broken");
}
}

@Override
public String getDisplayName() {
return Messages.ReverseProxySetupMonitor_DisplayName();
}
}

@@ -42,6 +42,12 @@
*/
@Extension @Symbol("tooManyJobsButNoView")
public class TooManyJobsButNoView extends AdministrativeMonitor {

@Override
public String getDisplayName() {
return Messages.TooManyJobsButNoView_DisplayName();
}

public boolean isActivated() {
Jenkins h = Jenkins.getInstance();
return h.getViews().size()==1 && h.getItemMap().size()> THRESHOLD;
@@ -986,6 +986,12 @@ private static String getCategoryDisplayName(String category) {
*/
@Extension @Symbol("coreUpdate")
public static final class CoreUpdateMonitor extends AdministrativeMonitor {

@Override
public String getDisplayName() {
return Messages.UpdateCenter_CoreUpdateMonitor_DisplayName();
}

public boolean isActivated() {
Data data = getData();
return data!=null && data.hasCoreUpdates();
@@ -37,6 +37,11 @@
*/
@Extension
public class MonitorMarkedNodeOffline extends AdministrativeMonitor {
@Override
public String getDisplayName() {
return Messages.MonitorMarkedNodeOffline_DisplayName();
}

public boolean active = false;

public boolean isActivated() {
@@ -349,6 +349,12 @@ public FormValidation doCheckPollingThreadCount(@QueryParameter String value) {

@Extension
public static final class AdministrativeMonitorImpl extends AdministrativeMonitor {

@Override
public String getDisplayName() {
return Messages.SCMTrigger_AdministrativeMonitorImpl_DisplayName();
}

private boolean on;

public boolean isActivated() {
@@ -40,6 +40,12 @@
@Restricted(NoExternalUse.class)
@Extension @Symbol("completedInitialization")
public class CompletedInitializationMonitor extends AdministrativeMonitor {

@Override
public String getDisplayName() {
return Messages.CompletedInitializationMonitor_DisplayName();
}

@Override
public boolean isActivated() {
final Jenkins instance = Jenkins.getInstance();
@@ -20,6 +20,12 @@
*/
@Extension @Symbol("securityIsOff")
public class SecurityIsOffMonitor extends AdministrativeMonitor {

@Override
public String getDisplayName() {
return Messages.SecurityIsOffMonitor_DisplayName();
}

@Override
public boolean isActivated() {
return !Jenkins.getInstance().isUseSecurity();
@@ -0,0 +1,56 @@
/*
* The MIT License
*
* Copyright (c) 2016, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package jenkins.management;

import hudson.Extension;
import hudson.model.AdministrativeMonitor;
import jenkins.model.GlobalConfiguration;
import net.sf.json.JSONObject;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.StaplerRequest;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

@Extension
@Restricted(NoExternalUse.class)
public class AdministrativeMonitorsConfiguration extends GlobalConfiguration {
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
for (AdministrativeMonitor am : AdministrativeMonitor.all()) {
try {
boolean disable = !json.getJSONArray("administrativeMonitor").contains(am.id);
am.disable(disable);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to process form submission for " + am.id, e);
}
}
return true;
}

private static Logger LOGGER = Logger.getLogger(AdministrativeMonitorsConfiguration.class.getName());
}
@@ -138,6 +138,11 @@ public DailyCheck() {

@Extension public static final class Warning extends AdministrativeMonitor {

@Override
public String getDisplayName() {
return Messages.DownloadSettings_Warning_DisplayName();
}

@Override public boolean isActivated() {
return DownloadSettings.get().isUseBrowser();
}
@@ -39,7 +39,7 @@ public boolean isActivated() {

@Override
public String getDisplayName() {
return "Agent \u2192 Master Access Control";
return Messages.AdminCallableMonitor_DisplayName();
}

// bind this to URL
@@ -28,6 +28,11 @@ public boolean isActivated() {
return rule.getMasterKillSwitch() && config.isRelevant();
}

@Override
public String getDisplayName() {
return Messages.MasterKillSwitchWarning_DisplayName();
}

public HttpResponse doAct(@QueryParameter String dismiss) throws IOException {
if(dismiss!=null) {
disable(true);
@@ -61,6 +61,8 @@ PluginManager.UploadPluginsPermission.Description=\
PluginManager.ConfigureUpdateCenterPermission.Description=\
The "configure update center" permission allows a user to \
configure update sites and proxy settings.
PluginManager.PluginCycleDependenciesMonitor.DisplayName=Cyclic Dependencies Detector
PluginManager.PluginUpdateMonitor.DisplayName=Invalid Plugin Configuration

AboutJenkins.DisplayName=About Jenkins
AboutJenkins.Description=See the version and license information.
@@ -80,4 +82,7 @@ PluginWrapper.disabledAndObsolete={0} v{1} is disabled and older than required.
PluginWrapper.disabled={0} is disabled. To fix, enable it.
PluginWrapper.obsolete={0} v{1} is older than required. To fix, install v{2} or later.
PluginWrapper.obsoleteCore=You must update Jenkins from v{0} to v{1} or later to run this plugin.
PluginWrapper.PluginWrapperAdministrativeMonitor.DisplayName=Plugins Failed To Load

TcpSlaveAgentListener.PingAgentProtocol.displayName=Ping protocol

@@ -3,3 +3,7 @@ MemoryUsageMonitor.TOTAL=Total
OldDataMonitor.Description=Scrub configuration files to remove remnants from old plugins and earlier versions.
OldDataMonitor.DisplayName=Manage Old Data
HudsonHomeDiskUsageMonitor.DisplayName=Disk Usage Monitor

NullIdDescriptorMonitor.DisplayName=Missing Descriptor ID
ReverseProxySetupMonitor.DisplayName=Reverse Proxy Setup
TooManyJobsButNoView.DisplayName=Too Many Jobs Not Organized in Views
@@ -272,6 +272,8 @@ UpdateCenter.Status.ConnectionFailed=\
<span class=error>Failed to connect to {0}. \
Perhaps you need to <a href="../pluginManager/advanced">configure HTTP proxy?</a></span>
UpdateCenter.init=Initialing update center
UpdateCenter.CoreUpdateMonitor.DisplayName=Jenkins Update Notification

UpdateCenter.PluginCategory.android=Android Development
UpdateCenter.PluginCategory.builder=Build Tools
UpdateCenter.PluginCategory.buildwrapper=Build Wrappers
@@ -32,3 +32,4 @@ SwapSpaceMonitor.DisplayName=Free Swap Space
TemporarySpaceMonitor.DisplayName=Free Temp Space
AbstractNodeMonitorDescriptor.NoDataYet=Not yet
DiskSpaceMonitorDescriptor.DiskSpace.FreeSpaceTooLow=Disk space is too low. Only {0}GB left on {1}.
MonitorMarkedNodeOffline.DisplayName=Node Marked Offline Due to Health Check
@@ -30,3 +30,4 @@ TimerTrigger.no_schedules_so_will_never_run=No schedules so will never run
TimerTrigger.TimerTriggerCause.ShortDescription=Started by timer
TimerTrigger.would_last_have_run_at_would_next_run_at=Would last have run at {0}; would next run at {1}.
Trigger.init=Initializing timer for triggers
SCMTrigger.AdministrativeMonitorImpl.DisplayName=Too Many SCM Polling Threads
@@ -0,0 +1,2 @@
CompletedInitializationMonitor.DisplayName=Jenkins Initialization Monitor
SecurityIsOffMonitor.DisplayName=Disabled Security
@@ -0,0 +1,55 @@
/*
* The MIT License
*
* Copyright (c) 2016, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package jenkins.management.AdministrativeMonitorsConfiguration

import hudson.model.AdministrativeMonitor

f = namespace(lib.FormTagLib)
st = namespace("jelly:stapler")

f.section(title: _("Administrative monitors configuration")) {
f.advanced(title: _("Administrative monitors")) {
f.entry(title: _("Enabled administrative monitors")) {
p(_("blurb"))
table(width: "100%") {
for (AdministrativeMonitor am : AdministrativeMonitor.all()) {
f.block() {
f.checkbox(name: "administrativeMonitor",
title: am.displayName,
checked: am.enabled,
json: am.id);
}
tr() {
td(colspan: "2");
td(class: "setting-description") {
st.include(from: am, page: "description", optional: true);
}
td();
}
}
}
}
}
}
@@ -0,0 +1,5 @@
blurb = Administrative monitors are warnings shown to Jenkins administrators \
about the state of the Jenkins instance. It is generally strongly \
recommended to keep all administrative monitors enabled, but if you are \
not interested in specific warnings, uncheck them here to permanently \
hide them.
@@ -68,3 +68,5 @@ ParameterizedJobMixIn.build_now=Build Now
BlockedBecauseOfBuildInProgress.shortDescription=Build #{0} is already in progress{1}
BlockedBecauseOfBuildInProgress.ETA=\ (ETA:{0})
BuildDiscarderProperty.displayName=Discard old builds

DownloadSettings.Warning.DisplayName=Browser-based metadata download
@@ -0,0 +1,2 @@
AdminCallableMonitor.DisplayName=Rejected Agent \u2192 Master Access Attempt
MasterKillSwitchWarning.DisplayName=Disabled Agent \u2192 Master Access Control

0 comments on commit 123d224

Please sign in to comment.