knix-microfunctions / knix

Serverless computing platform with process-based lightweight function execution and container-based application isolation. Works in Knative and bare metal/VM environments.

Home Page:https://knix.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error when workflow.excute. requests.exceptions.HTTPError: 405 Client Error: Not Allowed for url: http://XXXX:32777

lambda7xx opened this issue · comments

I change the nginx port to 12345/23456, then I use below code to depoly the workflow example. The GUI has my worklfow that means I have deployed it successful on the port 32777. Then, I execute the workflow use(response = workflow.execute("hello world",timeout=60)
)

import os
import shutil
import subprocess
import json
from zipfile import ZipFile
from functools import reduce
import argparse
import concurrent
from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED

from mfn_sdk import MfnClient



host='xxxx'


mfn = MfnClient(
    mfn_url=f'http://{host}',
    mfn_user="email",
    mfn_password="password",
    # mfn_name="test",
    proxies={
        "http": f'http://{host}:12345',
        "https": f'http://{host}:23456'
    })



fn = mfn.add_function("echo")
fn.source = {'code': """
def handle(event, context):
    context.log("Echoing event: "+str(event))
    print("hello world,DHY")
    return event
"""}

workflow = mfn.add_workflow("echo_wf")
workflow.json = """{
  "name": "echo_wf",
  "entry": "echo",
  "functions": [
    {
      "name": "echo",
      "next": ["end"]
    }
  ]
}"""

workflow.deploy(600)
request = {"hui":"hoi","blue":True,"Five":5}
response = workflow.execute(request,timeout=60)

response = workflow.execute("hello world",timeout=60)
print(response)
assert response == request

logdata = workflow.logs()
print("Exceptions:")
print(logdata['exceptions'])
print("Logs:")
print(logdata['log'])
print("Progress:")
print(logdata['progress'])

I meet the error log.

Traceback (most recent call last):
  File "deploy.py", line 54, in <module>
    response = workflow.execute(request,timeout=60)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/mfn_sdk/workflow.py", line 300, in execute
    r.raise_for_status()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 405 Client Error: Not Allowed for url: http://XXXXX:32777/

@iakkus I am sorry to bother you, thank you very much.

Check out the readme in tests. Create a copy of settings.json.sample as settings.json and modify that.

If you don't have a proxy, remove them. Then try the tests.

Copy a folder from the tests and use that as a template.

thank you. I can deploy my workflow on the knix. The echo_wf_lambda_hello in the below figure is the workflow I deployed.
image

The problem is that when I want to execute the workflow , it will raise error, The error is the below.

Traceback (most recent call last):
  File "deploy.py", line 150, in <module>
    response = workflow.execute(request,timeout=60)
  File "/usr/local/lib/python3.8/dist-packages/mfn_sdk/workflow.py", line 300, in execute
    r.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 405 Client Error: Not Allowed for url: http://ip:32768/

The response of workflow.exexucte(requests,timeout=60) is <Response [405]>

response = workflow.execute(request,timeout=60)

This is not a Knix error. There is a problem with your machine/firewall settings. Check out the error code 405 and search.

This is not a Knix error. There is a problem with your machine/firewall settings. Check out the error code 405 and search.

Thank you very much.

@iakkus

I cann't use the workflow.execute to execute the workflow. But I can use the follow code to execute a workflow that has a function. I think my firewall is OK

import requests
import time

url ="http://172.31.34.4:32853"

hello = {1:2, 3:4}
for i in range(10):
    start = time.time()
    rep = requests.post(url, json=hello )
    print(rep.json())
    duration = time.time() -start
    print(i, duration)

It seems the inventory.cfg has some problem.

[riak]
ip-172-31-34-4=172.31.34.4

[elasticsearch]
ip-172-31-34-4=172.31.34.4

[management]
ip-172-31-34-4=172.31.34.4

[nginx]
ip-172-31-34-4.us-east-2=172.31.34.4

[triggers_frontend]
ip-172-31-34-4=172.31.34.4


The inventory.cfg is only used during installation. And if you had a problem, you couldn't have installed knix properly.

If you get an http error, then that's the problem. Your error is on the server side, which means something on the server is not configured properly to handle this script that you are trying.

Also, the code that works is making a request to the server that passes (POST). If the other one is failing, then either you are doing something you should not or the server has a problem the way it passes the request.

The workflow.execute is using the same POST; that means the way you create your script has a problem related to the way you set it up, such that the url or method becomes wrong.

If you have deployed it via the GUI, and the requests.post works, then you can use that.

If you want to deploy programmitacally, then reuse the tests examples, which should be working.

I deploy the workflow programmitacally and I can not use the workflow.execute API to trigger it. Maybe there are some problem on my machine. Thank you very much and I will try to fix. If I have some update, I will post here