Clearing external workspaces during build discard using Fingerprints and Workspace Cleanup plugin

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Clearing external workspaces during build discard using Fingerprints and Workspace Cleanup plugin

Benjamin Beggs-3
I am trying to write a feature update for the Enhanced Old Build Discarder plugin that will trigger the Workspace Cleanup plugin to clear external workspaces set up using the External Workspace Manager plugin by aiming to have it that:
  • When all builds that used a given external workspace are deleted, the workspace is deleted as well.
  • This is determined using build Fingerprints, which contain data indicating the workspace(s) a build made use of.
  • Once no build Fingerprints indicate use of this given workspace, the Workspace Cleanup plugin is triggered to clean it.
These conditions aim to avoid workspace bloat, whereby upstream job workspaces kept for reuse in downstream jobs will not require manual maintenance to avoid indefinite growth in large projects.

I have experimented with monitoring the fingerprints for every individual build, but this has so far been ineffective. It requires that every build in every job in a Jenkins instance be scanned and indexed after every build discard, until it finally reaches the point where no build fingerprints indicate the usage of a given workspace, at which point it can be cleared. This is very resource intensive.

The current implementation I am experimenting with scans all artifact fingerprints after every build discard until it is observed that a given artifact is no longer seen to have been used in a build. Once all the artifacts in workspace have this property, that workspace is cleared with the Workspace Cleanup plugin. This is at least less resource intensive than the previous implementation, though it will still be costly in projects with many artifacts.

Does this implementation seem sensible? Does anyone know of a better one? Also, does anyone know of an existing plugin that scans artifact fingerprint data, and ideally looks at the usage of that artifact? I am finding lacking precedent for these kinds of operations via my own code searches.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/62D0ECD8-B65A-402C-87CE-50345F4BB4D5%40yahoo.com.
Reply | Threaded
Open this post in threaded view
|

Re: Clearing external workspaces during build discard using Fingerprints and Workspace Cleanup plugin

Martin d'Anjou
Hi Ben,

It is indeed expensive to run a scan of fingerprints at the end of every run or a project, esp. when, in the end, no workspace meets the criteria for discard.

I recently found about a plugin called purge job history plugin. It looks like this plugin adds an action to a project, so it would not run at the end of each build, it would run on-demand. So I am thinking that Instead of running a scan of all fingerprints at the end of every run of a job, it may be possible to run the scan at a pre-determined time or on-demand instead. It could even be triggered from a REST API, say once per day or once per week.

Martin

On Sunday, August 11, 2019 at 4:14:59 AM UTC-7, Benjamin Beggs wrote:
I am trying to write a feature update for the Enhanced Old Build Discarder plugin that will trigger the Workspace Cleanup plugin to clear external workspaces set up using the External Workspace Manager plugin by aiming to have it that:
  • When all builds that used a given external workspace are deleted, the workspace is deleted as well.
  • This is determined using build Fingerprints, which contain data indicating the workspace(s) a build made use of.
  • Once no build Fingerprints indicate use of this given workspace, the Workspace Cleanup plugin is triggered to clean it.
These conditions aim to avoid workspace bloat, whereby upstream job workspaces kept for reuse in downstream jobs will not require manual maintenance to avoid indefinite growth in large projects.

I have experimented with monitoring the fingerprints for every individual build, but this has so far been ineffective. It requires that every build in every job in a Jenkins instance be scanned and indexed after every build discard, until it finally reaches the point where no build fingerprints indicate the usage of a given workspace, at which point it can be cleared. This is very resource intensive.

The current implementation I am experimenting with scans all artifact fingerprints after every build discard until it is observed that a given artifact is no longer seen to have been used in a build. Once all the artifacts in workspace have this property, that workspace is cleared with the Workspace Cleanup plugin. This is at least less resource intensive than the previous implementation, though it will still be costly in projects with many artifacts.

Does this implementation seem sensible? Does anyone know of a better one? Also, does anyone know of an existing plugin that scans artifact fingerprint data, and ideally looks at the usage of that artifact? I am finding lacking precedent for these kinds of operations via my own code searches.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/3985a742-be1e-412f-b6f9-99b3ee2dde76%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Clearing external workspaces during build discard using Fingerprints and Workspace Cleanup plugin

Martin d'Anjou
There is a recent thread about this purge job history plugin: https://groups.google.com/forum/#!msg/jenkinsci-dev/OxSNmlyP1dY/PkKPxkvwDgAJ

Martin

On Monday, August 12, 2019 at 10:53:14 AM UTC-7, martinda wrote:
Hi Ben,

It is indeed expensive to run a scan of fingerprints at the end of every run or a project, esp. when, in the end, no workspace meets the criteria for discard.

