Skip to content
Permalink
Browse files

Merge branch 'master' into JENKINS-46132

  • Loading branch information
duemir committed Dec 19, 2017
2 parents b28c11e + 1e4d189 commit 735f1b2034000ec32376d08a2d72ddc067bd6d12
Showing with 116 additions and 405 deletions.
  1. +1 −1 Jenkinsfile
  2. +12 −6 pom.xml
  3. +2 −2 src/main/java/com/cloudbees/jenkins/support/AsyncResultCache.java
  4. +1 −2 src/main/java/com/cloudbees/jenkins/support/SupportAction.java
  5. +10 −30 src/main/java/com/cloudbees/jenkins/support/SupportPlugin.java
  6. +2 −9 src/main/java/com/cloudbees/jenkins/support/api/CommandOutputContent.java
  7. +1 −2 src/main/java/com/cloudbees/jenkins/support/api/Component.java
  8. +1 −2 src/main/java/com/cloudbees/jenkins/support/configfiles/AgentsConfigFile.java
  9. +1 −2 src/main/java/com/cloudbees/jenkins/support/configfiles/ConfigFileComponent.java
  10. +1 −2 src/main/java/com/cloudbees/jenkins/support/configfiles/OtherConfigFilesComponent.java
  11. +16 −36 src/main/java/com/cloudbees/jenkins/support/impl/AboutJenkins.java
  12. +2 −3 src/main/java/com/cloudbees/jenkins/support/impl/BuildQueue.java
  13. +1 −6 src/main/java/com/cloudbees/jenkins/support/impl/DumpExportTable.java
  14. +5 −15 src/main/java/com/cloudbees/jenkins/support/impl/EnvironmentVariables.java
  15. +3 −11 src/main/java/com/cloudbees/jenkins/support/impl/FileDescriptorLimit.java
  16. +0 −5 src/main/java/com/cloudbees/jenkins/support/impl/HeapUsageHistogram.java
  17. +2 −14 src/main/java/com/cloudbees/jenkins/support/impl/JenkinsLogs.java
  18. +1 −2 src/main/java/com/cloudbees/jenkins/support/impl/LoadStats.java
  19. +9 −20 src/main/java/com/cloudbees/jenkins/support/impl/Metrics.java
  20. +3 −11 src/main/java/com/cloudbees/jenkins/support/impl/NetworkInterfaces.java
  21. +1 −2 src/main/java/com/cloudbees/jenkins/support/impl/NodeMonitors.java
  22. +1 −2 src/main/java/com/cloudbees/jenkins/support/impl/ProcFilesRetriever.java
  23. +3 −11 src/main/java/com/cloudbees/jenkins/support/impl/RootCAs.java
  24. +2 −4 src/main/java/com/cloudbees/jenkins/support/impl/SlaveLaunchLogs.java
  25. +3 −10 src/main/java/com/cloudbees/jenkins/support/impl/SlaveLogs.java
  26. +4 −98 src/main/java/com/cloudbees/jenkins/support/impl/SmartLogFetcher.java
  27. +2 −9 src/main/java/com/cloudbees/jenkins/support/impl/SystemConfiguration.java
  28. +5 −14 src/main/java/com/cloudbees/jenkins/support/impl/SystemProperties.java
  29. +3 −11 src/main/java/com/cloudbees/jenkins/support/impl/ThreadDumps.java
  30. +11 −20 src/main/java/com/cloudbees/jenkins/support/impl/UpdateCenter.java
  31. +1 −2 src/main/java/com/cloudbees/jenkins/support/slowrequest/SlowRequestChecker.java
  32. +2 −2 src/main/java/com/cloudbees/jenkins/support/slowrequest/SlowRequestFilter.java
  33. +2 −2 src/main/java/com/cloudbees/jenkins/support/timer/DeadlockTrackChecker.java
  34. +0 −28 src/main/java/com/cloudbees/jenkins/support/util/Helper.java
  35. +2 −9 src/main/java/com/cloudbees/jenkins/support/util/SystemPlatform.java
@@ -1 +1 @@
buildPlugin()
buildPlugin(jenkinsVersions: [null, '2.89.1'])
18 pom.xml
@@ -29,7 +29,8 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.23</version>
<version>3.2</version>
<relativePath />
</parent>

<artifactId>support-core</artifactId>
@@ -40,11 +41,11 @@
<description>
This plugin provides a common set of classes to assist in generating support bundles.
</description>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Support+Core+Plugin</url>
<url>https://wiki.jenkins.io/display/JENKINS/Support+Core+Plugin</url>
<licenses>
<license>
<name>The MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>
@@ -63,20 +64,25 @@
<scm>
<connection>scm:git:git://github.com/jenkinsci/support-core-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/support-core-plugin.git</developerConnection>
<url>http://github.com/jenkinsci/support-core-plugin</url>
<url>https://github.com/jenkinsci/support-core-plugin</url>
<tag>HEAD</tag>
</scm>

