openfaas / faas

OpenFaaS - Serverless Functions Made Simple
https://www.openfaas.com
MIT License
25.02k stars 1.93k forks source link

Async calls to functions resulting in 404 page not found #1490

Closed VivekMBhasi closed 4 years ago

VivekMBhasi commented 4 years ago

My actions before raising this issue

Expected Behaviour

When functions are invoked using the --async flag, it should result in a 202 Accepted message and then the funtion should run in the background. I tried sending a POST request to the /async-function/ route, but it ended with the same 404 error.

But it works as expected when I try doing this with synchronous functions/ by using the /function/ route.

Current Behaviour

"Server returned unexpected status code: 404 - 404 page not found"

Possible Solution

Steps to Reproduce (for bugs)

  1. Built, pushed and deployed function
  2. faas-cli invoke --async OR
    1. curl -d 'random data' -X POST https://testingopenfaas.ml/async-function/helloworld

Context

I was working through the labs in the OpenFaaS workshop.

Your Environment

Client: Docker Engine - Community Version: 19.03.7 API version: 1.40

Server: Docker Engine - Community Engine: Version: 19.03.7 API version: 1.40 (minimum version 1.12)

Docker Swarm

Linux (Ubuntu 16.04)

https://github.com/openfaas/workshop/blob/master/lab7.md

Next steps

You may join Slack for community support.

alexellis commented 4 years ago

Hi there, thanks for using OpenFaaS.

Given that you're A) using Docker Swarm and B) using HTTPS it implies you have some kind of proxy or other product in front of OpenFaaS. My best guess is that you've configured that incorrectly.

I'm not aware of any issues with the async invocations right now, and cannot reproduce your issue:

k3d create
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
kubectl rollout status -n openfaas deploy/gateway
kubectl port-forward -n openfaas svc/gateway 8080:8080 &

# If basic auth is enabled, you can now log into your gateway:
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
echo -n $PASSWORD | faas-cli login --username admin --password-stdin

faas-cli store deploy figlet

echo "Test data" | faas-cli invoke figlet --async

echo "Test data" | faas-cli invoke figlet --async
Handling connection for 8080
Function submitted asynchronously.

curl -i -d "Test data" http://127.0.0.1:8080/async-function/figlet
Handling connection for 8080
HTTP/1.1 202 Accepted
X-Call-Id: 95d6d758-8111-495a-a5a9-2f49fb183545
X-Start-Time: 1585040651676299200
Date: Tue, 24 Mar 2020 09:04:11 GMT
Content-Length: 0

If you require technical support for your reverse proxy, we can provide consulting, or you may want to talk to the vendor of the proxy to see how to configure it? If we can prove a genuine issue with the gateway in OpenFaaS, I'm happy to re-open this issue.

Alex

alexellis commented 4 years ago

/add label: support,swarm

VivekMBhasi commented 4 years ago

Hey Alex,

Thanks for the quick response. I think that may be the issue, I do have Traefik set up in front of OpenFaaS. I'll try reconfiguring it to allow async functions.

Thanks

VivekMBhasi commented 4 years ago

Update: I was able to resolve the issue by adding /async-function under the labels in the docker-compose.yml file and then rebooting Traefik.

Thankd for directing me to the cause of the issue.

alexellis commented 4 years ago

Sounds like a misconfiguration of Traefik, easy to do. Glad you got the result you wanted.

I would recommend that you look at Kubernetes though.