From 5fbf2249fbd95185ebc9d2a7c0dfc7007a5cc3c2 Mon Sep 17 00:00:00 2001 From: Alexey Volkov Date: Mon, 22 Mar 2021 22:30:43 -0700 Subject: [PATCH] fix(backend): Caching - Make the cache key depend on output names and paths (#4675) * Caching - Make the cache key depend on output names and paths Output artifact/parameter names and paths are important and need to be considered. * Fixed the test --- backend/src/cache/server/mutation.go | 1 + backend/src/cache/server/mutation_test.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/cache/server/mutation.go b/backend/src/cache/server/mutation.go index 899cdcdef3..de59dae388 100644 --- a/backend/src/cache/server/mutation.go +++ b/backend/src/cache/server/mutation.go @@ -220,6 +220,7 @@ func generateCacheKeyFromTemplate(template string) (string, error) { "volumeMounts": nil, }, "inputs": nil, + "outputs": nil, // Output artifact/parameter names and paths are important and need to be considered. We can include the whole section since Argo does not seem to put the artifact s3 specifications here, leaving them in archiveLocation. "volumes": nil, "initContainers": nil, "sidecars": nil, diff --git a/backend/src/cache/server/mutation_test.go b/backend/src/cache/server/mutation_test.go index d8469e94f8..9252a7a884 100644 --- a/backend/src/cache/server/mutation_test.go +++ b/backend/src/cache/server/mutation_test.go @@ -205,9 +205,9 @@ func TestSetImage(t *testing.T) { func TestMutatePodIfCachedWithTeamplateCleanup(t *testing.T) { executionCache := &model.ExecutionCache{ - ExecutionCacheKey: "f5fe913be7a4516ebfe1b5de29bcb35edd12ecc776b2f33f10ca19709ea3b2f0", + ExecutionCacheKey: "5a20e3f2e74863b363291953082d9812a58e25f7117bface1c76d40ef0ee88fc", ExecutionOutput: "testOutput", - ExecutionTemplate: `Cache key was calculated from this: {"container":{"command":["echo", "Hello"],"image":"python:3.7"}}`, + ExecutionTemplate: `Cache key was calculated from this: {"container":{"command":["echo", "Hello"],"image":"python:3.7"},"outputs":"anything"}`, MaxCacheStaleness: -1, } fakeClientManager.CacheStore().CreateExecutionCache(executionCache)