HodorNV / ALOps

ALOps
59 stars 24 forks source link

pruneimagesdayscreated and multiple new docker artifacts per day eating space #511

Closed NAVFreak closed 2 years ago

NAVFreak commented 2 years ago

Is your feature request related to a problem? Please describe. I'm not really sure if I'm doing something wrong or if should be like this. The problem is that the docker artifacts are eating my harddrive space

I just started of with ALOps two weeks ago and I have implemented the following settings for the maintenance job: - task: ALOpsAgentMaintenance@1 inputs: removeoldtasks: true removeunusedcontainers: true pruneimagesdayscreated: '5' removebcartifacts: true daysunused: '29'

I don't know if these are good, what settings do you use or consider "best practice"?

The problem that I have is that it downloads multiple docker artifacts for the "same" version every day and eating space. I generally use these docker settings for most of the pipelines: - task: ALOpsDockerCreate@1 displayName: 'ALOPS - Create Docker Image' # It will reuse the image if already exists, or build one if it doesn't. inputs: artifacttype: Sandbox
artifactcountry: 'se'
versionselect: 'secondToLastMajor'

Before I had versionselect = latest but since I experienced the same problem I switched to secondToLastMajor but still have the same problem. Which setting do you use to test against latest version?

Here you can see that is has downloaded several artifacts during the day to the "same version". I'm guessing that it downloads a new image everytime MS builds a new one. image

Here is an image from docker that shows the images: I don't know why most of them doesent show either repository or tag. Perhaps those are the images that couldn't complete due to docker problems (space/memory...) image

Summary: I would like to have answers to following questions:

Describe the solution you'd like Answers to the questions so I can figure if it is normal behaviour or I need to change settings or increase disk space.

Describe alternatives you've considered Increase disk space

waldo1001 commented 2 years ago

Before I had versionselect = latest but since I experienced the same problem I switched to secondToLastMajor but still have the same problem. Which setting do you use to test against latest version?

We are using simply "Latest"

The downside of using "latest" is that MS comes with new sandbox images very frequently.. . So, setting your "daysunused: '29'" is quite high. You can set it way down (1 day?), as you're using new images all the time.

Do know you can also use VersionSelect: Daily or VersionSelect: Weekly. This will make sure it only get a new version once a day or per week. Thay might work as well.

We also make sure the we run the maintenance-job after every single pipeline. This way, we make sure that the clean-job is small, all user build agents are cleaned, and all agents use as less disk space as at all possible.

Hope this helps..

NAVFreak commented 2 years ago

Thank you, that sound great. Btw, I just realized that it is a good idea to make the cleaning setttings use variables 😁

kasperdj commented 2 years ago

@waldo1001 just following along on side here. I understand what you write in the Docker Creation part. Do you have any tips to the maintenance cleanup task to adress these Sandbox images (if the daily where used to created them and thereby we will have multiple container for a major version due to daily builds) as show cased here:

https://user-images.githubusercontent.com/34970096/168959874-49867d70-fc30-4086-a218-f0d36e3e980e.png

Can I do something smart in cleanup besides reducing daysunsed parameter to 1?

waldo1001 commented 2 years ago

Not that I'm aware of.

What would you suggest?

kasperdj commented 2 years ago

Not that I'm aware of.

What would you suggest?

Well what I am aiming for is easy way clean up obsolete sandboxes, all but latest sandbox, as we are currently filling up 400GB of disk space per week per build server, before we on sunday run a powershell script to delete images older that 7 days - as an addition to our maintenance ALOps task, which is currently implemented on half of your pipelines with these settings:

waldo1001 commented 2 years ago

But if you simply run it every day , and set it for 7 days .. AND use the "Daily" setting in stead of "Latest" - isn't that going to help tremendously?

kasperdj commented 2 years ago

I think - lets close the case here