openfaas / openfaas/faas-cli

build command doesn't return non-zero exit code when image is not built

Open
#499 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

skill/advanced
Dominant language
Go
Stars
816
Forks
230
Avg merge
6h 4m
Merged PRs (30d)
1

Description

The build command returns exit code 0 even though an image was not created/built.

In this particular example, the path in the handler property of the function's .yml file was invalid/not found

Expected Behaviour

The build command should return a non-zero exit status when the image cannot be built

Current Behaviour

Running faas-cli build -f test-fn.yml with an invalid handler path returns a message, but no error

 $ faas-cli build -f stack.yml
[0] > Building spacex-info.
Unable to build burtonr/spacex-info, ./spacex-info is an invalid path
Image: burtonr/spacex-info not built.
[0] < Building spacex-info done.
[0] worker done.

Possible Solution

If the image cannot be built, return non-zero exit code to fail the command

Steps to Reproduce (for bugs)

  1. create a new function: faas-cli new test-fn --lang go
  2. alter the handler path in the generated yml to and invalid path:
provider:
  name: faas
  gateway: http://127.0.0.1:8080

functions:
  test-fn:
    lang: go
    handler: ./test-fn-invalid
    image: test-fn
  1. run the build command: faas-cli build -f test-fn.yml
  2. run echo $? to observe that the command does not return an error code

Context

This was discovered in testing the OpenFaas-Cloud where I had copied a function repo to a new repo without renaming the handler path.

This resulted in the shrinkwrap function to pass without error, but the image was not built.

Your Environment

  • FaaS-CLI version ( Full output from: faas-cli version ):

  • Docker version ( Full output from: docker version ):

$ faas-cli version
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Commit: 8c7ebc3e7304873ba42b8d8e95d492499935f278
Version: 0.6.4
  • Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?
    FaaS-Swarm

  • Operating System and version (e.g. Linux, Windows, MacOS):
    Linux -> Ubuntu 18.04

  • Link to your project or a code example to reproduce issue:
    https://github.com/burtonr/test-function

Issue can easily be reproduced by following the "Steps to Reproduce" section. It's more obvious when you run echo $? just after the faas-cli build command

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with faas-cli build -f test-fn.yml using the invalid handler path described in the issue, then trace how the build command handles the “image not built” result. Done means the command returns a non-zero exit status when the image cannot be built, while successful builds retain exit code 0; add or update coverage if the repository’s build command tests identify an appropriate location.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.