I recently found about a plugin called <a href="https://github.com/jenkinsci/purge-job-history-plugin" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fpurge-job-history-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuENHtcPG4ycGVBw_E5ETHOPN_HQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fpurge-job-history-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuENHtcPG4ycGVBw_E5ETHOPN_HQ&#39;;return true;">purge job history plugin. It looks like this plugin adds an action to a project, so it would not run at the end of each build, it would run on-demand. So I am thinking that Instead of running a scan of all fingerprints at the end of every run of a job, it may be possible to run the scan at a pre-determined time or on-demand instead. It could even be triggered from a REST API, say once per day or once per week.

Martin

On Sunday, August 11, 2019 at 4:14:59 AM UTC-7, Benjamin Beggs wrote:
I am trying to write a feature update for the Enhanced Old Build Discarder plugin that will trigger the Workspace Cleanup plugin to clear external workspaces set up using the External Workspace Manager plugin by aiming to have it that:
  • When all builds that used a given external workspace are deleted, the workspace is deleted as well.
  • This is determined using build Fingerprints, which contain data indicating the workspace(s) a build made use of.
  • Once no build Fingerprints indicate use of this given workspace, the Workspace Cleanup plugin is triggered to clean it.
These conditions aim to avoid workspace bloat, whereby upstream job workspaces kept for reuse in downstream jobs will not require manual maintenance to avoid indefinite growth in large projects.

I have experimented with monitoring the fingerprints for every individual build, but this has so far been ineffective. It requires that every build in every job in a Jenkins instance be scanned and indexed after every build discard, until it finally reaches the point where no build fingerprints indicate the usage of a given workspace, at which point it can be cleared. This is very resource intensive.

The current implementation I am experimenting with scans all artifact fingerprints after every build discard until it is observed that a given artifact is no longer seen to have been used in a build. Once all the artifacts in workspace have this property, that workspace is cleared with the Workspace Cleanup plugin. This is at least less resource intensive than the previous implementation, though it will still be costly in projects with many artifacts.

Does this implementation seem sensible? Does anyone know of a better one? Also, does anyone know of an existing plugin that scans artifact fingerprint data, and ideally looks at the usage of that artifact? I am finding lacking precedent for these kinds of operations via my own code searches.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/bfb3f282-d957-428e-bc86-eff090d98ac4%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Clearing external workspaces during build discard using Fingerprints and Workspace Cleanup plugin

Benjamin Beggs-3
Great, thank you. I was rethinking an implementation for this and I think the following may be most sensible:
Scan all artifact fingerprints after a regular time interval. If an artifact has no build usage history, it is deleted. If the working directory of the artifact is left empty after this, it is deleted as well.

Wouldn’t this in effect cleanup workspaces? If so it may be doable without a dependency on Workspace Cleanup plugin....

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/520bca36-29be-48d5-b839-760e0567677b%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Clearing external workspaces during build discard using Fingerprints and Workspace Cleanup plugin

Martin d'Anjou
So you are thinking of letting the build discarder plugin do its job, and asynchronously to that, scan the fingerprints to find workspaces, and delete workspaces that no longer have builds. I think this would work.

Martin

On Monday, August 12, 2019 at 4:48:53 PM UTC-7, Benjamin Beggs wrote:
Great, thank you. I was rethinking an implementation for this and I think the following may be most sensible:
Scan all artifact fingerprints after a regular time interval. If an artifact has no build usage history, it is deleted. If the working directory of the artifact is left empty after this, it is deleted as well.

Wouldn’t this in effect cleanup workspaces? If so it may be doable without a dependency on Workspace Cleanup plugin....

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/de33e71a-3378-4880-9e5b-e2801bf222f7%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Clearing external workspaces during build discard using Fingerprints and Workspace Cleanup plugin

Benjamin Beggs-2
I think this is the most resource efficient way of doing this.....I will experiment. It will function separate to the build discard process. It doesn't seem resource efficient to attach the feature to build discards, as far as I can see.

On Tue, Aug 13, 2019 at 1:03 PM martinda <[hidden email]> wrote:
So you are thinking of letting the build discarder plugin do its job, and asynchronously to that, scan the fingerprints to find workspaces, and delete workspaces that no longer have builds. I think this would work.

Martin

On Monday, August 12, 2019 at 4:48:53 PM UTC-7, Benjamin Beggs wrote:
Great, thank you. I was rethinking an implementation for this and I think the following may be most sensible:
Scan all artifact fingerprints after a regular time interval. If an artifact has no build usage history, it is deleted. If the working directory of the artifact is left empty after this, it is deleted as well.

Wouldn’t this in effect cleanup workspaces? If so it may be doable without a dependency on Workspace Cleanup plugin....

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/5vp_JBye3Tk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/de33e71a-3378-4880-9e5b-e2801bf222f7%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAMSuSKT3rmzicPogidtdDnPsR-dj7nwgHsLzx2pz4CBvT7DTKQ%40mail.gmail.com.