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

Don't fetch tags when exact version is specified in HelmChart #846

Merged
merged 1 commit into from
Jul 27, 2022

Conversation

makkes
Copy link
Member

@makkes makkes commented Jul 26, 2022

Taking this shortcut has two benefits:

  1. It allows charts to be fetched from AWS's public container registry
    at public.ecr.aws
  2. It makes reconciling a HelmChart faster by skipping one or more
    potentially expensive API calls to the registry.

refs #845

@makkes makkes self-assigned this Jul 26, 2022
@makkes makkes added area/helm Helm related issues and pull requests area/oci OCI related issues and pull requests labels Jul 26, 2022
@makkes makkes force-pushed the conditionally-fetch-oci-tags branch from e5d93e5 to db3ef6a Compare July 26, 2022 15:19
@souleb
Copy link
Member

souleb commented Jul 27, 2022

Wouldn't it be better to do the check in downloadFromRepository before calling remote.GetChartVersion. Because remote.GetChartVersion does some expensive job in either cases, load index or fetch tags to retrieve a version. If we know we have a valid version, maybe we can save some cpu cycles here.

@makkes
Copy link
Member Author

makkes commented Jul 27, 2022

Wouldn't it be better to do the check in downloadFromRepository before calling remote.GetChartVersion. Because remote.GetChartVersion does some expensive job in either cases, load index or fetch tags to retrieve a version. If we know we have a valid version, maybe we can save some cpu cycles here.

GetChartVersion is called from two places:

  1. remoteChartBuilder#downloadFromRepository
  2. DependencyManager#addRemoteDependency

We'd have to change both callers to get the same behaviour. IMHO the logic to check whether to hit the remote repository or not belongs into GetChartVersion so that callers don't have to think about that. The next time someone adds a call to GetChartVersion and doesn't think about the case where the version denotes a concrete semantic version they introduce this bug again.

@souleb
Copy link
Member

souleb commented Jul 27, 2022

the other thing is that we rely on remote.GetChartVersion to tell us if a given version is valid(i.e. it does exit in the remote) or not before trying to download it ... We are introducing a different behavior than https helmrepo here. And the test cases have to be changed accordingly.

@makkes makkes force-pushed the conditionally-fetch-oci-tags branch 3 times, most recently from f915dd0 to 4b62e38 Compare July 27, 2022 10:14
@makkes makkes requested a review from darkowlzz July 27, 2022 10:14
@makkes
Copy link
Member Author

makkes commented Jul 27, 2022

The failure on "tests / test-linux-amd64" is a flake:

panic: Failed to stop the test environment: timeout waiting for process kube-apiserver to stop

@makkes makkes force-pushed the conditionally-fetch-oci-tags branch from 4b62e38 to 28fe78f Compare July 27, 2022 10:29
Taking this shortcut has two benefits:

1. It allows charts to be fetched from AWS's public container registry
   at public.ecr.aws
2. It makes reconciling a HelmChart faster by skipping one or more
   potentially expensive API calls to the registry.

I adapted the unit tests to the new behavior that the
OCIChartRepository doesn't fail anymore for the case where a specific
chart version has been requested that doesn't actually exist in the
registry.

refs #845

Signed-off-by: Max Jonas Werner <max@e13.dev>
@makkes makkes force-pushed the conditionally-fetch-oci-tags branch from 28fe78f to b86572b Compare July 27, 2022 11:25
@stefanprodan stefanprodan changed the title don't fetch tags when exact version is used in HelmRepository Don't fetch tags when exact version is specified in HelmChart Jul 27, 2022
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @makkes 🏅

@makkes makkes merged commit 5a036da into main Jul 27, 2022
@makkes makkes deleted the conditionally-fetch-oci-tags branch July 27, 2022 12:00
@darkowlzz darkowlzz mentioned this pull request Jul 27, 2022
darkowlzz added a commit that referenced this pull request Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm Helm related issues and pull requests area/oci OCI related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants