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

Crash with gitlab-ci component at specific commit #1319

Open
pixelshot91 opened this issue Aug 22, 2024 · 2 comments
Open

Crash with gitlab-ci component at specific commit #1319

pixelshot91 opened this issue Aug 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@pixelshot91
Copy link

Minimal .gitlab-ci.yml illustrating the issue

---
include:
  - component: <my_gitlab_component_url>@<specific_commit_hash>
$ gitlab-ci-local
Error: Error: Command failed with exit code 1: git archive --remote=ssh://git@<my_gitlab_component_git_url> <specific_commit_hash> templates/common.yml
fatal: sent error to the client: git upload-archive: archiver died with error
remote: fatal: no such ref: <specific_commit_hash>        
remote: git upload-archive: archiver died with error
    at Function.remoteFileExist (/snapshot/firecow-gitlab-ci-local/src/utils.ts:289:112)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Function.init (/snapshot/firecow-gitlab-ci-local/src/parser-includes.ts:126:31)
    at Parser.init (/snapshot/firecow-gitlab-ci-local/src/parser.ts:109:44)
    at Function.create (/snapshot/firecow-gitlab-ci-local/src/parser.ts:60:9)
    at handler (/snapshot/firecow-gitlab-ci-local/src/handler.ts:78:18)
    at Object.handler (/snapshot/firecow-gitlab-ci-local/src/index.ts:37:21)

The problem is caused by git archive. I get the same error if I launch it manually

$ git archive --remote=ssh://git@<my_gitlab_component_git_url>  <specific_commit_hash> templates/common.yml
fatal: sent error to the client: git upload-archive: archiver died with error
remote: fatal: no such ref: <specific_commit_hash>
remote: git upload-archive: archiver died with error

If I use a branch name or no ref at all, the CI works correctly. But a specific commit hash is the only way to guarantee reproducibility.

It seems that I is intentionally forbidden by git to get a file at a specific commit.

Should we use git clone && git checkout to avoid this problem ?

Expected behavior
The component should be correctly included

Host information
Debian 12.6
gitlab-ci-local 4.52.2

@firecow firecow added the bug Something isn't working label Aug 22, 2024
@ANGkeith
Copy link
Collaborator

But a specific commit hash is the only way to guarantee reproducibility.

regarding this point, as an workaround to our implementation limitation, you can use git tag which should work with git archive --remote

@ANGkeith
Copy link
Collaborator

ANGkeith commented Aug 29, 2024

I won't be implementing this since we should be able to live with the workaround.

But for future note, do take note of the following potential performance issue when dealing with large repos

echo "git sparse-checkout:"
time (
  rm -rf test1
  git clone --branch v1.0.2 [email protected]:gitlab-org/gitlab.git -v --depth 1 --no-checkout --filter=tree:0 test1 &>/dev/null
  cd test1

  git sparse-checkout set Gemfile --no-cone
  git checkout v1.0.2 &>/dev/null
)

echo "\ngit archive:"
time (
  git archive --remote=ssh://[email protected]:22/gitlab-org/gitlab.git v1.0.2 Gemfile >/dev/null
)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants