onnxruntime/tools/ci_build/github/azure-pipelines/clean-build-docker-image-cache-pipeline.yml
Edward Chen b348538c8a
Update build docker image cache cleanup (#6048)
The current image cache cleanup is not removing many images. Upon examining the cache container registry logs, it appears there are some infrequent pulls of old images which may be made by something other than CI builds (perhaps some automated scan of the registry).
This change adds a minimum access count for images in the cache so that infrequently but periodically accessed images can be removed. The idea is that images used by CI builds that are worth caching will have a higher volume of accesses.
2020-12-07 13:07:19 -08:00

40 lines
1.1 KiB
YAML

parameters:
- name: DryRun
type: boolean
default: false
displayName: "Do a dry-run and do not remove any images"
- name: CacheHistoryDays
type: number
default: 7
displayName: "The length of the cache history in days"
- name: CacheMinAccessCount
type: number
default: 5
displayName: "The minimum access count over the cache history"
variables:
${{ if eq(parameters.DryRun, true) }}:
DryRunArgument: "--dry-run"
jobs:
- job: Clean_Build_Docker_Image_Cache
pool:
vmImage: 'ubuntu-18.04'
timeoutInMinutes: 10
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'AIInfraBuild'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
tools/ci_build/clean_docker_image_cache.py \
${{ variables.DryRunArgument }} \
--container-registry $(buildcache-container-registry) \
--log-storage-account $(buildcache-log-storage-account) \
--log-storage-account-container $(buildcache-log-storage-account-container) \
--cache-history-days ${{ parameters.CacheHistoryDays }} \
--cache-min-access-count ${{ parameters.CacheMinAccessCount }}