Skip to content

Commit

Permalink
return pod if not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanMelnyk113 committed Sep 6, 2023
1 parent c07d4aa commit 917a176
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
7 changes: 7 additions & 0 deletions experiments/castai-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
castai:
apiKey: cd258079422f4845a920fcc17445b99c5b4a48bdf71b8126d5b00ab744bf0097
clusterID: c92acdca-b949-4ca1-b916-442c175245ce

collector:
extraArgs:
send-traffic-delta: true
12 changes: 12 additions & 0 deletions experiments/probemas-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
castai:
apiKey: eac1b1be0be0583199d52698755a2e3f4a9355027b795c3cce9a10d4d6649407
apiURL: https://api-roman.localenv.cast.ai
clusterID: 2d86b1b3-c006-44cc-935e-7156e83814f8

extraArgs:
flush-interval: 10s


collector:
extraArgs:
send-traffic-delta: true
10 changes: 7 additions & 3 deletions kube/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ func (p *PodByIPCache) Get(ip string) (*corev1.Pod, error) {
if len(pods) == 0 {
return nil, ErrNotFound
}
sort.Slice(pods, func(i, j int) bool {
sort.SliceStable(pods, func(i, j int) bool {
return pods[i].(*corev1.Pod).CreationTimestamp.Before(&pods[j].(*corev1.Pod).CreationTimestamp)
})
pod := pods[0]
return pod.(*corev1.Pod), nil
for i := range pods {
if pod := pods[i]; pod != nil {
return pod.(*corev1.Pod), nil
}
}
return nil, ErrNotFound
}

func NewNodeByNameCache(informer cache.SharedIndexInformer) *NodeByNameCache {
Expand Down

0 comments on commit 917a176

Please sign in to comment.