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

Kustomize unable to build remote base versioned with Git commit #2444

Closed
eliavem opened this issue May 7, 2020 · 13 comments
Closed

Kustomize unable to build remote base versioned with Git commit #2444

eliavem opened this issue May 7, 2020 · 13 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

Comments

@eliavem
Copy link

eliavem commented May 7, 2020

Hi, I have 2 different repositories, in one I'm storing some overlays and in the other one, I have my base that all overlays use. I am currently versioning my base using the Git SHA1 hash in the commit. For example, I can build on the remote base as:

resources:

However, the ref gets ignored. The latest base always is used even if I specify an older commit. Here https://github.com/kubernetes-sigs/kustomize/blob/master/examples/remoteBuild.md#url-format, it is mentioned we can use specific commits and that base will be used. Is this a Bug? I'm currently using kustomize version 3.5.4, but I believe the version should not matter and this behavior should work for any version as specified in the above link. I have tested this locally running "kustomize build" and have also deployed using ArgoCD which uses the same kustomize version. Argo is able to build but the same problem happens. Any help would be appreciated

@eliavem eliavem changed the title Kustomize unable to build remote base in a repo on commit Kustomize unable to build remote base versioned with Git commit May 7, 2020
@ricochet
Copy link

ricochet commented May 14, 2020

Your example should have the ref appended to the url with "?".

For example:

resources:
- git@gitlab.com:someName/k8s-bases.git/bases/golang/?ref=release-0.3
- https://github.someOrganization/someName/someRepo.git//base?ref=7c69acaca930ec40413cfee468d3f2e7af423e20

@eliavem
Copy link
Author

eliavem commented May 15, 2020

@ricochet it was a type in the description, but even with the "?" appended it does not work as expected

@sara4dev
Copy link

@eam-cs - it doesn't download the specific sha in v3.5.4. It silently errors out and downloads the master branch always. I had to use the tag or branch to make it pin.

You can find more details here - #2072 (comment)

@mr-karan
Copy link
Contributor

Can confirm even with ?ref=<> the problem is still there.

@michaelgeorgeattard
Copy link

In v3.5.4 ?ref=<> works correctly to retrieve tags, in v3.5.5 it does not.

@monopole
Copy link
Contributor

does anyone have a proposed fix?

@monopole monopole added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label May 22, 2020
@Shell32-Natsu
Copy link
Contributor

Shell32-Natsu commented May 26, 2020

This issue is introduced in the Git cloning process here.

In v3.5.4 the implementation was wrong because it reset the repo to FETCH_HEAD after checkout the ref.

But in commit ae458d0, which is included in v3.5.5, it's wrong as well by hard-coding using branch name so commit hash doesn't work.

The fix should be adding a checkout command after cloning.

@Shell32-Natsu
Copy link
Contributor

We cannot use this option as well if we want to support checkout a commit hash.

@Shell32-Natsu
Copy link
Contributor

Shell32-Natsu commented May 27, 2020

Did a deeper research. Kustomize changed to use go-getter but the implementation has a bug. go-getter will try to update the directory if the directory has already existed (hashicorp/go-getter#114).

Kustomize always creates the temporary directory before calling go-getter so the go-getter actually is not used (because the directory is not initialized as a git repo), in most cases I guess. Then the buggy git clone implementation is engaged as a backup mechanism.

I will add a subdirectory in the temporary dir to make go-getter work.

@monopole
Copy link
Contributor

Presumably fixed by #2537. See also #2494

Please see if this can be reproduced in v3.6.1

if so, reopen and add details, thanks!

@mr-karan
Copy link
Contributor

mr-karan commented Jun 4, 2020

Got the issue in 3.6.1 as well.

Error

Error: accumulating resources: accumulateFile "accumulating resources from 'https://gitlab.xyz/my/repo/?ref=develop':
YAML file [https://gitlab.xyz/my/repo/?ref=develop] encounters a format error.\nerror converting YAML to JSON: yaml: line 3: mapping values are not allowed in thiscontext\n", accumulateDirector: "couldn't make target for path '/tmp/kustomize-440724480/repo':|
unable to find one of 'kustomization.yaml', 'kustomization.yml' or 'Kustomization' in directory '/tmp/kustomize-440724480/repo'"

Version

➜ kustomize version
{Version:kustomize/v3.6.1 GitCommit:c97fa946d576eb6ed559f17f2ac43b3b5a8d5dbd BuildDate:2020-05-27T20:47:35Z GoOs:linux GoArch:amd64}

I can confirm https://gitlab.xyz/my/repo/?ref=develop has kustomization.yaml present in root.
Also kustomize 3.5.4 is the last version where this works correctly.

Don't have the permission to reopen it, but it needs to be @monopole

@Shell32-Natsu
Copy link
Contributor

@mr-karan Currently Kustomize is using go-getter as default method to fetch remote resources. I am not sure whether go-getter has issue with gitlab URL. Can you try to use go-getter to download your repo to see is there an error?

@ricochet
Copy link

ricochet commented Oct 5, 2020

gitlab URL's are working for me with v3.6.1. Try this format:

resources:
- git@gitlab.com:convoy/my/repo.git/bases/deployment?ref=develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
Projects
None yet
Development

No branches or pull requests

7 participants