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

[velero] Add enable/disable option for helm hooks #171

Merged
merged 10 commits into from
Nov 18, 2020

Conversation

igorcezar
Copy link
Contributor

@igorcezar igorcezar commented Oct 14, 2020

Special notes for your reviewer:

Create an option in values to disable helm hooks used in CRDs (for Helm v2) and templates manifest (like BackupStorageLocation), introduced in #109 and #153.

With this change it's possible to install this chart using ArgoCD without any problems, setting the new option to false:

enableHelmHooks: false

It's possible to disable only CRD hooks or template hooks, in case you don't want to disable both.

The default option is true, which enables all helm hooks.

Helm hooks in crds folder, for Helm v3, are untouched, because they can't be templated.

Fix #158

Checklist

  • DCO signed
  • Chart Version bumped
  • Title of the PR starts with chart name (e.g. [velero])

cidsasaki
cidsasaki previously approved these changes Oct 14, 2020
Copy link

@cidsasaki cidsasaki left a comment

Choose a reason for hiding this comment

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

Works as expected! Thanks for the correction.

@cidsasaki
Copy link

cidsasaki commented Oct 14, 2020

Resolves to #146 / #44

@@ -72,6 +72,12 @@ metrics:
# Install CRDs as a templates. Enabled by default.
installCRDs: true

# Enable/disable helm hooks annotations for Helm v2 in CRDs and/or templates
Copy link
Collaborator

@jenting jenting Oct 14, 2020

Choose a reason for hiding this comment

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

May I say ArgoCD uses helm v2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ArgoCD uses only Helm v2 until v1.4. Starting in v1.5 it has both v2 and v3, using v3 when Chart.yaml apiVersion is v2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay, since we're using apiVersion: v1 https://github.com/vmware-tanzu/helm-charts/blob/c90e413/charts/velero/Chart.yaml#L1, so the ArgoCD would use helm v2 behavior even we use ArgoCD version >= 1.5, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That’s right!

Choose a reason for hiding this comment

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

Not exactly, if you want to provide your own values.yaml for this chart for the helm install you need to build your own chart which has this one as a dependency. Which results in usually helm v3 being the actual engine.
This is because argocd requires the source of both helm chart and altered values.yaml to be in the same repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not exactly, if you want to provide your own values.yaml for this chart for the helm install you need to build your own chart which has this one as a dependency. Which results in usually helm v3 being the actual engine.
This is because argocd requires the source of both helm chart and altered values.yaml to be in the same repository.

I use it that way, with velero chart as a dependency, and ArgoCD also uses Helm v2. For Helm v3 I have to change Chart.yaml apiVersion of the chart that I build (the one which imports velero chart) to v2, or force ArgoCD to use Helm v3 as described here.

charts/velero/values.yaml Outdated Show resolved Hide resolved
@jenting
Copy link
Collaborator

jenting commented Oct 14, 2020

@simran3695, @fabianmet could you please take a look a this 🙇 ? It seems to fix #158.

@jenting jenting added the velero label Oct 14, 2020
@jenting
Copy link
Collaborator

jenting commented Oct 14, 2020

Resolves to #146 / #44

thanks, but I don't think it resolves the #44. #146 was want to resolve we always have to manual sync CRDs against each Velero release and also fixes the issues that helm upgrade won't upgrade the CRDs.

Copy link

@fabianmet fabianmet left a comment

Choose a reason for hiding this comment

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

The actual issue arises because if you install this chart with helm v3 the pre-install pre-sync hooks are also triggered on the CRD's in the CRD directory.

This causes the state to be dropped by ArgoCD because a hook has no state. It is a one off job.
The only way to fix this is either remove the hook notations in the CRD directory all together, or change them back to the helm hook for crd-install.

I understand you want this helm chart to keep the CRD's in line with your actual helm velero installation but this goes against what helm themselves say as explained here.

I tried the same approach as @igorcezar did in this PR but it did not solve the issue where the CRD's were installed but constantly in a bad state because of the pre-install pre-sync hooks still being present on the CRD's themselves.

Also its a shame but the CRD directory does not treat files as templates, so there is no way to properly disable helm hooks in the CRD files.

Having the option to see what changes in a CRD is really helpful for upgrade purposes. So im a big fan of having them available easily in git instead of having velero themselves generate it but that is my opinion.

