openfaas / openfaas/faas-cli

Proposal: add --debug flag to `deploy` (print out HTTP request)

Open
#636 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

During provider development i've found it helpful to log the the entire request/response sent from the CLI to the gateway.

Expected Behaviour

faas cli deploy --debug

Current behaviour

$faas deploy 
Deploying: echo.
Unexpected status: 400, message: Please provide a valid route /function/function_name.

Function 'echo' failed to deploy with status code: 400

Future behaviour with debug flag

$ faas deploy --debug                                    
Deploying: echo.
WARNING! Communication is not secure, please consider using HTTPS. Letsencrypt.org offers free SSL/TLS certificates.
2019/05/10 18:54:21
-------- deploy request:echo --------
PUT /system/functions HTTP/1.1
Host: 127.0.0.1:8080
Authorization: Basic YWRtaW46OGFmYzg4N2YxMjM3NGViZmMwN2I0ZTZjMTQ3MzY5Y2Y1NzQ5MGNmZTA1N2ZkOGIyYTE1ZTk2MWEwZjc2Y2ZhNQ==

{"service":"echo","image":"ewilde/echo:latest","network":"","envProcess":"python index.py","envVars":{},"constraints":null,"secrets":[],"labels":{},"annotations":{},"limits":null,"requests":null,"readOnlyRootFilesystem":false}
-------------------------------------
2019/05/10 18:54:21
-------- deploy response:echo --------
HTTP/1.1 400 Bad Request
Content-Length: 53
Content-Type: text/plain; charset=utf-8
Date: Fri, 10 May 2019 17:54:21 GMT

Please provide a valid route /function/function_name.
-------------------------------------

Unexpected status: 400, message: Please provide a valid route /function/function_name.

I have a private fork with the above functionality, if it's something the community wants I can PR it in / or adapt based on feedback.

Alternatives

  • Run faas-cli through a proxy which logs request/response (not such great DX?)

Extensions

  • Flag could get proxied as a header X-OpenFaaS-Trace to gateways / provider which could debug log request/response as each hop

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

Start at the deploy command entry point and the CLI's HTTP request path; the issue names no files or tests. Compare normal output with the proposed --debug transcript. Done means faas-cli deploy --debug prints the deploy request and response while preserving existing behavior without the flag.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.