Skip to content
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

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

jaskaransarkaria
Copy link
Contributor

@jaskaransarkaria jaskaransarkaria commented Aug 28, 2024

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

@@ -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) {
Copy link
Contributor Author

@jaskaransarkaria jaskaransarkaria Aug 28, 2024

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-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 37.25%. Comparing base (a94794e) to head (e738ed3).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
pkg/cluster/cluster.go 0.00% 10 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@@ -90,16 +90,6 @@ func GetAllNodes(c *client.KubeClient) ([]v1.Node, error) {
return n, nil
}

func getOldestNode(c *client.KubeClient) (v1.Node, error) {
Copy link
Contributor Author

@jaskaransarkaria jaskaransarkaria Aug 29, 2024

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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaskaransarkaria jaskaransarkaria merged commit c4d809a into main Aug 29, 2024
16 of 22 checks passed
@jaskaransarkaria jaskaransarkaria deleted the debug-oldest-node-recycle branch August 29, 2024 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants