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

feat: add buildDependenciesSkipRefresh option to HelmRelease to pass --skip-refresh to helm dep bulid #9672

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

art-shutter
Copy link

Fixes: #8413

Description
This adds a new configuration option buildDependenciesSkipRefresh to skaffold render config.

User facing changes
Users can now supply a new option in the helm config for skaffold render when using helm as a renderer

Copy link

google-cla bot commented Jan 20, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

Hi team,

I'm currently reviewing this pull request and will provide my feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:

This pull request, authored by art-shutter, adds a new configuration option buildDependenciesSkipRefresh to the HelmRelease section of the Skaffold configuration. The goal is to allow users to skip refreshing already built Helm dependencies when using helm dep build. This addresses issue #8413.

Here's a breakdown of the changes:

  • Added buildDependenciesSkipRefresh option: A new boolean field, buildDependenciesSkipRefresh, has been added to the HelmRelease struct in pkg/skaffold/schema/latest/config.go (lines 1050-1055). This option defaults to false.
  • Updated schema: The schema definition in docs-v2/content/en/schemas/v4beta12.json has been updated to reflect the new option (lines 2365-2376 and 2494-2506).
  • Implemented skip refresh logic: The helm.go file (pkg/skaffold/render/renderer/helm/helm.go) now incorporates the buildDependenciesSkipRefresh option. If it's set to true, the --skip-refresh flag is passed to the helm dep build command (lines 208-218).
  • Minor cleanup: Some minor formatting changes were made in pkg/skaffold/schema/latest/config.go (lines 1856-1865 and 1883-1891).

The changes are well-structured and easy to follow. The addition of the buildDependenciesSkipRefresh option provides a valuable performance improvement for users with large Helm charts.


And now, a little haiku to lighten the mood:

Code flows like a stream,
New features gently emerge,
Reviews make it shine.

Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

This pull request adds a buildDependenciesSkipRefresh option to the HelmRelease config in Skaffold. This allows users to skip refreshing Helm dependencies during builds, which can be useful for speeding up builds when dependencies haven't changed. The implementation looks good overall, and the documentation updates are clear. I've summarized the Google Go Style Guide elements I referenced below:

  • Naming: Used for the new option name BuildDependenciesSkipRefresh.
  • Comments/Documentation: Ensured the new option is documented clearly in the schema and the code.

Here are a few minor suggestions for improvement:

@art-shutter art-shutter marked this pull request as ready for review January 20, 2025 13:12
@art-shutter art-shutter requested a review from a team as a code owner January 20, 2025 13:12
@art-shutter art-shutter requested a review from mattsanta January 20, 2025 13:12
@art-shutter
Copy link
Author

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

I did sign a CLA, can we re-run the check, please?

@menahyouyeah
Copy link
Contributor

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.

I did sign a CLA, can we re-run the check, please?

I reran it yesterday and today and looks like it's still failing

@menahyouyeah menahyouyeah self-assigned this Jan 22, 2025
@@ -2494,6 +2500,7 @@
"wait",
"recreatePods",
"skipBuildDependencies",
"buildDependenciesSkipRefresh",
Copy link
Contributor

Choose a reason for hiding this comment

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

to stay consistent with the other flag "skipBuildDependencies", can you rename to "skipBuildDependenciesRefresh"? I had to look up what the other one was doing and with this rename I think it will be clearer what each flag is doing

if err := helm.ExecWithStdoutAndStderr(ctx, h, io.Discard, errBuffer, false, env, "dep", "build", release.ChartPath); err != nil {
cmdArgs := []string{"dep", "build", release.ChartPath}
if release.BuildDependenciesSkipRefresh {
cmdArgs = []string{"dep", "build", "--skip-refresh", release.ChartPath}
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of redefining, can you just += to cmdArgs slice? I.e. just add "--skip-refresh"? Does release.ChartPath have to be the last arg?

Copy link
Author

Choose a reason for hiding this comment

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

It doesn't have to be last in helm cli. Changed it to append instead of recreate.

if err := helm.ExecWithStdoutAndStderr(ctx, h, io.Discard, errBuffer, false, env, "dep", "build", release.ChartPath); err != nil {
cmdArgs := []string{"dep", "build", release.ChartPath}
if release.BuildDependenciesSkipRefresh {
cmdArgs = []string{"dep", "build", "--skip-refresh", release.ChartPath}
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a unit test for this?

Copy link
Author

Choose a reason for hiding this comment

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

moved to its own func and added a unit test

@@ -1050,6 +1050,10 @@ type HelmRelease struct {
// Ignored for `remoteChart`.
SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"`

// BuildDependenciesSkipRefresh should the refresh of already built dependencies be skipped.
Copy link
Contributor

@menahyouyeah menahyouyeah Jan 22, 2025

Choose a reason for hiding this comment

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

nit on grammar: determines whether the refresh of already built dependencies should be skipped. I'd also add that if it's set to true, the --skip-refresh flag is passed to the helm dep build command

@art-shutter art-shutter force-pushed the add-skip-refresh-to-helm branch from db45528 to e6a93b8 Compare January 28, 2025 22:27
@pull-request-size pull-request-size bot added size/M and removed size/S labels Jan 28, 2025
@art-shutter
Copy link
Author

I reran it yesterday and today and looks like it's still failing

I amended the commits to use the email address that was used to sing the CLA. The check is passing now

menahyouyeah
menahyouyeah previously approved these changes Jan 30, 2025
@@ -171,7 +179,7 @@ func (h Helm) generateHelmManifest(ctx context.Context, builds []graph.Artifact,
return nil, helm.UserErr("cannot marshal overrides to create overrides values.yaml", err)
}

if err := os.WriteFile(constants.HelmOverridesFilename, overrides, 0666); err != nil {
if err := os.WriteFile(constants.HelmOverridesFilename, overrides, 0o666); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

just wondering why you changed this?

Copy link
Author

Choose a reason for hiding this comment

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

it's octal permissions, added by gofumpt automatically. I didn't intend this change as this is not the accepted tool in the repo. Reverted.

@plumpy
Copy link
Collaborator

plumpy commented Jan 30, 2025

Would this be better implemented as new manifests.helm.flags.depBuild option? Are there other flags that people might want to specify, and this would give them the flexibility to do so?

(edited to add:)
To clarify, I'm wondering if the config should instead support somethign like this:

manifests:
  helm:
    flags:
      depBuild: ["--skip-refresh"]

This means if there's some other flag another user wants in the future, they could immediately use it without adding yet another configuration option to the skaffold.yaml.

Curious if you have thoughts on this? (also @idsulik)

@idsulik
Copy link
Contributor

idsulik commented Jan 30, 2025

Yes, I think it'll be better to avoid adding more and more flags into the skaffold's config, we should follow the install/upgrade flags and add depBuild under the flags, as @plumpy suggested, it'll allow users to specify other flags as well if they need them:

      --keyring string            keyring containing public keys (default "/Users/main/.gnupg/pubring.gpg")
      --skip-download-if-exists   skip download of the chart if it already exists in the charts directory
      --skip-refresh              do not refresh the local repository cache
      --verify                    verify the packages against signatures

@art-shutter
Copy link
Author

here it is: #9696

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.

[Feature request] support for --skip-refresh when updating helm chart dependencies
4 participants