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

update karpenter manifest management #744

Merged
merged 4 commits into from Feb 7, 2024
Merged

update karpenter manifest management #744

merged 4 commits into from Feb 7, 2024

Conversation

myaser
Copy link
Member

@myaser myaser commented Feb 1, 2024

CLM had the CRDs for karpenter hardcoded.
these strings are used to query k8s api server searching for node pools to be cleaned up
the karpenter API is now upgraded from alpha to beta and thus the CRDs have been renamed and their structure have slightly changed

in this PR is adding support for both versions of karpenter (depends on a config_item)

Signed-off-by: Mahmoud Gaballah <mahmoud.gaballah@zalando.de>
Signed-off-by: Mahmoud Gaballah <mahmoud.gaballah@zalando.de>
Signed-off-by: Mahmoud Gaballah <mahmoud.gaballah@zalando.de>
//if apierrors.IsNotFound(err) {
// // the node pool have been deleted. thus the
// return nil, nil
//}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove commented code

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔
actually, this may manage to mark old karpenter node-pools for decommission.
I will experiment with uncomment it and keep them to see if it makes a difference


func NewLazyOf[T any](newfunc func() (T, error)) *LazyOf[T] {
return &LazyOf[T]{New: newfunc}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not completely clear to me why this lazy initialization is needed. Can't we just initialize when initializing the NodePool backend, or is it because the resources are not applied at that time?

The way to solve that would be to do the resolution whenever there is a need to lookup the CRD resources and not during the setup of the client. Since this is gonna be short lived I think we can keep it like this for now. But I would suggest to remove it long term to simplify the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, it is because the CRDs are not there during the initialization of the backend.

I tried to delay the initialization of the resolver but it was a bit difficult to pass all the parameters across the functions all the way to where it is needed. I thought this was "simpler" 😄

But I would suggest to remove it long term to simplify the code.

yea, sure, we can do this

Signed-off-by: Mahmoud Gaballah <mahmoud.gaballah@zalando.de>
@mikkeloscar
Copy link
Contributor

👍

1 similar comment
@myaser
Copy link
Member Author

myaser commented Feb 7, 2024

👍🏻

@myaser myaser merged commit 5fc91e6 into master Feb 7, 2024
7 of 9 checks passed
@myaser myaser deleted the karpenter-update branch February 7, 2024 13:18
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.

None yet

2 participants