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

fix(delete): [JENKINS-70252] delete WorkflowRun before WorkflowJob #463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,12 @@
@Override protected void performDelete() throws IOException, InterruptedException {
setDisabled(true);
Jenkins.get().getQueue().cancel(this);

for (WorkflowRun workflowRun : getBuilds()) {
Copy link
Member

Choose a reason for hiding this comment

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

The trouble is that this will make performance worse for those not using artifact-manager-s3 (or those using it in its default and only supported mode, which never deletes artifacts), since loading potentially thousands of WorkflowRun objects from so many little XML files is expensive. Anyway deleting those S3 directories one by one would be inefficient.

Fixing this properly would have to take a different approach I think. https://javadoc.jenkins.io/jenkins/model/ArtifactManager.html#delete() cannot handle this since the whole object is scoped per build. https://javadoc.jenkins.io/jenkins/model/ArtifactManagerFactory.html could have a delete(Job) method, perhaps. Or JCloudsArtifactManager (or something else in the plugin) could check ItemListener.onDeleted and delete the whole directory with one API call.

workflowRun.delete();
}

Check warning on line 669 in src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 667-669 are not covered by tests

// TODO call SCM.processWorkspaceBeforeDeletion

Check warning on line 671 in src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: call SCM.processWorkspaceBeforeDeletion
super.performDelete();
}

Expand Down