@@ -72,6 +72,12 @@ metrics:
# Install CRDs as a templates. Enabled by default.
installCRDs: true

# Enable/disable helm hooks annotations for Helm v2 in CRDs and/or templates

Choose a reason for hiding this comment

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

Not exactly, if you want to provide your own values.yaml for this chart for the helm install you need to build your own chart which has this one as a dependency. Which results in usually helm v3 being the actual engine.
This is because argocd requires the source of both helm chart and altered values.yaml to be in the same repository.

cidsasaki
cidsasaki previously approved these changes Oct 15, 2020
@igorcezar
Copy link
Contributor Author

The only way to fix this is either remove the hook notations in the CRD directory all together, or change them back to the helm hook for crd-install.

In this PR we remove hook notations from templates/crds.yaml and the CR's templates, which for ArgoCD solves the problem, since it uses Helm v2 if you don't change the chart apiVersion to v2. But for sure the best solution would be to also remove from CRD folder so ArgoCD can work even using Helm v3.

@jenting the hook notations were included in CRD directory just for templates/crds.yaml could import the crds with the hooks, right?
Could we remove it from CRD folder (Helm v3) and enable only in crds.yaml for Helm v2?

@jenting
Copy link
Collaborator

jenting commented Oct 15, 2020

The only way to fix this is either remove the hook notations in the CRD directory all together, or change them back to the helm hook for crd-install.

In this PR we remove hook notations from templates/crds.yaml and the CR's templates, which for ArgoCD solves the problem, since it uses Helm v2 if you don't change the chart apiVersion to v2. But for sure the best solution would be to also remove from CRD folder so ArgoCD can work even using Helm v3.

@jenting the hook notations were included in CRD directory just for templates/crds.yaml could import the crds with the hooks, right?

I think so.

Could we remove it from CRD folder (Helm v3) and enable only in crds.yaml for Helm v2?

Not sure what you'd like to remove? The helm annotation or CRD folder?

@igorcezar
Copy link
Contributor Author

Not sure what you'd like to remove? The helm annotation or CRD folder?

The helm annotation in all *.yaml of CRD folder.
Keep annotation only for templates/crds.yaml file.

@igorcezar
Copy link
Contributor Author

igorcezar commented Oct 15, 2020

@jenting I have pushed the changes I was talking about.

With this, the chart works for ArgoCD with Helm v2 (setting enableHelmHooks: false) and Helm v3 ( no matter how enableHelmHooks is set, but the preference is set to false, so that BSL/VSL/Schedule don't become Post Sync hooks).

Also works with helm install for both versions too (tested with helm v2.15.2 and v3.1.2), with enableHelmHooks: true (which is the default).

cidsasaki
cidsasaki previously approved these changes Oct 19, 2020
@jenting
Copy link
Collaborator

jenting commented Oct 21, 2020

I want to play ArgoCD so I'll review this PR slowly.

Copy link
Collaborator

@jenting jenting left a comment

Choose a reason for hiding this comment

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

@igorcezar could you please address the comments and fix the conflicts? thank you.

Comment on lines 75 to 76
# Enable/disable helm hooks annotations for CRDs (Helm v2) and templates
# You should disable this if using a deploy tool that doesn't support helm hooks
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. I don't think it's for helm2 only, these helm hooks also available on helm3
  2. maybe we could mention the deploy tool ArgoCD to help people easier to understand when to disable helm hooks annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For CRDs it was helm2 only, because in helm3 CRDs can't be templated, but for all else it was for both v2 and v3.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For CRDs it was helm2 only, because in helm3 CRDs can't be templated, but for all else it was for both v2 and v3.

helm template vmware-tanzu/velero --include-crds

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hooks are available for Helm3, but in this chart the option enableHelmHooks will only enable/disable helm hooks for helm2 CRDs (templates/crds.yaml) and for all other templates on both versions.
I've made the changes in the comments and chart version.

Signed-off-by: Igor Cezar <[email protected]>

Remove whitespaces

Signed-off-by: Igor Cezar <[email protected]>
Copy link
Collaborator

@jenting jenting left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

@igorcezar
Copy link
Contributor Author

Any news on this?

@jenting
Copy link
Collaborator

jenting commented Nov 18, 2020

Any news on this?

@carlisia @cpanato PTAL

Copy link
Contributor

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

lgtm, did not see any issues

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backup is not creating with failed validation error on ArgoCD
5 participants