Closed tlemarchand closed 3 years ago
Please help us to help you by providing a Github repository that we can use to reproduce your issue among with detailed instructions.
@tlemarchand hope to hear back from you soon? Do you still need this issue open?
@alexellis Thanks for your answer. I still have the issue. Unfortunately the functions that are impacted are not public, and I have not found any public function working with an multipart upload and returning json or something else. So I have to put up a mock to make it easily reproducible, it might take a few days ...
Ok, but this shouldn't really take days to reproduce. Perhaps find a simple upload example for express.js or whatever you're using and use that? I'll keep the issue open another week.
@alexellis you're right, it didn't took days (a nice colleague built a mock function for me) !
Steps to reproduce, on OpenFaas with operator over Kubernetes and direct_functions set to false :
Deploy this function :
apiVersion: openfaas.com/v1
kind: Function
metadata:
name: mock
spec:
environment:
combine_output: "false"
log_level: ERROR
read_debug: "true"
read_timeout: 10s
write_debug: "true"
write_timeout: 10s
image: tlemarchand/mock-function:v0
labels:
com.openfaas.scale.min: "1"
limits:
cpu: 50m
memory: 256Mi
name: mock
requests:
cpu: 25m
memory: 128Mi
Upload a PDF to the function through the gateway ( :
curl -v -X POST -F file=@"/home/thomas/test.pdf" https://gateway.openfaas/function/mock
And check the return :
> POST /function/mock HTTP/1.1
> Host: gateway.openfaas
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 118212
> Content-Type: multipart/form-data; boundary=------------------------acc50ded887785be
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< content-length: 129
< content-type: multipart/form-data; boundary=------------------------acc50ded887785be
< date: Fri, 04 Sep 2020 12:58:04 GMT
< x-duration-seconds: 0.865100
< set-cookie: 9757cb406d295d7baa9a8e457d584d0a=66cfc9bb9377472353f808963f5d90fc; path=/; HttpOnly; Secure
<
[{"confidence":0.9834659099578857,"coordinates":{"xmax":411,"xmin":-9,"ymax":1104,"ymin":-53},"document_id":"0","label":"mock"}]
Returned content-type header is wrong.
Expose the function directly to bypass the gateway (did it with a route, but you can do the same with an ingress) :
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: mock
spec:
host: mock.direct
to:
kind: Service
name: mock
weight: 100
port:
targetPort: http
tls:
termination: edge
insecureEdgeTerminationPolicy: None
wildcardPolicy: None
Upload same PDF to the function directly :
curl -v -X POST -F file=@"/home/thomas/test.pdf" https://mock.direct/
And check the return :
> POST / HTTP/1.1
> Host: mock.direct
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 118212
> Content-Type: multipart/form-data; boundary=------------------------4140fb8cc6f9a44a
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< content-length: 129
< content-type: application/json
< date: Fri, 04 Sep 2020 13:09:50 GMT
< x-duration-seconds: 0.356345
< set-cookie: 8ac40157395f389a681c21b2265cd916=383e2a4e214d222b7af35b5c53542117; path=/; HttpOnly; Secure
<
[{"confidence":0.9834659099578857,"coordinates":{"xmax":411,"xmin":-9,"ymax":1104,"ymin":-53},"document_id":"0","label":"mock"}]
Returned content-type header is correct.
/lock: closing due to inactivity
My actions before raising this issue
Expected Behaviour
When a function is called through the gateway, it should return the same headers (and specifically the same content-type header) than when it's called directly.
Current Behaviour
When a function is called through gateway, if direct_functions parameter is set to false, content-type return header is equal to the content-type header sent by the client.
As an example, I have called a function directly (port 8080, through openfaas-watchdog), returned content-type is correct :
Same function, this time through openfaas gateway, returned content-type is wrong :
Possible Solution
I have found another issue, describing the exact same behavior, but closed in 2017, so maybe same problem but different root cause : https://github.com/openfaas/faas/issues/312
Steps to Reproduce (for bugs)
Context
Your Environment
FaaS-CLI version ( Full output from:
faas-cli version
): 0.12.4Docker version
docker version
(e.g. Docker 17.0.05 ): 19.03.13-beta2Are you using Docker Swarm or Kubernetes (FaaS-netes)? Kubernetes
Operating System and version (e.g. Linux, Windows, MacOS): MacOs 10.15.4
Code example or link to GitHub repo or gist to reproduce problem:
Other diagnostic information / logs from troubleshooting guide
If using Swarm, run the following and include the output:
Next steps
You may join Slack for community support.