Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PauseAction when throttling pipelines #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nickb-carallon
Copy link
Contributor

This change will allow the pipeline UI to show when a stage is throttled, and how long for.

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, Nick! This seems reasonable to me. Could you add a new integration test for this functionality?

@nickb-carallon nickb-carallon changed the title Add PauseAction when throttling pipelines WIP Add PauseAction when throttling pipelines Jul 13, 2021
@nickb-carallon nickb-carallon changed the title WIP Add PauseAction when throttling pipelines Add PauseAction when throttling pipelines Jul 13, 2021
@nickb-carallon
Copy link
Contributor Author

Not sure what went wrong with Jenkins, but the test ran fine locally.

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you start by describing the high-level problem you are trying to solve? What is the current behavior, and what is the desired behavior? I placed a breakpoint after your new call to TestUtil.hasPauseActionForItem(queuedItem), but I don't see any difference in functionality in the UI. I need to understand the high-level problem before I can evaluate the design of the solution and its implementation.

flowNode.addAction(new PauseAction(cause.getShortDescription()));
}
} else {
PauseAction.endCurrentPause(flowNode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PauseAction#endCurrentPause has the following code:

LOGGER.log(Level.FINE, "‘endCurrentPause’ was called for a FlowNode (‘{0}’) that does not have an active pause. ‘endCurrentPause’ may have already been called.", node.getDisplayName());

That code should never get called; it indicates a programming error. Putting a breakpoint here, I see this is getting called a lot with your PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -682,5 +689,26 @@ private int getMaxConcurrentPerNodeBasedOnMatchingLabels(
return maxConcurrentPerNodeLabeledIfMatch;
}

private void updatePauseAction(Task task, CauseOfBlockage cause) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this relate to throttling of Pipeline jobs with a throttle job property rather than a throttle step? Every other usage of new PauseAction that I can find in the jenkinsci organization (e.g. in Lockable Resource, SonarQube, and Pipeline: Input Step) is from a StepExecution. Should this be specific to a throttle step (see ThrottleStep and ThrottleStepExecution)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pause action only applies to stages within a pipeline, so doesn't apply for pipelines using the throttle job property.

@@ -682,5 +689,26 @@ private int getMaxConcurrentPerNodeBasedOnMatchingLabels(
return maxConcurrentPerNodeLabeledIfMatch;
}

private void updatePauseAction(Task task, CauseOfBlockage cause) {
if (task instanceof PlaceholderTask) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

task can also be of type WorkflowJob. Do we need to handle this as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, see above.

@@ -98,6 +98,7 @@ public void onePerNode() throws Exception {
assertThat(
blockageReasons,
hasItem(Messages._ThrottleQueueTaskDispatcher_MaxCapacityOnNode(1).toString()));
TestUtil.hasPauseActionForItem(queuedItem);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion needs to be added to other tests as well, at least in ThrottleStepTest (if not also the other Pipeline tests).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@nickb-carallon
Copy link
Contributor Author

Can you start by describing the high-level problem you are trying to solve? What is the current behavior, and what is the desired behavior? I placed a breakpoint after your new call to TestUtil.hasPauseActionForItem(queuedItem), but I don't see any difference in functionality in the UI. I need to understand the high-level problem before I can evaluate the design of the solution and its implementation.

Thanks for the thorough review! I realise now that PauseAction is only used by stage visualiser plugins (such as pipeline-stage-view-plugin) and it also requires the use of stages in the pipeline. Neither of these are used in the tests which is why you didn't see a change in the UI. I'll rework this PR to resolve your issues and implement a better test for showing the effect of my changes.

@nickb-carallon
Copy link
Contributor Author

I hope I've resolved your questions now. I've also adjusted the throttle step tests so that, if you place a breakpoint, you should see the pipeline stage view indicate that the pipeline is paused.

@nickb-carallon
Copy link
Contributor Author

I've had a look at the failing tests, and they seem to be due to a deadlock between the maintain() call on line 149 of ThrottleJobPropertyPipelineRestartTest.java, and the getNode() call on line 696 of ThrottleQueueTaskDispatcher.java. I'm not sure how to resolve this, is there anyone/anywhere that could help with this issue?

The PauseAction is used by pipeline visualisers (such as
pipeline-stage-view) to indicate when a stage has been paused, and
for how long is was staged for. This can improve the display of
stages timings, as the paused time is removed from the overall stage
time.

The PauseAction only applies to stages, so only applies when the
throttle step is used in conjunction with a pipeline stage.
@nickb-carallon
Copy link
Contributor Author

I've had a look at the failing tests, and they seem to be due to a deadlock between the maintain() call on line 149 of ThrottleJobPropertyPipelineRestartTest.java, and the getNode() call on line 696 of ThrottleQueueTaskDispatcher.java. I'm not sure how to resolve this, is there anyone/anywhere that could help with this issue?

Huh, tests seem to be passing now 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants