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

Better messaging on Shallow git Clones #1698

Closed
Racer159 opened this issue May 11, 2023 · 2 comments · Fixed by #1696
Closed

Better messaging on Shallow git Clones #1698

Racer159 opened this issue May 11, 2023 · 2 comments · Fixed by #1696
Labels
enhancement ✨ New feature or request

Comments

@Racer159
Copy link
Contributor

Racer159 commented May 11, 2023

Is your feature request related to a problem? Please describe.

Shallow clones can cause issues with Zarf because it expects to mirror a repository and a shallow clone does not contain all of the object references in that repository.

Describe the solution you'd like

Detect the object not found error on a git push in in the push() function (

if errors.Is(err, git.NoErrAlreadyUpToDate) {
) and return an error that mentions shallow cloning:

return fmt.Errorf("unable to push the repo due to it being a shallow clone")

Additionally add a :::caution admonition to the git-data example that describes that a user should not use shallow clones with Zarf linking them to a page like this for more information: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone

Additional context

For more information see: https://kubernetes.slack.com/archives/C03B6BJAUJ3/p1683743369646829

@Racer159 Racer159 added the enhancement ✨ New feature or request label May 11, 2023
@dgershman
Copy link
Collaborator

Repro steps.

  1. Init a new cluster with Zarf.
  2. Build a package that uses a shallow git clone repo.

zarf.yaml

kind: ZarfPackageConfig
metadata:
  name: shallow-clone
  version: v1.0.0
  description: "Failure testing a shallow clone git reference"

components:
  - name: shallow-nocode
    required: true
    repos:
      - file:///tmp/nocode
    actions:
      onCreate:
        before:
          - cmd: cd /tmp && rm -rf nocode && git clone --depth 1 https://github.com/kelseyhightower/nocode.git

Build the package command:

zarf package create --max-package-size=0 --confirm
  1. Deploy the package to your initialized cluster.
zarf package deploy zarf-package-shallow-clone-amd64-v1.0.0.tar.zst --confirm
  1. Observe error:
Screenshot 2023-05-11 at 11 32 01 AM

@dgershman
Copy link
Collaborator

dgershman commented May 11, 2023

For anyone that might hit this issue in the interim (referencing the cloned repo within a pipeline build for your zarf.yaml), the workaround in Gitlab is to specify the below in your .gitlab-ci.yml pipeline configuration. This disables shallow cloning.

variables:
  GIT_DEPTH: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
No open projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants