WasmEdge / WasmEdge

WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime for cloud native, edge, and decentralized applications. It powers serverless apps, embedded functions, microservices, smart contracts, and IoT devices.
https://WasmEdge.org
Apache License 2.0
8.58k stars 772 forks source link

bug: error trying to connect: dns error: Success (os error 85) when running on cluster #3317

Open KaiWalter opened 7 months ago

KaiWalter commented 7 months ago

Summary

When trying to call an (AKS cluster) internal service or an external service like

    let url =
        url::Url::parse("http://eu.httpbin.org/ip").map_err(|e| ServiceError::ParseError(e))?;
    tracing::info!("test url {}", url);

    let response = reqwest::Client::new()
        .get(url)
        .send()
        .await
        .map_err(|e| ServiceError::ReqwestError(e))?
        .text()
        .await
        .map_err(|e| ServiceError::ReqwestError(e))?;

I get this error when running on a cluster - with local wasmedge run the call is succeeding.

error sending request for url (http://eu.httpbin.org/ip): error trying to connect: dns error: Success (os error 85)

Current State

I install #wasmedge 0.3.0 with #kwasm node installer ghcr.io/kwasm/kwasm-node-installer:v0.3.1 on AKS,

add a runtime class,

apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
  name: wasmedge-v1
handler: wasmedge
scheduling:
  nodeSelector:
    agentpool: wasm

deploy a service with #knative-serving,

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: distributor
  namespace: default
spec:
  template:
    spec:
      runtimeClassName: wasmedge-v1
      timeoutSeconds: 1
      containers:
        - name: http-server
          image: { will be replaced by deployment script }
          ports:
            - containerPort: 8080
              protocol: TCP
          livenessProbe:
            tcpSocket:
              port: 8080
  traffic:
    - latestRevision: true
      percent: 100

Expected State

I expect DNS resolution of cluster is applied and call to internal and external services is succeeding.

Reproduction steps

  1. Build with options : wasmedge compile target/wasm32-wasi/release/warpwasi_dapr_rs.wasm target/warpwasi_dapr_rs.wasm
  2. Execute with flags : see call to WasmEdge SDK in runwasi containerd shim
  3. Execute with inputs : n.a.
  4. Get error

infrastructure: https://github.com/ZEISS/enterprise-wasm/tree/knative/infra/aks-kn-dapr module: https://github.com/ZEISS/enterprise-wasm/tree/knative/samples/warpwasi-dapr-rs

Screenshots

No response

Any logs you want to share for showing the specific issue

No response

Components

Rust SDK

WasmEdge Version or Commit you used

0.13.5

Operating system information

CBL-Mariner/Linux

Hardware Architecture

arm64

Compiler flags and options

No response

leothetryhard commented 5 days ago

For anyone facing the same issue, the workaround is providing the IP to the cluster DNS via environment variable in the deployment yaml:

containers:
  - name: http-server
    ...
    env:
       - name: DNS_SERVER
         value: "<ClusterIP>:53"

Get the IP with kubectl get svc -n kube-system kube-dns

alabulei1 commented 5 days ago

Thanks for sharing! @leothetryhard