-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: 💡 don't lookup oldest unless neeeded #614
Conversation
@@ -51,7 +51,9 @@ type AwsCredentials struct { | |||
|
|||
// NewCluster creates a new Cluster object and populates its | |||
// fields with the values from the Kubernetes cluster in the client passed to it. | |||
func NewCluster(c *client.KubeClient) (*Cluster, error) { | |||
func NewCluster(c *client.KubeClient, recycleOldest bool) (*Cluster, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NewCluster function isn't used by any other components other than recycle-node so it's safe to refactor like this
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #614 +/- ##
==========================================
+ Coverage 37.11% 37.25% +0.13%
==========================================
Files 50 50
Lines 3225 3213 -12
==========================================
Hits 1197 1197
+ Misses 1903 1891 -12
Partials 125 125 ☔ View full report in Codecov by Sentry. |
@@ -90,16 +90,6 @@ func GetAllNodes(c *client.KubeClient) ([]v1.Node, error) { | |||
return n, nil | |||
} | |||
|
|||
func getOldestNode(c *client.KubeClient) (v1.Node, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// RefreshStatus performs a value overwrite of the cluster status. | ||
// This is useful for when the cluster is being updated. | ||
func (c *Cluster) RefreshStatus(client *client.KubeClient) (err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still hitting the error which is caused when the oldest node is a monitoring node, we only care about that when we are recycling nodes and are specifying we want to recycle the oldest node.
We want to be prevented from recycling the oldest node when it's a monitoring node because we only care about recycling nodes with user workloads on.
When we specify which node to recycle it doesn't matter that the oldest one is a monitoring node because we have explicitly specified which node we will recycle, so we can safely bypass checking and throwing the error when we have named the instance to recycle.
Also, remove aa couple of unused function 1, unused function 2
These changes allow me to use the
cloud-platform cluster recycle-node --name foobar-node
command in the cordon and drain pipeline and avoid irrelevant errors