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

Lab4: Sentiment Analysis only works randomly, and requests.get() does't work #191

Open
cheimu opened this issue Mar 5, 2021 · 1 comment

Comments

@cheimu
Copy link

cheimu commented Mar 5, 2021

Two problems when doing lab4:

  1. When I try lab4 function chaining, I firstly try echo -n "California is great, it's always sunny there." | faas-cli invoke sentimentanalysis, sometimes it works, but most of time it returns: Server returned unexpected status code: 502 -
  2. When I try function chaining using exactly same code in lab4, but exceptions raised. Cannot recognize gateway in url.

Expected Behaviour

  1. $ echo -n "California is great, it's always sunny there." | faas-cli invoke sentimentanalysis {"polarity": 0.8, "sentence_count": 1, "subjectivity": 0.75}
  2. "That was probably positive"

Current Behaviour

  1. Server returned unexpected status code: 502 -
  2. Server returned unexpected status code: 500 - exit status 1
    Traceback (most recent call last):
    File "/home/app/python/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
    File "/home/app/python/urllib3/util/connection.py", line 73, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
    File "/usr/local/lib/python3.9/socket.py", line 953, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    socket.gaierror: [Errno -2] Name does not resolve
During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/app/python/urllib3/connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "/home/app/python/urllib3/connectionpool.py", line 394, in _make_request conn.request(method, url, **httplib_request_kw) File "/home/app/python/urllib3/connection.py", line 234, in request super(HTTPConnection, self).request(method, url, body=body, headers=headers) File "/usr/local/lib/python3.9/http/client.py", line 1255, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.9/http/client.py", line 1301, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.9/http/client.py", line 1250, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.9/http/client.py", line 1010, in _send_output self.send(msg) File "/usr/local/lib/python3.9/http/client.py", line 950, in send self.connect() File "/home/app/python/urllib3/connection.py", line 200, in connect conn = self._new_conn() File "/home/app/python/urllib3/connection.py", line 181, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno -2] Name does not resolve

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

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

  • Docker version ( Full output from: docker version ): Client: Docker Engine - Community
    Cloud integration: 1.0.7
    Version: 20.10.2
    API version: 1.41
    Go version: go1.13.15
    Git commit: 2291f61
    Built: Mon Dec 28 16:12:42 2020
    OS/Arch: darwin/amd64
    Context: default
    Experimental: true
    Server: Docker Engine - Community
    Engine:
    Version: 20.10.2
    API version: 1.41 (minimum version 1.12)
    Go version: go1.13.15
    Git commit: 8891c58
    Built: Mon Dec 28 16:15:28 2020
    OS/Arch: linux/amd64
    Experimental: false
    containerd:
    Version: 1.4.3
    GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
    runc:
    Version: 1.0.0-rc92
    GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
    docker-init:
    Version: 0.19.0
    GitCommit: de40ad0

  • Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)? Kubernetes

  • Operating System and version (e.g. Linux, Windows, MacOS): MacOS

  • Link to your project or a code example to reproduce issue:

cheimu added a commit to cheimu/My-OpenFaaS-Workshop that referenced this issue Mar 5, 2021
@cheimu
Copy link
Author

cheimu commented Mar 5, 2021

I guess I know where the problem is my first question and totally fix my second question where requests.get() does't work.

The solution to my second question: requests.get() does't work
the lab4's spec has one typo and one place a little bit confusing

1 typo. It says

Kubernetes

Suffix the gateway host with openfaas namespace:

    r = requests.get("http://gateway.openfaas:8080/function/sentimentanalysis", text= test_sentence)

But it should be r = requests.get("http://gateway.openfaas:8080/function/sentimentanalysis", data= test_sentence) instead. It's data not text !!!

  1. Confusion. Spec says

Kubernetes

Suffix the gateway host with openfaas namespace:

    r = requests.get("http://gateway.openfaas:8080/function/sentimentanalysis", text= test_sentence)

Or via an environmental variable:

    gateway_hostname = os.getenv("gateway_hostname", "gateway") # uses a default of "gateway" for when "gateway_hostname" is not set
    test_sentence = "California is great, it's always sunny there."
    r = requests.get("http://" + gateway_hostname + ":8080/function/sentimentanalysis", data= test_sentence)

However, "Or via an environmental variable" part description is the syntax for swarm rather than for k8s. For k8s it should be
r = requests.get("http://" + gateway_hostname + ".openfaas:8080/function/sentimentanalysis", data= test_sentence) instead. K8s requires namespace openfaas.

As for my first question: Sentiment Analysis only works randomly
I can close the issue, since I think it is because sentimentanalysis takes a long time to deploy and my open-faas service is not stable, somethings kubectl port-forward svc/gateway -n openfaas 8080:8080 got broken. E0304 18:44:15.028897 9123 portforward.go:340] error creating error stream for port 8080 -> 8080: EOF Could I get confirmed? Thank you in advance!

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

1 participant