<properties>
<jenkins.version>2.46.3</jenkins.version>
<java.level>7</java.level>
</properties>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

@@ -26,14 +26,14 @@
private final Node node;
private final String name;

public static <V, T extends java.lang.Throwable> V get(Node node, WeakHashMap<Node, V> cache, Callable<V,T> operation, String name, V defaultIfNull)
public static <V, T extends java.lang.Throwable> V get(Node node, WeakHashMap<Node, V> cache, /*MasterToSlave*/Callable<V,T> operation, String name, V defaultIfNull)

throws IOException {
V result = get(node, cache, operation, name);
return result == null ? defaultIfNull : result;
}

public static <V, T extends java.lang.Throwable> V get(Node node, WeakHashMap<Node, V> cache, Callable<V,T> operation, String name)
public static <V, T extends java.lang.Throwable> V get(Node node, WeakHashMap<Node, V> cache, /*MasterToSlave*/Callable<V,T> operation, String name)

throws IOException {
if (node == null) return null;
@@ -27,7 +27,6 @@
import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.SupportProvider;

import com.cloudbees.jenkins.support.util.Helper;
import hudson.Extension;
import hudson.model.RootAction;
import hudson.security.ACL;
@@ -175,7 +174,7 @@ public void doDownload(StaplerRequest req, StaplerResponse rsp) throws ServletEx

@RequirePOST
public void doGenerateAllBundles(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
final Jenkins instance = Helper.getActiveInstance();
final Jenkins instance = Jenkins.getInstance();
instance.getAuthorizationStrategy().getACL(instance).checkPermission(CREATE_BUNDLE);

JSONObject json = req.getSubmittedForm();
@@ -31,7 +31,6 @@
import com.cloudbees.jenkins.support.api.SupportProvider;
import com.cloudbees.jenkins.support.api.SupportProviderDescriptor;
import com.cloudbees.jenkins.support.impl.ThreadDumps;
import com.cloudbees.jenkins.support.util.Helper;
import com.codahale.metrics.Histogram;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -47,7 +46,6 @@
import hudson.model.Node;
import hudson.model.PeriodicWork;
import hudson.model.TaskListener;
import hudson.remoting.Callable;
import hudson.remoting.Future;
import hudson.remoting.VirtualChannel;
import hudson.security.ACL;
@@ -67,7 +65,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;
import org.jenkinsci.remoting.RoleChecker;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.StaplerRequest;
@@ -102,6 +99,7 @@
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import jenkins.security.MasterToSlaveCallable;

/**
* Main entry point for the support plugin.
@@ -160,7 +158,7 @@ public SupportPlugin() {
public SupportProvider getSupportProvider() {
if (supportProvider == null) {
// if this is not set, pick the first one that we can get our hands on
for (Descriptor<SupportProvider> d : Helper.getActiveInstance().getDescriptorList(SupportProvider.class)) {
for (Descriptor<SupportProvider> d : Jenkins.getInstance().getDescriptorList(SupportProvider.class)) {
if (d instanceof SupportProviderDescriptor) {
try {
supportProvider = ((SupportProviderDescriptor) (d)).newDefaultInstance();
@@ -179,7 +177,7 @@ public SupportProvider getSupportProvider() {
* @return the wrking directory that the support-core plugin uses to write out files.
*/
public static File getRootDirectory() {
return new File(Helper.getActiveInstance().getRootDir(), SUPPORT_DIRECTORY_NAME);
return new File(Jenkins.getInstance().getRootDir(), SUPPORT_DIRECTORY_NAME);
}


@@ -245,7 +243,7 @@ public static void setLogLevel(String level) {
public static void setLogLevel(Level level) {
SupportPlugin instance = getInstance();
instance.handler.setLevel(level);
for (Node n : Helper.getActiveInstance().getNodes()) {
for (Node n : Jenkins.getInstance().getNodes()) {
Computer c = n.toComputer();
if (c == null) {
continue;
@@ -262,11 +260,11 @@ public static void setLogLevel(Level level) {
}

public static SupportPlugin getInstance() {
return Helper.getActiveInstance().getPlugin(SupportPlugin.class);
return Jenkins.getInstance().getPlugin(SupportPlugin.class);
}

public static ExtensionList<Component> getComponents() {
return Helper.getActiveInstance().getExtensionList(Component.class);
return Jenkins.getInstance().getExtensionList(Component.class);
}

public static void writeBundle(OutputStream outputStream) throws IOException {
@@ -609,7 +607,7 @@ private static String getBundlePrefix() {
private static final SupportLogHandler SLAVE_LOG_HANDLER = new SupportLogHandler(256, 2048, 8);
}

private static class LogInitializer implements Callable<Void, RuntimeException> {
private static class LogInitializer extends MasterToSlaveCallable<Void, RuntimeException> {
private static final long serialVersionUID = 1L;
private static final Logger ROOT_LOGGER = Logger.getLogger("");
private final FilePath rootPath;
@@ -640,30 +638,18 @@ public Void call() {
return null;
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}

}

public static class LogFetcher implements Callable<List<LogRecord>, RuntimeException> {
public static class LogFetcher extends MasterToSlaveCallable<List<LogRecord>, RuntimeException> {
private static final long serialVersionUID = 1L;

public List<LogRecord> call() throws RuntimeException {
return new ArrayList<LogRecord>(LogHolder.SLAVE_LOG_HANDLER.getRecent());
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}

}

public static class LogUpdater implements Callable<Void, RuntimeException> {
public static class LogUpdater extends MasterToSlaveCallable<Void, RuntimeException> {

private static final long serialVersionUID = 1L;

@@ -678,12 +664,6 @@ public Void call() throws RuntimeException {
return null;
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}

}

@Extension
@@ -820,7 +800,7 @@ public boolean accept(File dir, String name) {
public static class GlobalConfigurationImpl extends GlobalConfiguration {

public boolean isSelectable() {
return Helper.getActiveInstance().getDescriptorList(SupportProvider.class).size() > 1;
return Jenkins.getInstance().getDescriptorList(SupportProvider.class).size() > 1;
}

public SupportProvider getSupportProvider() {
@@ -3,11 +3,9 @@
import com.cloudbees.jenkins.support.AsyncResultCache;
import com.cloudbees.jenkins.support.SupportLogFormatter;
import hudson.model.Node;
import hudson.remoting.Callable;
import hudson.remoting.VirtualChannel;
import jenkins.model.Jenkins;
import org.apache.commons.io.IOUtils;
import org.jenkinsci.remoting.RoleChecker;

import java.io.IOException;
import java.io.PrintWriter;
@@ -16,6 +14,7 @@
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import jenkins.security.MasterToSlaveCallable;

/**
* Content of a command output. You can only instantiate this content with
@@ -29,7 +28,7 @@ private CommandOutputContent(String name, String value) {
super(name, value);
}

public static class CommandLauncher implements Callable<String, RuntimeException> {
public static class CommandLauncher extends MasterToSlaveCallable<String, RuntimeException> {
final String[] command;

private CommandLauncher(String... command) {
@@ -48,12 +47,6 @@ public String call() {
pw.flush();
return bos.toString();
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}
}

private static String getNodeName(Node node) {
@@ -24,7 +24,6 @@

package com.cloudbees.jenkins.support.api;

import com.cloudbees.jenkins.support.util.Helper;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.security.ACL;
import hudson.security.Permission;
@@ -86,7 +85,7 @@ public String getDisplayPermissions() {
* @return {@code true} if the current authentication can include this component in a bundle.
*/
public boolean isEnabled() {
ACL acl = Helper.getActiveInstance().getAuthorizationStrategy().getRootACL();
ACL acl = Jenkins.getInstance().getAuthorizationStrategy().getRootACL();
if (acl != null) {
Authentication authentication = Jenkins.getAuthentication();
assert authentication != null;
@@ -25,7 +25,6 @@

import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.Container;
import com.cloudbees.jenkins.support.util.Helper;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.security.Permission;
@@ -64,7 +63,7 @@ public String getDisplayName() {

@Override
public void addContents(@NonNull Container container) {
File[] agentDirs = new File(Helper.getActiveInstance().getRootDir(), "nodes").listFiles();
File[] agentDirs = new File(Jenkins.getInstance().getRootDir(), "nodes").listFiles();
if (agentDirs == null) {
return;
}
@@ -2,7 +2,6 @@

import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.Container;
import com.cloudbees.jenkins.support.util.Helper;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.security.Permission;
@@ -34,7 +33,7 @@ public String getDisplayName() {

@Override
public void addContents(@NonNull Container container) {
Jenkins jenkins = Helper.getActiveInstance();
Jenkins jenkins = Jenkins.getInstance();
File configFile = new File(jenkins.getRootDir(), "config.xml");
if (configFile.exists()) {
container.add(
@@ -2,7 +2,6 @@

import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.Container;
import com.cloudbees.jenkins.support.util.Helper;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.security.Permission;
@@ -34,7 +33,7 @@ public String getDisplayName() {

@Override
public void addContents(@NonNull Container container) {
Jenkins jenkins = Helper.getActiveInstance();
Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
File dir = jenkins.getRootDir();
File[] files = dir.listFiles(new FilenameFilter() {

0 comments on commit 735f1b2

Please sign in to comment.
You can’t perform that action at this time.