Skip to content

Commit

Permalink
perf: ⚡️ call GetAllNodes once (#613)
Browse files Browse the repository at this point in the history
* perf: ⚡️ call GetAllNodes once
  • Loading branch information
jaskaransarkaria committed Aug 28, 2024
1 parent 6568252 commit 28268c7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewCluster(c *client.KubeClient) (*Cluster, error) {
return nil, err
}

oldestNode, err := getOldestNode(c)
oldestNode, err := oldestNode(nodes)
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/cluster/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func GetAllNodes(c *client.KubeClient) ([]v1.Node, error) {
return n, nil
}

// getOldestNode returns the oldest node in a cluster
func getOldestNode(c *client.KubeClient) (v1.Node, error) {
nodes, err := GetAllNodes(c)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/util/testutils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"fmt"
"os"
"strings"
"testing"
Expand All @@ -14,7 +13,7 @@ func FileContainsString(t *testing.T, filename string, searchString string) {
}

if !(strings.Contains(string(contents), searchString)) {
t.Errorf(fmt.Sprintf("Didn't find string: %s in file: %s", searchString, filename))
t.Errorf("Didn't find string: %s in file: %s", searchString, filename)
}
}

Expand Down

0 comments on commit 28268c7

Please sign in to comment.