Skip to content

Commit

Permalink
[FLINK-32392][ci] Invalidate Maven repo cache on Azure every year to …
Browse files Browse the repository at this point in the history
…reduce its disk usage
  • Loading branch information
PatrickRen committed Jun 26, 2023
1 parent 43f5d03 commit 9b63099
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ variables:
E2E_CACHE_FOLDER: $(Pipeline.Workspace)/e2e_cache
E2E_TARBALL_CACHE: $(Pipeline.Workspace)/e2e_artifact_cache
MAVEN_ARGS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
PIPELINE_START_YEAR: $[format('{0:yyyy}', pipeline.startTime)]
CACHE_KEY: maven | $(Agent.OS) | **/pom.xml, !**/target/**
CACHE_FALLBACK_KEY: maven | $(Agent.OS)
DOCKER_IMAGES_CACHE_KEY: docker-images-cache | $(Agent.OS) | **/cache_docker_images.sh | flink-test-utils-parent/**/DockerImageVersions.java
Expand Down
1 change: 1 addition & 0 deletions tools/azure-pipelines/build-apache-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ variables:
E2E_CACHE_FOLDER: $(Pipeline.Workspace)/e2e_cache
E2E_TARBALL_CACHE: $(Pipeline.Workspace)/e2e_artifact_cache
MAVEN_ARGS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
PIPELINE_START_YEAR: $[format('{0:yyyy}', pipeline.startTime)]
CACHE_KEY: maven | $(Agent.OS) | **/pom.xml, !**/target/**
CACHE_FALLBACK_KEY: maven | $(Agent.OS)
DOCKER_IMAGES_CACHE_KEY: docker-images-cache | $(Agent.OS) | **/cache_docker_images.sh | flink-test-utils-parent/**/DockerImageVersions.java
Expand Down
8 changes: 4 additions & 4 deletions tools/azure-pipelines/build-nightly-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- task: Cache@2
displayName: Cache Maven local repo
inputs:
key: $(CACHE_KEY)
restoreKeys: $(CACHE_FALLBACK_KEY)
key: $(PIPELINE_START_YEAR) | $(CACHE_KEY)
restoreKeys: $(PIPELINE_START_YEAR) | $(CACHE_FALLBACK_KEY)
path: $(MAVEN_CACHE_FOLDER)
continueOnError: true
- script: |
Expand Down Expand Up @@ -79,8 +79,8 @@ jobs:
- task: Cache@2
displayName: Cache Maven local repo
inputs:
key: $(CACHE_KEY)
restoreKeys: $(CACHE_FALLBACK_KEY)
key: $(PIPELINE_START_YEAR) | $(CACHE_KEY)
restoreKeys: $(PIPELINE_START_YEAR) | $(CACHE_FALLBACK_KEY)
path: $(MAVEN_CACHE_FOLDER)
continueOnError: true
- script: |
Expand Down
4 changes: 2 additions & 2 deletions tools/azure-pipelines/e2e-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
displayName: Create cache directories
- task: Cache@2
inputs:
key: $(CACHE_KEY)
restoreKeys: $(CACHE_FALLBACK_KEY)
key: $(PIPELINE_START_YEAR) | $(CACHE_KEY)
restoreKeys: $(PIPELINE_START_YEAR) | $(CACHE_FALLBACK_KEY)
path: $(MAVEN_CACHE_FOLDER)
displayName: Cache Maven local repo
continueOnError: true
Expand Down
11 changes: 7 additions & 4 deletions tools/azure-pipelines/jobs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ jobs:
# as a key for the build cache (CACHE_KEY). If we have a cache miss on the hash
# (usually because a pom file has changed), we'll fall back to a key without
# the pom files (CACHE_FALLBACK_KEY).
# Note that we use the year number that the pipeline run starts in the cache key,
# which means the cache is invalidated per year, in order to avoid the size of
# cached .m2 directory growing indefinitely.
# Offical documentation of the Cache task: https://docs.microsoft.com/en-us/azure/devops/pipelines/caching/?view=azure-devops
- task: Cache@2
inputs:
key: $(CACHE_KEY)
restoreKeys: $(CACHE_FALLBACK_KEY)
key: $(PIPELINE_START_YEAR) | $(CACHE_KEY)
restoreKeys: $(PIPELINE_START_YEAR) | $(CACHE_FALLBACK_KEY)
path: $(MAVEN_CACHE_FOLDER)
continueOnError: true # continue the build even if the cache fails.
# do not use cache on the "Default" queue
Expand Down Expand Up @@ -118,8 +121,8 @@ jobs:

- task: Cache@2
inputs:
key: $(CACHE_KEY)
restoreKeys: $(CACHE_FALLBACK_KEY)
key: $(PIPELINE_START_YEAR) | $(CACHE_KEY)
restoreKeys: $(PIPELINE_START_YEAR) | $(CACHE_FALLBACK_KEY)
path: $(MAVEN_CACHE_FOLDER)
continueOnError: true # continue the build even if the cache fails.
condition: not(eq('${{parameters.test_pool_definition.name}}', 'Default'))
Expand Down

0 comments on commit 9b63099

Please sign in to comment.