Skip to content

Add option to not cache build run when calculating pause duration#313

Merged
sarah-witt merged 3 commits into
masterfrom
sarah/use-create-new
Oct 26, 2022
Merged

Add option to not cache build run when calculating pause duration#313
sarah-witt merged 3 commits into
masterfrom
sarah/use-create-new

Conversation

@sarah-witt

@sarah-witt sarah-witt commented Oct 21, 2022

Copy link
Copy Markdown
Collaborator

What does this PR do?

This PR adds an option to change the way we fetch a build when calculating pause duration as well as whether we cache the run when fetching it. Now, we don't cache our newly calculated run. Additionally, we create a new RunExt instead of potentially using a cached run.

Description of the Change

In some cases, caching the run when calculating it caches the incorrect build url

https://github.com/jenkinsci/pipeline-stage-view-plugin/blob/268cddaa96b69d92c06c994c611e0ef55c1bd1db/rest-api/src/main/java/com/cloudbees/workflow/rest/external/RunExt.java#L299

The create function first checks if there is a cached run, and if there isn't creates a new run and then caches that run. We are just moving away from this function and using createNew to not use the cache.

public static RunExt create(WorkflowRun run) {
        FlowExecution execution = run.getExecution();

        // Use cache if eligible
        boolean isNotRunning = FlowNodeUtil.isNotPartOfRunningBuild(execution);
        if (isNotRunning) {
            RunExt myRun = FlowNodeUtil.getCachedRun(run);
            if (myRun != null) {
                return myRun;
            }
        }
        // Compute the entire flow
        RunExt myRun = createNew(run);
        if (isNotRunning) {
            FlowNodeUtil.cacheRun(run, myRun);
        }
        return myRun;
    }

Alternate Designs

Possible Drawbacks

Verification Process

Confirm we can still calculate the pause duration metric when using the new version of the plugin

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@sarah-witt
sarah-witt marked this pull request as draft October 21, 2022 20:52
@sarah-witt
sarah-witt marked this pull request as ready for review October 21, 2022 21:01
@sarah-witt sarah-witt added the changelog/Fixed Fixed features results into a bug fix version bump label Oct 21, 2022
albertvaka
albertvaka previously approved these changes Oct 22, 2022
@sarah-witt sarah-witt changed the title Don't cache build run when calculating pause duration Add option to not cache build run when calculating pause duration Oct 24, 2022
@sarah-witt sarah-witt added changelog/Added Added features results into a minor version bump and removed changelog/Fixed Fixed features results into a bug fix version bump labels Oct 24, 2022

@albertvaka albertvaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems safe to merge 👌

@sarah-witt
sarah-witt merged commit 88bd965 into master Oct 26, 2022
@sarah-witt
sarah-witt deleted the sarah/use-create-new branch October 26, 2022 16:55
sarah-witt added a commit that referenced this pull request Nov 9, 2022
* Use createNew

* Add option

* Determine what function to use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/Added Added features results into a minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants