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

[BUG] kompose fails with getAbsBuildContext failed: exit status 128 #1957

Closed
cortex3 opened this issue Nov 7, 2024 · 0 comments · Fixed by #1958
Closed

[BUG] kompose fails with getAbsBuildContext failed: exit status 128 #1957

cortex3 opened this issue Nov 7, 2024 · 0 comments · Fixed by #1958
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@cortex3
Copy link
Contributor

cortex3 commented Nov 7, 2024

Expected Behavior

I have a gitlab pipeline that runs kompose. Recently I updated the docker image and started running into the following error from kompose:

$ kompose convert --provider=openshift --build build-config --build-repo "https://${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" --build-branch "$CI_COMMIT_REF_NAME" -f docker-compose.k8s-resolved.yml -o $KOMPOSE_DIR
FATA initBuildConfig failed: clibuildconfig cannot be created due to error in creating build context, getAbsBuildContext failed: exit status 128 

Now this error sadly did not explain a lot to me and I was confused because the kompose version didn't even change.
After some debugging I figured out that the error comes from the git command executed in this function: https://github.com/kubernetes/kompose/blob/main/pkg/transformer/openshift/utils.go#L34

Now the git version is something that has indeed changed in the container and executing the command directly inside the container gives me the following output:

fatal: detected dubious ownership in repository at '{{ PATH }}'
To add an exception for this directory, call:
	git config --global --add safe.directory {{ PATH }}

I think it would be useful to return this information as part of the kompose error output.
Similiary if I was to provide a compose file with a build context that does not point to a git repository I would be hit with the exact same error:
FATA initBuildConfig failed: clibuildconfig cannot be created due to error in creating build context, getAbsBuildContext failed: exit status 128
instead of receiving the much more useful information from git:

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I can create a PR to adjust the error output. I've seen there are 2 more git commands in the same file that could possibly also benefit from more output. Please let me know if you see any issues with my approach.

Even if no PR ends up being merged here it might help someone that you can google for this error now.
The error did not return any results in google so far.

Actual Behavior

better error output

Steps To Reproduce

No response

Kompose Version

same behaviour in 1.22.0 and 1.34.0

Docker-Compose file

No response

Anything else?

No response

@cortex3 cortex3 added the kind/bug Categorizes issue or PR as related to a bug. label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant