Skip to content

Commit

Permalink
[JENKINS-22639] Don't record changes to AbstractCloudSlaves or Epheme…
Browse files Browse the repository at this point in the history
…ralNodes

This can result in high load when there are nodes coming online and offline quickly.
  • Loading branch information
recampbell committed Apr 15, 2014
1 parent 3a1b0d9 commit e410332
Showing 1 changed file with 15 additions and 4 deletions.
Expand Up @@ -5,6 +5,8 @@
package hudson.plugins.jobConfigHistory;

import hudson.Extension;
import hudson.slaves.EphemeralNode;
import hudson.slaves.AbstractCloudSlave;
import hudson.slaves.ComputerListener;
import hudson.model.Node;
import hudson.model.Slave;
Expand Down Expand Up @@ -49,19 +51,28 @@ public void onConfigurationChange() {
*/
private void onAdd() {
for (Node node : Jenkins.getInstance().getNodes()) {
if (!nodes.contains(node)) {
if (!nodes.contains(node) && isTracked(node)) {
switchHistoryDao(node).createNewNode(node);
return;
}
}
}

/**
* Is this node likely to be important to the user?
* @param node
*/
private boolean isTracked(Node node) {
return node != null &&
! (node instanceof AbstractCloudSlave || node instanceof EphemeralNode);
}

/**
* If a slave get removed.
*/
private void onRemove() {
for (Node node : nodes) {
if (!Jenkins.getInstance().getNodes().contains(node)) {
if (!Jenkins.getInstance().getNodes().contains(node) && isTracked(node)) {
switchHistoryDao(node).deleteNode(node);
return;
}
Expand All @@ -87,7 +98,7 @@ private void onChange() {
private void onRename() {
Node originalNode = null;
for (Node node : nodes) {
if (!Jenkins.getInstance().getNodes().contains(node)) {
if (!Jenkins.getInstance().getNodes().contains(node) && isTracked(node)) {
originalNode = node;
}
}
Expand All @@ -97,7 +108,7 @@ private void onRename() {
}
Node newNode = null;
for (Node node : Jenkins.getInstance().getNodes()) {
if (!nodes.contains(node)) {
if (!nodes.contains(node) && isTracked(node)) {
newNode = node;
}
}
Expand Down

0 comments on commit e410332

Please sign in to comment.