faasflow / faas-flow-example

Example flows cooked with faas-flow
11 stars 4 forks source link

[ Failed ] failed to execute request #8

Closed springCozyRock closed 7 months ago

springCozyRock commented 7 months ago

I am a student, and your help means a lot to me. @s8sg @pasdam I was trying out faas-flow-example, and take Sync-chain for example. As the following figure shows, I successfully deployed them to OpenFaas API gateway, and I can invoked the function. But with failed information.

image

I checked the logs. basically connection refused error. But I can invoke func1, func2 in the ui. Why can't I invoke them in sync-chain function???

2024/03/10 12:18:35 stdout: [Request `cnmqa6qdbmlc70fup2jg`] Executing node 0_1_sync
2024/03/10 12:18:35 stdout: [Request `cnmqa6qdbmlc70fup2jg`] Executing function `func1`
2024/03/10 12:18:35 stdout: [Request `cnmqa6qdbmlc70fup2jg`] Failed: Node(0_1_sync), Operation (func1), error: execution failed, Function(func1), error: function execution failed, Post "http://localhost:31112/function/func1": dial tcp [::1]:31112: connect: connection refused
2024/03/10 12:18:35 stderr: 2024/03/10 12:18:35 Reporting span 0385fbc86a493339:6afb878cc7e86aac:68d885664cf3df05:1
2024/03/10 12:18:35 stderr: 2024/03/10 12:18:35 Reporting span 0385fbc86a493339:0385fbc86a493339:0000000000000000:1
2024/03/10 12:18:35 stderr: 2024/03/10 12:18:35 Node(0_1_sync), Operation (func1), error: execution failed, Function(func1), error: function execution failed, Post "http://localhost:31112/function/func1": dial tcp [::1]:31112: connect: connection refused
2024/03/10 12:18:35 stdout: [ Failed ] failed to execute request
2024/03/10 12:18:35 stderr: 2024/03/10 12:18:35 http: superfluous response.WriteHeader call from main.makeRequestHandler.func1 (main.go:89)
2024/03/10 12:18:35 POST / - 200 OK - ContentLength: 37

Some configuration information are as follows flow.yml

environment:
  gateway: "localhost:31112"
  enable_tracing: true
  trace_server: "jaeger-agent.faasflow:5775"
  enable_hmac: true
  consul_url: "consul.faasflow:8500"
  consul_dc: "dc1"
  s3_url: "minio.faasflow:9000"
  s3_tls: false

stack.yml

provider:
  name: openfaas
  gateway: http://127.0.0.1:31112

functions:
  sync-chain:
    lang: faas-flow
    handler: ./sync-chain
    image: s8sg/sync-chain-example:2.0.0
    labels:
      faas-flow: 1
    annotations:
      faas-flow-desc: "flow for a example synchronous chain execution"
    environment_file:
      - flow.yml
    secrets:
      - s3-secret-key
      - s3-access-key

  # async-chain:
  #   lang: faas-flow
  #   handler: ./async-chain
  #   image: s8sg/async-chain-example:2.0.0
  #   labels:
  #     faas-flow: 1
  #   annotations:
  #     faas-flow-desc: "flow for a example asynchronous chain execution"
  #   environment_file:
  #     - flow.yml
  #   secrets:
  #     - s3-secret-key
  #     - s3-access-key

  # parallel-branching:
  #   lang: faas-flow
  #   handler: ./parallel-branching
  #   image: s8sg/parallel-branching-example:2.0.0
  #   labels:
  #     faas-flow: 1
  #   annotations:
  #     faas-flow-desc: "flow for a example parallel branch execution"
  #   environment_file:
  #     - flow.yml
  #   secrets:
  #     - s3-secret-key
  #     - s3-access-key

  # dynamic-branching:
  #   lang: faas-flow
  #   handler: ./dynamic-branching
  #   image: s8sg/dynamic-branching-example:2.0.0
  #   labels:
  #     faas-flow: 1
  #   annotations:
  #     faas-flow-desc: "flow for a example dynamic branch execution"
  #   environment_file:
  #     - flow.yml
  #   secrets:
  #     - s3-secret-key
  #     - s3-access-key

  # conditional-branching:
  #   lang: faas-flow
  #   handler: ./conditional-branching
  #   image: s8sg/conditional-branching:2.0.0
  #   labels:
  #     faas-flow: 1
  #   annotations:
  #     faas-flow-desc: "flow for a example synchronous chain execution"
  #   environment_file:
  #     - flow.yml
  #   secrets:
  #     - s3-secret-key
  #     - s3-access-key

  func1:
    lang: python3-http
    handler: ./func1
    image: s8sg/func1-example:1.0.0

  func2:
    lang: python3-http
    handler: ./func2
    image: s8sg/func2-example:1.0.0

  fake-storage:
    lang: python3-http
    handler: ./fake-storage
    image: s8sg/fake-storage:1.0.0
    environment:
      write_debug: true
      combine_output: false
springCozyRock commented 7 months ago

update: solved I have known why, change the environment - gateway from localhost:31112 to gateway.openfaas, although I still don't know why. Can you help me? @s8sg @pasdam flow.yml

environment:
  gateway: "gateway.openfaas"
  enable_tracing: true
  trace_server: "jaeger-agent.faasflow:5775"
  enable_hmac: true
  consul_url: "consul.faasflow:8500"
  consul_dc: "dc1"
  s3_url: "minio.faasflow:9000"
  s3_tls: false
pasdam commented 7 months ago

I'm not involved in the project anymore unfortunately. but from the sound of it, it looks like openfass gateway is deployed in a different container than your function, hence when the function tries to call the gateway on localhost can't reach it (localhost from the perspective of the function is only the container where the function is executing), so you need to use a proper dns hostname to call it.