Skip to content

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

@cortex3

Description

@cortex3

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions