Skip to content

Commit

Permalink
fix: Remove invalid label value for last hit timestamp from caches (#…
Browse files Browse the repository at this point in the history
…5528)

Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>
  • Loading branch information
terrytangyuan authored Apr 1, 2021
1 parent 2ba0a43 commit 2b3655e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
3 changes: 0 additions & 3 deletions workflow/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ const (
// LabelKeyOnExit is a label applied to Pods that are run from onExit nodes, so that they are not shut down when stopping a Workflow
LabelKeyOnExit = workflow.WorkflowFullName + "/on-exit"

// LabelKeyCacheLastHitTimestamp is the timestamp when the memoization cache is last hit.
LabelKeyCacheLastHitTimestamp = "last-hit-timestamp"

// ExecutorArtifactBaseDir is the base directory in the init container in which artifacts will be copied to.
// Each artifact will be named according to its input name (e.g: /argo/inputs/artifacts/CODE)
ExecutorArtifactBaseDir = "/argo/inputs/artifacts"
Expand Down
3 changes: 0 additions & 3 deletions workflow/controller/cache/configmap_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"k8s.io/client-go/kubernetes"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/workflow/common"
)

type configMapCache struct {
Expand Down Expand Up @@ -62,7 +61,6 @@ func (c *configMapCache) Load(ctx context.Context, key string) (*Entry, error) {

c.logInfo(log.Fields{}, "config map cache loaded")
hitTime := time.Now()
cm.SetLabels(map[string]string{common.LabelKeyCacheLastHitTimestamp: hitTime.Format(time.RFC3339)})
rawEntry, ok := cm.Data[key]
if !ok || rawEntry == "" {
c.logInfo(log.Fields{}, "config map cache miss: entry does not exist")
Expand Down Expand Up @@ -119,7 +117,6 @@ func (c *configMapCache) Save(ctx context.Context, key string, nodeId string, va
}

creationTime := time.Now()
cache.SetLabels(map[string]string{common.LabelKeyCacheLastHitTimestamp: creationTime.Format(time.RFC3339)})

newEntry := Entry{
NodeID: nodeId,
Expand Down
15 changes: 2 additions & 13 deletions workflow/controller/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import (
"context"
"encoding/json"
"testing"
"time"

"github.com/stretchr/testify/assert"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/workflow/common"
"github.com/argoproj/argo-workflows/v3/workflow/controller/cache"
)

Expand Down Expand Up @@ -55,13 +53,7 @@ func TestConfigMapCacheLoadHit(t *testing.T) {

entry, err := c.Load(ctx, "hi-there-world")
assert.NoError(t, err)

cm, err = controller.kubeclientset.CoreV1().ConfigMaps("default").Get(ctx, sampleConfigMapCacheEntry.Name, metav1.GetOptions{})
assert.NoError(t, err)
lastHitTimestampLabel, err := time.Parse(time.RFC3339, cm.Labels[common.LabelKeyCacheLastHitTimestamp])
assert.NoError(t, err)
assert.True(t, lastHitTimestampLabel.After(entry.CreationTimestamp.Time))
assert.Equal(t, lastHitTimestampLabel.Format(time.RFC3339), entry.LastHitTimestamp.Time.Format(time.RFC3339))
assert.True(t, entry.LastHitTimestamp.Time.After(entry.CreationTimestamp.Time))

outputs := entry.Outputs
assert.NoError(t, err)
Expand Down Expand Up @@ -103,11 +95,8 @@ func TestConfigMapCacheSave(t *testing.T) {
cm, err := controller.kubeclientset.CoreV1().ConfigMaps("default").Get(ctx, "whalesay-cache", metav1.GetOptions{})
assert.NoError(t, err)
assert.NotNil(t, cm)
lastHitTimestampLabel, err := time.Parse(time.RFC3339, cm.Labels[common.LabelKeyCacheLastHitTimestamp])
assert.NoError(t, err)
var entry cache.Entry
err = json.Unmarshal([]byte(cm.Data["hi-there-world"]), &entry)
assert.NoError(t, err)
assert.Equal(t, lastHitTimestampLabel.Format(time.RFC3339), entry.LastHitTimestamp.Time.Format(time.RFC3339))
assert.Equal(t, lastHitTimestampLabel.Format(time.RFC3339), entry.CreationTimestamp.Time.Format(time.RFC3339))
assert.Equal(t, entry.LastHitTimestamp.Time, entry.CreationTimestamp.Time)
}

0 comments on commit 2b3655e

Please sign in to comment.