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

Non-git directories should error on tags #769

Open
andrew-s opened this issue Feb 28, 2020 · 2 comments
Open

Non-git directories should error on tags #769

andrew-s opened this issue Feb 28, 2020 · 2 comments

Comments

@andrew-s
Copy link

andrew-s commented Feb 28, 2020

This happened because of an edge case with a git binary version on a self-hosted runner.

When using tags of branch or sha on a directory that isn't a git repository, you get a complete error as an image name, e.g; eu.gcr.io/project/image:0.1-fatal: not a git repository (or any parent up to mount point /github) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).-fatal: not a git repository (or any parent up to mount point /github) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

This is an invalid image name, and kubernetes had some issues with this.

Expected Behaviour

Should fatal or exit back to the user (with a non zero exit code)

Current Behaviour

Creates invalid image names

Possible Solution

Exit with a non-zero exit code (so that a pipeline can exit too, in this case, the runner had checked the code out as a zip instead of git without any notice)

Steps to Reproduce (for bugs)

  1. Run faas-cli build --parallel 5 --tag=sha -f faas-stack.yml on a non-git directory

Context

Runner had changed the checkout method without notification

@martindekov
Copy link
Contributor

I get exit code 1 on failure as you described it:

$ sudo faas-cli build --tag=sha
[sudo] password for mdekov: 
Pulling template: perl-alpine from configuration file: stack.yml
Fetch templates from repository: https://github.com/tmiklas/openfaas-perl-templates at master
...
[0] > Building newnew.
Clearing temporary build folder: ./build/newnew/
Preparing: ./newnew/ build/newnew/function
Building: newnew:latest-fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). with go template. Please wait..
invalid argument "newnew:latest-fatal: not a git repository (or any parent up to mount point /)\nStopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)." for "-t, --tag" flag: invalid reference format: repository name must be lowercase
See 'docker build --help'.
[0] < Building newnew done in 0.43s.
[0] Worker done.

Total build time: 0.43s
Errors received during build:
- [newnew] received non-zero exit code from build, error: invalid argument "newnew:latest-fatal: not a git repository (or any parent up to mount point /)\nStopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)." for "-t, --tag" flag: invalid reference format: repository name must be lowercase
See 'docker build --help'.


mdekov@mdekov-Lenovo-Y520-15IKBN:~/go/src/github.com/martindekov/newnew$ echo $?
1

it returns 1 isn't this the proposed solution?

@andrew-s
Copy link
Author

andrew-s commented Mar 1, 2020

@martindekov So I went back and took a look at our pipeline, turns out we built on one machine (with the correct git version) and deployed on one that ended up with the zip, looks like build does indeed fail correctly but deploy does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants