serverless / serverless-openwhisk

Adds Apache OpenWhisk support to the Serverless Framework!
http://openwhisk.org/
MIT License
143 stars 47 forks source link

sls with runtime Docker, fails to invoke #160

Closed karanrk closed 5 years ago

karanrk commented 5 years ago

Hello Team,

I tried deploying a serverless application that is completed built with personal docker image (dockerhub) and the deployment is successful but the invoke isn't. The deployment and invoke works fine on the ibmcloud without serverless, but looking at your examples on docker this is something that should have worked. I don't see any logs generated too.

Information from bluemix

image

jthomas commented 5 years ago

@karanrk Sorry you are having issues. Can you post the serverless.yaml configuration file you are using to deploy the service?

karanrk commented 5 years ago

Below is my serverless.yml file

service: "MyServiceName"

provider:
  name: openwhisk

  runtime: python

functions:
  "MyfunctionName":
    handler: krkamatg/chatter-uc
    runtime: docker
    timeout: 600
    memory: 2048

plugins:
  - serverless-openwhisk

Below is my Dockerfile

FROM openwhisk/python3action

COPY requirements.txt ./

COPY download-toolkit.py ./

ENV https_proxy "MyProxy"
ENV http_proxy "MyProxy"

RUN export http_proxy="MyProxy" && export https_proxy="MyProxy" && \
pip install --no-cache-dir -r requirements.txt

RUN export http_proxy="MyProxy" && export https_proxy="MyProxy" && python3 download-toolkit.py

COPY unitConvertion.py ./

CMD [ "python3", "unitConvertion.py" ]
jthomas commented 5 years ago

I have managed to get this working based on the files above. The Docker image being built is incorrect and should not include or attempt to run the unitConvertion.py file as the start command.

FROM openwhisk/python3action

COPY requirements.txt ./

COPY download-toolkit.py ./

ENV https_proxy "MyProxy"
ENV http_proxy "MyProxy"

RUN export http_proxy="MyProxy" && export https_proxy="MyProxy" && \
pip install --no-cache-dir -r requirements.txt

RUN export http_proxy="MyProxy" && export https_proxy="MyProxy" && python3 download-toolkit.py
service: unit-conversion

provider:
  name: openwhisk
  runtime: python

functions:
  test:
    handler: unitConvertion.main
    image: <DOCKERHUB_USER>/openwhisk_python

plugins:
  - serverless-openwhisk

When I follow these steps the code executes with the following output...

$ sls invoke -f test
{
    "0 celsius to fahrenheit": "32.00000039999997",
    "How many meters are in a kilometer?": "1000.0",
    "How many meters are in one inch": "0.0254",
    "one hour is how many minutes ?": "60.0"
}
$ sls logs -f test
activation (4a7b278569154c69bb278569150c69d2):
2019-03-13 19:12:56.280 [nltk_data] Downloading package averaged_perceptron_tagger to
2019-03-13 19:12:56.280 [nltk_data] /usr/share/nltk_data...
2019-03-13 19:12:56.289 [nltk_data] Package averaged_perceptron_tagger is already up-to-
2019-03-13 19:12:56.289 [nltk_data] date!
2019-03-13 19:12:56.289 [nltk_data] Downloading package punkt to /usr/share/nltk_data...
2019-03-13 19:12:56.328 [nltk_data] Package punkt is already up-to-date!
2019-03-13 19:12:56.329 [nltk_data] Downloading package stopwords to /usr/share/nltk_data...
2019-03-13 19:12:56.330 [nltk_data] Package stopwords is already up-to-date!
2019-03-13 19:12:56.331 [nltk_data] Downloading package wordnet to /usr/share/nltk_data...
2019-03-13 19:12:56.847 [nltk_data] Unzipping corpora/wordnet.zip.
Training ai.yml: [####################] 100% 1%
Training botprofile.yml: [####################] 100%] 5%
Training computers.yml: [####################] 100% ] 10%
Training conversations.yml: [####################] 100%] 6%
Training emotion.yml: [####################] 100% 2%
Training food.yml: [####################] 100% ] 8%
Training gossip.yml: [####################] 100%] 5%
Training greetings.yml: [####################] 100%] 4%
2019-03-13 19:13:02.410 Training health.yml: [####################] 100%
Training history.yml: [####################] 100% ] 12%
Training humor.yml: [####################] 100% 2%
Training literature.yml: [####################] 100%] 3%
Training money.yml: [####################] 100%] 3%
Training movies.yml: [####################] 100%] 4%
Training politics.yml: [####################] 100%] 6%
Training psychology.yml: [####################] 100% 1%
Training science.yml: [####################] 100%] 3%
Training sports.yml: [####################] 100%] 5%
Training trivia.yml: [####################] 100% ] 10%
Training greetings.yml: [####################] 100%] 4%
Training conversations.yml: [####################] 100%] 6%
2019-03-13 19:13:04.589 How many meters are in a kilometer? - Response: 1000.0
2019-03-13 19:13:04.797 How many meters are in one inch - Response: 0.0254
2019-03-13 19:13:05.007 0 celsius to fahrenheit - Response: 32.00000039999997
2019-03-13 19:13:05.215 one hour is how many minutes ? - Response: 60.0
jthomas commented 5 years ago

@karanrk I'm going to close this as this looks like it was a configuration error rather than a bug in the framework.

Let me know if you are still having issues....