From 48aca5bd781e94daedcfc0760b4d0467a22e9028 Mon Sep 17 00:00:00 2001
From: "Yuan (Bob) Gong" <gongyuan94@gmail.com>
Date: Mon, 27 Apr 2020 10:55:28 +0800
Subject: [PATCH] [Caching] Add a cached label for cached pods (#3623)

* Update mutation.go

* Update mutation.go

* Update mutation.go

* Update mutation.go
---
 backend/src/cache/server/mutation.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/backend/src/cache/server/mutation.go b/backend/src/cache/server/mutation.go
index 6b35f82c1ee4..201c4a23434c 100644
--- a/backend/src/cache/server/mutation.go
+++ b/backend/src/cache/server/mutation.go
@@ -34,6 +34,8 @@ import (
 const (
 	KFPCacheEnabledLabelKey   string = "pipelines.kubeflow.org/cache_enabled"
 	KFPCacheEnabledLabelValue string = "true"
+	KFPCachedLabelKey         string = "pipelines.kubeflow.org/reused_from_cache"
+	KFPCachedLabelValue       string = "true"
 	ArgoWorkflowNodeName      string = "workflows.argoproj.io/node-name"
 	ArgoWorkflowTemplate      string = "workflows.argoproj.io/template"
 	ExecutionKey              string = "pipelines.kubeflow.org/execution_cache_key"
@@ -124,6 +126,9 @@ func MutatePodIfCached(req *v1beta1.AdmissionRequest, clientMgr ClientManagerInt
 
 		annotations[ArgoWorkflowOutputs] = getValueFromSerializedMap(cachedExecution.ExecutionOutput, ArgoWorkflowOutputs)
 		labels[CacheIDLabelKey] = strconv.FormatInt(cachedExecution.ID, 10)
+		labels[KFPCachedLabelKey] = KFPCachedLabelValue // This label indicates the pod is taken from cache.
+		
+		// These labels cache results for metadata-writer.
 		labels[MetadataExecutionIDKey] = getValueFromSerializedMap(cachedExecution.ExecutionOutput, MetadataExecutionIDKey)
 		labels[MetadataWrittenKey] = "true"