Skip to content

Commit

Permalink
enhance(k8s): pod tracker.TrackContainers can be called more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd committed Apr 12, 2022
1 parent 9f5b86a commit b383384
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions runtime/kubernetes/pod_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,17 @@ func (p podTracker) Start(ctx context.Context) {
}

// TrackContainers creates a containerTracker for each container.
func (p podTracker) TrackContainers(containers []v1.Container) {
ctnTrackers := map[string]*containerTracker{}
func (p *podTracker) TrackContainers(containers []v1.Container) {
if p.Containers == nil {
p.Containers = map[string]*containerTracker{}
}

for _, ctn := range containers {
ctnTrackers[ctn.Name] = &containerTracker{
p.Containers[ctn.Name] = &containerTracker{
Name: ctn.Name,
Terminated: make(chan struct{}),
}
}

p.Containers = ctnTrackers
}

// newPodTracker initializes a podTracker with a given clientset for a given pod.
Expand Down

0 comments on commit b383384

Please sign in to comment.