未验证 提交 b4aa9d7d 编写于 作者: J Jesse Glick

Errors from node monitors should be sent to agent logs rather than the system log.

上级 2fbd132b
package hudson.node_monitors;
import hudson.Functions;
import hudson.model.Computer;
import hudson.remoting.Callable;
import hudson.remoting.VirtualChannel;
import hudson.slaves.SlaveComputer;
import jenkins.model.Jenkins;
import javax.annotation.CheckForNull;
......@@ -93,7 +95,7 @@ public abstract class AbstractAsyncNodeMonitorDescriptor<T> extends AbstractNode
futures.put(c,ch.callAsync(cc));
}
} catch (RuntimeException | IOException e) {
LOGGER.log(WARNING, "Failed to monitor "+c.getDisplayName()+" for "+getDisplayName(), e);
error(c, e);
}
}
......@@ -111,7 +113,7 @@ public abstract class AbstractAsyncNodeMonitorDescriptor<T> extends AbstractNode
try {
data.put(c,f.get(Math.max(0,end-System.currentTimeMillis()), MILLISECONDS));
} catch (RuntimeException | TimeoutException | ExecutionException x) {
LOGGER.log(WARNING, "Failed to monitor " + c.getDisplayName() + " for " + getDisplayName(), x);
error(c, x);
}
} else {
skipped.add(c);
......@@ -121,6 +123,14 @@ public abstract class AbstractAsyncNodeMonitorDescriptor<T> extends AbstractNode
return new Result<>(data, skipped);
}
private void error(Computer c, Throwable x) {
if (c instanceof SlaveComputer) {
Functions.printStackTrace(x, ((SlaveComputer) c).getListener().error("Failed to monitor for " + getDisplayName()));
} else {
LOGGER.log(WARNING, "Failed to monitor " + c.getDisplayName() + " for " + getDisplayName(), x);
}
}
private static final Logger LOGGER = Logger.getLogger(AbstractAsyncNodeMonitorDescriptor.class.getName());
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册