-
Notifications
You must be signed in to change notification settings - Fork 288
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
curated packages full cluster lifecycle adaptations #4970
Conversation
/hold |
Related to aws/eks-anywhere-packages#807 |
Codecov Report
@@ Coverage Diff @@
## main #4970 +/- ##
==========================================
+ Coverage 72.24% 72.30% +0.05%
==========================================
Files 435 435
Lines 35518 35659 +141
==========================================
+ Hits 25661 25782 +121
- Misses 8316 8332 +16
- Partials 1541 1545 +4
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
7eca270
to
e9e5017
Compare
66630e5
to
d0f3cf1
Compare
d3329a0
to
412df1e
Compare
/unhold |
412df1e
to
b932576
Compare
49428fa
to
14609e3
Compare
14609e3
to
3be6109
Compare
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.
looks good from the perspective of the RBAC configuration scope!
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ewollesen The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
// resources, which will trigger the curated packages controller to do the | ||
// rest. | ||
// | ||
// +kubebuilder:rbac:groups=packages.eks.amazonaws.com,resources=packagebundlecontrollers,verbs=create;delete;get;list;patch;update;watch; |
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.
What is the purpose of adding this comment then? Generally we don't need to backport to legacy controller anyways.
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.
This was the only place I found to add these comments that was actually reflected in the final output. Can you suggest a better place to put them?
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.
This file is for the old controller, so I would suggest to try in cluster_controller.go. Or if it's not applicable then omit.
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'll try again, but the last time I made modifications there, they plain just didn't show up... Which seemed weird, but maybe I was using the wrong makefile target... or something.
pkg/api/v1alpha1/cluster_types.go
Outdated
// IsPackagesEnabled checks if the configuration supports curated packages | ||
// installation. | ||
func (c *Cluster) IsPackagesEnabled() bool { | ||
return !c.IsSelfManaged() && (c.Spec.Packages == nil || !c.Spec.Packages.Disable) |
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.
This is confusing to me then, why is there a method for IsPackagesEnabled
then? That makes it sound like it should apply for any cluster that has packages enabled or not, regardless of if it's handled by the CLI.
Is IsPackagesSupported
a better name based on the comment? I think understanding the use case better will help explain it.
chart *releasev1.Image | ||
chartInstaller ChartInstaller | ||
// deleter handles helm chart install deletion. | ||
deleter ChartInstallationDeleter |
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.
Can we just call this ChartUninstaller
?
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 guess? Helm has weird wording for a chart installation or whatever. I guess I don't have a strong feeling on it, it's just all confusing.
// | ||
// This method fills in the gaps between the original CLI use case, where all | ||
// information is known at PackageControllerClient initialization, and the | ||
// Full Cluster Lifecycle use case, where there's limited information at |
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.
What are some examples of this limited information?
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.
Basically, if you look at NewPackageControllerClient
's parameters, and subtract these parameters out, you're left with the set of parameters that full cluster lifecycle knows at instantiation. Things like the cluster name aren't known at instantiation for full cluster lifecycle. Some of this is because of different timings, and some is because when used by full cluster lifecycle, this package controller client might be reused to build multiple clusters, whereas in a CLI usage, it builds a single cluster, then exits.
There's probably a lot of refactoring that could be done here, but this PR was big enough as is.
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'll add something to the comment.
}(&err) | ||
pc.mu.Lock() | ||
// This anonymous function ensures that the pc.mu is unlocked before | ||
// Enable is called, preventing deadlocks in the event that Enable tries |
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.
Not sure if I quite understand why we need to use a lock here. Just curious on the use case.
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.
Guillermo pointed out that this isn't thread safe. While we don't have any concurrent code at the moment, he asked that I ensure thread-safety if possible, as there are designs towards concurrency for the future. Since it was relatively simple to add, I did so. This is far from the only thing in our codebase that isn't thread-safe though. ;)
pkg/dependencies/factory.go
Outdated
@@ -1049,6 +1049,7 @@ func (f *Factory) WithPackageControllerClient(spec *cluster.Spec, kubeConfig str | |||
return err | |||
} | |||
f.dependencies.PackageControllerClient = curatedpackages.NewPackageControllerClient( | |||
f.dependencies.Helm, |
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.
Why do we have two helm dependencies being passed in here?
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.
The first is for installing helm charts, the second is for removing helm charts. They can require different parameters when they're instantiated, so you can't assume that you can use the same object to do both. Kinda annoying, but grants flexibility.
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.
Adding comments
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.
What's a case where different need to be specified? I am wondering if we should only stick to one right now if we don't have that use case for two different right now. Whoever needs two separate can then decide to separate this.
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.
Removing via followup. There was a case during development, but then that case was eliminated, so they can be collapsed into one now.
@@ -116,19 +118,26 @@ func (h *Helm) SaveChart(ctx context.Context, ociURI, version, folder string) er | |||
} | |||
|
|||
func (h *Helm) InstallChartFromName(ctx context.Context, ociURI, kubeConfig, name, version string) error { | |||
params := []string{"install", name, ociURI, "--version", version, "--kubeconfig", kubeConfig} | |||
params := []string{"upgrade", "--install", name, ociURI, "--version", version, "--kubeconfig", kubeConfig} |
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.
Can we have a comment explaining that this will install if it doesn't exist and upgrade if it does, and any side effects of that?
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.
Of course.
This will install the chart if it doesn't exist, and (if necessary) upgrade it if it does.
This change introduces the creation and deletion of a namespaced package bundle controller for workload clusters created via the full cluster lifecycle. Future commits will add packages installation/deletion via full cluster lifecycle.
Co-authored-by: Guillermo Gaston <guillermogastonlorente@gmail.com>
Co-authored-by: Guillermo Gaston <guillermogastonlorente@gmail.com>
Co-authored-by: Vivek Koppuru <vivek.koppuru@gmail.com>
57d6965
to
cf44c4e
Compare
Issue #, if available:
Description of changes:
Testing (if applicable):
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.