Skip to content
Permalink
Browse files

Merge pull request #3254 from jglick/heavyweight-JENKINS-46652

[JENKINS-46652] Check Computer.BUILD permission only on heayweight tasks
  • Loading branch information
jglick committed Mar 9, 2018
2 parents c84cbf3 + 50878a3 commit 1f4f76ffcae89938aa9b95c23c025da3706d7150
@@ -62,6 +62,7 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import jenkins.util.io.OnMaster;
import net.sf.json.JSONObject;
import org.acegisecurity.Authentication;
@@ -97,6 +98,9 @@

private static final Logger LOGGER = Logger.getLogger(Node.class.getName());

/** @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-46652">JENKINS-46652</a> */
public static /* not final */ boolean SKIP_BUILD_CHECK_ON_FLYWEIGHTS = SystemProperties.getBoolean(Node.class.getName() + ".SKIP_BUILD_CHECK_ON_FLYWEIGHTS", true);

/**
* Newly copied agents get this flag set, so that Jenkins doesn't try to start/remove this node until its configuration
* is saved once.
@@ -395,7 +399,7 @@ public CauseOfBlockage canTake(Queue.BuildableItem item) {
}

Authentication identity = item.authenticate();
if (!hasPermission(identity,Computer.BUILD)) {
if (!(SKIP_BUILD_CHECK_ON_FLYWEIGHTS && item.task instanceof Queue.FlyweightTask) && !hasPermission(identity, Computer.BUILD)) {
// doesn't have a permission
return CauseOfBlockage.fromMessage(Messages._Node_LackingBuildPermission(identity.getName(), getDisplayName()));
}
@@ -134,7 +134,7 @@ public boolean canAccept(WorkChunk c) {
if (c.assignedLabel!=null && !c.assignedLabel.contains(node))
return false; // label mismatch

if (!nodeAcl.hasPermission(item.authenticate(), Computer.BUILD))
if (!(Node.SKIP_BUILD_CHECK_ON_FLYWEIGHTS && item.task instanceof Queue.FlyweightTask) && !nodeAcl.hasPermission(item.authenticate(), Computer.BUILD))
return false; // tasks don't have a permission to run on this node

return true;

0 comments on commit 1f4f76f

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