The case that you mention here is one of many possible cases I can think of the following
Case A
Parent (trigger+block) -> child(label=qwerty)
A1: No nodes online that have label==qwerty
A2: No nodes that have label defined.
Case B
Parent(label=qwerty)(trigger+block) -> child(label=qwerty)
B1: Label qwerty has only one executor which is in use by parent
Case C
Parent(trigger+block) -> child
C1: Master only has 1 executor
This covers the simple cases, however if the parent is a Matrix project, we end up with an even more difficult probelm to solve.
Case D
Parent(x*y configurations) -> x*y matrix builds -> x*y child builds
D1: Less than or equal x*y executors - Child builds cannot run
So to be able to resolve this within the plugin at either configuration or runtime is very difficult.
as we cannot just check if master has a single executor as other factors come into play, regarding Cloud
services and job properties(label, resource, etc) that the child projects require.
Problems:
Configuration time.
Can only check current situation of child projects + Nodes.
Project list might be a parameter, so cannot determine the project list.
Passing a label parameter to child project might affect checking.
Cannot account for any cases where Cloud can allocate nodes.
Runtime
Cannot always garrenttee that a Node could be created for a Cloud instance
Cannot control busy Executors that used by other projects, needed by started build.
Implementation Ideas
Get Node that we are being built on (own node)
(or list of nodes containing all matrix siblings see below)
get Projects to start
get All Nodes
get All Clouds
foreach project + parameter set
#check 1
can it be started on master with parameters?
Yes
does master == ownNode
(
if master.numExecutors > 1 — Can run on master.
)
else
(
if master.numExecutors > 0 — Can run on master.
)
No
// cannot start on master try other Nodes
forEach Node
can it be started on node with parameters?
Yes
does node == ownNode
(
if node.numExecutors > 1 — Can run on node.
)
else
(
if node.numExecutors > 0 — Can run on node.
)
No
// cannot start on master or existing Nodes try Cloud services
forEach Cloud
can Cloud start a required node
Yes
— Can create a node to run on
No
— No possible way that we can continue as we will block.
This should handle most cases, if it can be implemented,
however it assumes that any other builds that are ongoing on any executor
will be able to finish and allow a proposed job to start.
This may fail if the parent build is a Matrix build as this behaviour would not
take into account the jobs siblings which also have similar blocking behaviour.
This could be resolved by
get current build get root build
if these are the same there is no issue
if are different and root build is a matrix we need to find out
where all of child jobs are running/going to run on.
Overall this could be done but is there a need for this?
I feel that it would be better to just add a warning when enabling the
"Block until the triggered projects finish their builds" item that informs
the user that this might occur.
The case that you mention here is one of many possible cases I can think of the following
Case A
Parent (trigger+block) -> child(label=qwerty)
A1: No nodes online that have label==qwerty
A2: No nodes that have label defined.
Case B
Parent(label=qwerty)(trigger+block) -> child(label=qwerty)
B1: Label qwerty has only one executor which is in use by parent
Case C
Parent(trigger+block) -> child
C1: Master only has 1 executor
This covers the simple cases, however if the parent is a Matrix project, we end up with an even more difficult probelm to solve.
Case D
Parent(x*y configurations) -> x*y matrix builds -> x*y child builds
D1: Less than or equal x*y executors - Child builds cannot run
So to be able to resolve this within the plugin at either configuration or runtime is very difficult.
as we cannot just check if master has a single executor as other factors come into play, regarding Cloud
services and job properties(label, resource, etc) that the child projects require.
Problems:
Configuration time.
Can only check current situation of child projects + Nodes.
Project list might be a parameter, so cannot determine the project list.
Passing a label parameter to child project might affect checking.
Cannot account for any cases where Cloud can allocate nodes.
Runtime
Cannot always garrenttee that a Node could be created for a Cloud instance
Cannot control busy Executors that used by other projects, needed by started build.
Implementation Ideas
Get Node that we are being built on (own node)
(or list of nodes containing all matrix siblings see below)
get Projects to start
get All Nodes
get All Clouds
foreach project + parameter set
#check 1
can it be started on master with parameters?
Yes
does master == ownNode
(
if master.numExecutors > 1 — Can run on master.
)
else
(
if master.numExecutors > 0 — Can run on master.
)
No
// cannot start on master try other Nodes
forEach Node
can it be started on node with parameters?
Yes
does node == ownNode
(
if node.numExecutors > 1 — Can run on node.
)
else
(
if node.numExecutors > 0 — Can run on node.
)
No
// cannot start on master or existing Nodes try Cloud services
forEach Cloud
can Cloud start a required node
Yes
— Can create a node to run on
No
— No possible way that we can continue as we will block.
This should handle most cases, if it can be implemented,
however it assumes that any other builds that are ongoing on any executor
will be able to finish and allow a proposed job to start.
This may fail if the parent build is a Matrix build as this behaviour would not
take into account the jobs siblings which also have similar blocking behaviour.
This could be resolved by
get current build get root build
if these are the same there is no issue
if are different and root build is a matrix we need to find out
where all of child jobs are running/going to run on.
Overall this could be done but is there a need for this?
I feel that it would be better to just add a warning when enabling the
"Block until the triggered projects finish their builds" item that informs
the user that this might occur.