-
Notifications
You must be signed in to change notification settings - Fork 50
add items to dynamic watch in helm #517
add items to dynamic watch in helm #517
Conversation
d54c821
to
0f83a3a
Compare
0f83a3a
to
2f8e7df
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.
This seems to take a different approach than the plain provisioner. Should this with how the plain provisioner works? That would hopefully make it easier to find re-use opportunities in the future, and it would ensure the UX is generally the same for both.
@joelanford The UX should be the same. It is doing the same thing as the plain provisioner but it can not do the same way. It is adding to the watch using the release.manifest after the install because the yaml files in the charts can not be decoded without the rendering. It is adding the labels using the postrenderer because it must be done against the rendered objects. |
Oh right. In Plain, we know the full content of the "templates" ahead of time. In Helm, we have to run the chart through the helm libraries to know what the resulting manifest is. One other thing that comes to mind. We use a post-renderer under the hood in the helm-operator-plugins repo to inject owner references. If we override the post-renderer to set these labels, we might be overriding the ownerref post renderer. |
Yes, I found that. I added the ownerref injection in the post-render function. |
2f8e7df
to
0ee9c0b
Compare
Not blocking for this PR, but I imagine that unknowingly setting a post-renderer like you did could be a footgun for others. I wonder if there's a way in helm-operator-plugins to support adding more caller-defined post-renderers to the chain. |
0ee9c0b
to
049c44a
Compare
I made changes to call the preset PostRenderer after our PostRenderer if it is set. |
@akihikokuroda I've got a PR up in helm-operator-plugins that I think should get rid of the awkward hacking you had to do to use both the built-in and extra post-renderer. |
02920f9
to
2a9a878
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.
These changes seem reasonable. If we're hacking around the helm-operator-plugins implementation here, does it make sense to create a ticket that tracks cleaning up the implementation once Joe's changes land and a new release is cut?
break | ||
} | ||
if err != nil { | ||
return fmt.Errorf("read %q: %v", obj, err) |
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.
Is printing the obj here potentially problem for logs? Or does this just print the metadata information we care about?
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 err
has enough information. I take out the obj
.
@@ -286,7 +323,7 @@ const ( | |||
stateError releaseState = "Error" | |||
) | |||
|
|||
func (r *BundleDeploymentReconciler) getReleaseState(cl helmclient.ActionInterface, obj metav1.Object, chrt *chart.Chart, values chartutil.Values) (*release.Release, releaseState, error) { | |||
func (r *BundleDeploymentReconciler) getReleaseState(cl helmclient.ActionInterface, obj metav1.Object, chrt *chart.Chart, values chartutil.Values, post *postrenderer) (*release.Release, releaseState, 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.
We may want/need a tech debt ticket here given the number of parameters for this method.
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.
OK. I'll add a TODO comment.
if err != nil { | ||
return currentRelease, stateError, err | ||
} | ||
if desiredRelease.Manifest != currentRelease.Manifest || | ||
!reflect.DeepEqual(desiredRelease.Chart.Metadata, currentRelease.Chart.Metadata) || |
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.
Any idea on why this comparison is needed?
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 checking for the changes in Chart.yaml file. It's contents are here.
@@ -251,6 +278,16 @@ func (r *BundleDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req | |||
}), | |||
updater.EnsureInstalledName(bundle.GetName()), | |||
) | |||
if err := r.addDynamicWatch(cl, bd, bundle); err != nil { |
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 feels like something the plain provisioner could also hook into?
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 checking for the changes in Chart.yaml file. The plain provisioner is generating the contents of the Chart.yam file on the fly so it's always same.
rel, state, err := r.getReleaseState(cl, bd, chrt, values) | ||
post := &postrenderer{ | ||
labels: map[string]string{ | ||
util.CoreOwnerKindKey: "BundleDeployment", |
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.
nit: I think we have a const variable somewhere for the BD GVK.
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.
It doesn't seem defined.
@timflannagan I created the issue for refactoring. #534 |
Awesome. Follow-up question: do we think it would be valuable to also add a comment linking to that issue for the postrenderer hacks? |
That's a good idea. I'll do it. Refactor issue: #534 |
6169128
to
6be4583
Compare
6be4583
to
3e706cf
Compare
3e706cf
to
3a18d86
Compare
3a18d86
to
5e91b3e
Compare
Refactor has done. Please review. |
For(&rukpakv1alpha1.BundleDeployment{}, builder.WithPredicates( | ||
util.BundleDeploymentProvisionerFilter(plain.ProvisionerID)), | ||
). |
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 haven't had a chance to look over the new directory structure since #447 landed: we're specifying the plain.ProvisionerID here, and filtering BundleDeployments that don't match that unique provisioner class ID from the cache. Is that the right read here? If so, I think we'll need to solve this in an agnostic way s.t. our core provisioners can leverage this functionality without inter-depending on the plain provisioner libraries.
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.
Oh, it's my mistake. This function is not used any more since #447 changes. I'll take this out.
@@ -426,7 +450,13 @@ func (p *bundledeploymentProvisioner) getReleaseState(cl helmclient.ActionInterf | |||
desiredRelease, err := cl.Upgrade(obj.GetName(), p.releaseNamespace, chrt, values, func(upgrade *action.Upgrade) error { | |||
upgrade.DryRun = true | |||
return nil | |||
}) | |||
}, | |||
// To be refactored issue 534 |
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.
nit: can we copy/paste the 534 issue link so it's easier to track when reading through the codebase locally?
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.
Sure. It must be better.
rel, state, err := p.getReleaseState(cl, bd, chrt, values) | ||
post := &postrenderer{ | ||
labels: map[string]string{ | ||
util.CoreOwnerKindKey: "BundleDeployment", |
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.
nit: we have a constant variable for the BundleDeployment Kind: https://github.com/operator-framework/rukpak/blob/main/api/v1alpha1/bundledeployment_types.go#L26.
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.
Thanks! I'll update.
Sorry for the slow turnaround on this. I've been pretty heads down with other projects/work recently. Can we also re-title this PR to fix the typo? |
Signed-off-by: akihikokuroda <akuroda@us.ibm.com>
5e91b3e
to
9137b59
Compare
Pulling this down now, and quickly testing it out locally. |
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 tested these changes out locally, and it looks like we're good to go:
apiVersion: core.rukpak.io/v1alpha1
kind: BundleDeployment
metadata:
name: hello-world-helm
namespace: demo1
spec:
provisionerClassName: core-rukpak-io-helm
template:
metadata:
labels:
app: hello-world-helm
spec:
provisionerClassName: core-rukpak-io-helm
source:
http:
url: https://github.com/helm/examples/releases/download/hello-world-0.1.0/hello-world-0.1.0.tgz
type: http
And then deleted the deployment that got created from that Bundle resource a couple of times, and waited for it to be quickly recreated.
I haven't had a chance to catch up the new repository structure, but this looks like a reasonable short term hack while we wait for a release to be cut.
Closes #514
Signed-off-by: akihikokuroda akuroda@us.ibm.com