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

Git clone fails after upgrading to 0.23.1 #3183

Closed
bakeemawaytoys opened this issue Mar 2, 2023 · 12 comments · Fixed by #3185 or #3188
Closed

Git clone fails after upgrading to 0.23.1 #3183

bakeemawaytoys opened this issue Mar 2, 2023 · 12 comments · Fixed by #3185 or #3188
Labels
bug Something isn't working
Milestone

Comments

@bakeemawaytoys
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

I just upgraded my Atlantis instance from 0.21 to 0.23. Cloning a repository now fails with the following error.

running git clone --depth 0 --branch main --single-branch https://<redacted>:<redacted>@example.com/example.git /home/atlantis/.atlantis/repos/example/14/default: fatal: depth 0 is not a positive number
: exit status 128

I did some digging and it looks like as of version 2.32.0, Git no longer allows the --depth flag to be set to zero. Git 2.39.2 is the version installed on the 0.23.1 image.

Reproduction Steps

The error can be reproduced by running the clone command in the Docker image

 docker run --rm -it --entrypoint /usr/bin/git  ghcr.io/runatlantis/atlantis:v0.23.1 clone --depth 0 --branch main --single-branch https://github.com/runatlantis/atlantis.git

I added checkout-depth: 25 to my server configuration file to work around the issue.

Logs

Environment details

Additional Context

The issue was introduced in #2758.

@bakeemawaytoys bakeemawaytoys added the bug Something isn't working label Mar 2, 2023
@jamengual
Copy link
Contributor

looks like the default now is 50, we will work on this to change the default

@nitrocode
Copy link
Member

Ah, I did not see this in my tests...

Default is set here to 0.

DefaultCheckoutDepth = 0

Logic is here. If branch, set depth to 1. If merge, use the checkout-depth.

if !w.CheckoutMerge {
return runGit("clone", "--depth=1", "--branch", p.HeadBranch, "--single-branch", headCloneURL, cloneDir)
}
if err := runGit("clone", "--depth", fmt.Sprint(w.CheckoutDepth), "--branch", p.BaseBranch, "--single-branch", baseCloneURL, cloneDir); err != nil {
return err
}

Options

  1. raise depth default from 0 to 50
  2. add logic to include the --depth flag only if --checkout-depth is greater than zero

@nitrocode
Copy link
Member

Does the new git default to 50 checkout depth? I do not see this.

@jamengual
Copy link
Contributor

jamengual commented Mar 3, 2023 via email

@nitrocode
Copy link
Member

nitrocode commented Mar 3, 2023

Perhaps here? but this is for repack

https://github.com/git/git/blob/d15644fe0226af7ffc874572d968598564a230dd/Documentation/git-repack.txt#L108-L118

--depth=<n>::
	These two options affect how the objects contained in the pack are
	stored using delta compression. The objects are first internally
	sorted by type, size and optionally names and compared against the
	other objects within `--window` to see if using delta compression saves
	space. `--depth` limits the maximum delta depth; making it too deep
	affects the performance on the unpacker side, because delta data needs
	to be applied that many times to get to the necessary object.

The default value for --window is 10 and --depth is 50. The maximum
depth is 4095.

@nitrocode
Copy link
Member

I think the default depth would need to be omitted to do a full clone which is what the previous atlantis versions did. Meaning we'd have to go with option 2.

@nitrocode
Copy link
Member

nitrocode commented Mar 3, 2023

We're building a new image. Once it's complete a new dev image will be created in about 20 to 30 minutes. If you could test that out without the checkout depth and confirm it works in your setup then we will release a v0.23.2.

Edit: the build finished

Please try this image

https://github.com/orgs/runatlantis/packages/container/atlantis/74593085?tag=dev-alpine-47cb6bd

ghcr.io/runatlantis/atlantis:dev-alpine-47cb6bd

@nitrocode nitrocode reopened this Mar 3, 2023
@bakeemawaytoys
Copy link
Author

I removed the checkout-depth setting from my server config file and redeployed it with the new dev image.

image

The clone error didn't occur but a similar error occurred with git fetch.

running git fetch --depth 0 head +refs/heads/<redacted-branch-name>:: fatal: depth 0 is not a positive number
: exit status 128

@nitrocode
Copy link
Member

Thanks @bakeemawaytoys . I cannot believe we missed that one. I added one more to omit the checkout.

@jamengual
Copy link
Contributor

jamengual commented Mar 3, 2023

please test docker pull ghcr.io/runatlantis/atlantis:dev-debian-5774453 we pushed the fix for fetch too

@bakeemawaytoys
Copy link
Author

Sorry for the late response. I was finally able to confirm that the fixes worked for me. I tested on v0.23.2. Thanks for the quick turnaround.

@jamengual
Copy link
Contributor

thanks for the help @bakeemawaytoys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment