Skip to content

Commit

Permalink
Merge pull request #3615 from telepresenceio/thallgren/workload-owner…
Browse files Browse the repository at this point in the history
…-recursion

Fix endless recursion when a workload uses the same name as its owner.
  • Loading branch information
thallgren authored Jun 10, 2024
2 parents 4c978b1 + 9368b47 commit f4f2d39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ items:
- version: 2.18.5
date: (TBD)
notes:
- type: bugfix
title: Fix bug in workload cache, causing endless recursion when a workload uses the same name as its owner.
body: >-
The workload cache was keyed by name and namespace, but not by kind, so a workload named the same as its
owner workload would be found using the same key. This led to the workload finding itself when looking up
its owner, which in turn resulted in an endless recursion when searching for the topmost owner.
- type: bugfix
title: FailedScheduling events mentioning node availability considered fatal when waiting for agent to arrive.
body: >-
Expand Down
3 changes: 2 additions & 1 deletion pkg/agentmap/workload_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
type workloadKey struct {
name string
namespace string
kind string
}

type workloadValue struct {
Expand Down Expand Up @@ -71,7 +72,7 @@ func (w workloadCache) gc(ctx context.Context) {

func (w workloadCache) GetWorkload(c context.Context, name, namespace, workloadKind string) (k8sapi.Workload, error) {
dlog.Debugf(c, "GetWorkload(%s,%s,%s)", name, namespace, workloadKind)
wv, _ := w.Compute(workloadKey{name: name, namespace: namespace}, func(wv workloadValue, loaded bool) (workloadValue, bool) {
wv, _ := w.Compute(workloadKey{name: name, namespace: namespace, kind: workloadKind}, func(wv workloadValue, loaded bool) (workloadValue, bool) {
now := time.Now().UnixNano()
if loaded && wv.cTime >= now-int64(w.maxAge) {
return wv, false
Expand Down

0 comments on commit f4f2d39

Please sign in to comment.