apache / apisix-dashboard

Dashboard for Apache APISIX
https://apisix.apache.org/
Apache License 2.0
954 stars 511 forks source link

bug: upstream.upstreams() returns nil #2934

Open ali-mahdavi-mehr opened 4 months ago

ali-mahdavi-mehr commented 4 months ago

Current Behavior

When we update the upstreams in the dashboard, this value becomes nil. local upstreams, _ = upstream.upstreams()

Expected Behavior

Since APISIX is real-time, upstreams should be updated as soon as they are updated in the dashboard.

Error Logs

local upstreams, _ = upstream.upstreams() upstream is a nil value

Steps to Reproduce

1- update the upstreams in the dashboard

Environment

ali-mahdavi-mehr commented 4 months ago

When an upstream is deleted, this error occurs even if no route uses it.

theweakgod commented 4 months ago

Could u please show me ur config.yaml of apisix and conf.yaml of dashboard?

ali-mahdavi-mehr commented 4 months ago

Could u please show me ur config.yaml of apisix and conf.yaml of dashboard?

APISIX config

apisix:
  node_listen: 9080
  enable_ipv6: false
  enable_control: true
  control:
    ip: "0.0.0.0"
    port: 9092

  extra_lua_path: "/lua_extra/?.lua"
  extra_lua_cpath: ""

deployment:
  admin:
    allow_admin:
      - 0.0.0.0/0

  etcd:
    host:
      - "http://etcd:2379"
    prefix: "/apisix"
    timeout: 30

plugin_attr:
  prometheus:
    export_addr:
      ip: "0.0.0.0"
      port: 9091
    metrics:
      http_status:
        extra_labels:
          - upstream_addr: $upstream_addr
      http_latency:
        extra_labels:
          - upstream_addr: $upstream_addr
      bandwidth:
        extra_labels:
          - upstream_addr: $upstream_addr

nginx_config:
  envs:
    - NGINX_PORT

plugins:
  - api-breaker
  - authz-keycloak
  - basic-auth
  - batch-requests
  - consumer-restriction
  - cors
  - ext-plugin-post-resp
  - ext-plugin-post-req
  - ext-plugin-pre-req
  - fault-injection
  - grpc-transcode
  - hmac-auth
  - http-logger
  - ip-restriction
  - jwt-auth
  - kafka-logger
  - key-auth
  - limit-conn
  - limit-count
  - limit-req
  - openid-connect
  - prometheus
  - proxy-cache
  - proxy-mirror
  - proxy-rewrite
  - redirect
  - referer-restriction
  - request-id
  - request-validation
  - response-rewrite
  - serverless-post-function
  - serverless-pre-function
  - sls-logger
  - tcp-logger
  - udp-logger
  - uri-blocker
  - wolf-rbac
  - zipkin
  - server-info
  - traffic-split
  - elasticsearch-logger

ext-plugin:
  cmd: ["/plugins/go-runner", "run"]
  path_for_test: /tmp/runner.sock

Dashboard config:

conf:
  listen:
    host: 0.0.0.0
    port: 9000
  allow_list:
    - 0.0.0.0/0
  etcd:
    endpoints:
      - "http://etcd:2379"

    mtls:
      key_file: ""
      cert_file: ""
      ca_file: ""

  log:
    error_log:
      level: warn 
      file_path:
        logs/error.log 

    access_log:
      file_path:
        logs/access.log 
  security:
      content_security_policy: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; frame-src *"

authentication:
  enable: false
  secret:
    secret

  expire_time: 360000     
  users:                
    - username: admin   
      password: admin
    - username: user
      password: user

plugins:                      
  - api-breaker
  - authz-keycloak
  - basic-auth
  - batch-requests
  - consumer-restriction
  - cors
  - echo
  - fault-injection
  - grpc-transcode
  - hmac-auth
  - http-logger
  - ip-restriction
  - jwt-auth
  - kafka-logger
  - key-auth
  - limit-conn
  - limit-count
  - limit-req
  - openid-connect
  - prometheus
  - proxy-cache
  - proxy-mirror
  - proxy-rewrite
  - redirect
  - referer-restriction
  - request-id
  - request-validation
  - response-rewrite
  - serverless-post-function
  - serverless-pre-function
  - sls-logger
  - tcp-logger
  - udp-logger
  - uri-blocker
  - wolf-rbac
  - zipkin
  - server-info
  - traffic-split
  - ext-plugin-post-resp
  - ext-plugin-post-req
  - ext-plugin-pre-req
  - elasticsearch-logger
theweakgod commented 4 months ago
  etcd:
    host:
      - "http://etcd:2379"
    prefix: "/apisix"
    timeout: 30
etcd:
   endpoints:
     - "http://etcd:2379"

You might need to change it to the correct host instead of using etcd:2379, as DNS might not resolve correctly.

ali-mahdavi-mehr commented 4 months ago
  etcd:
    host:
      - "http://etcd:2379"
    prefix: "/apisix"
    timeout: 30
etcd:
   endpoints:
     - "http://etcd:2379"

You might need to change it to the correct host instead of using etcd:2379, as DNS might not resolve correctly.

I set the value but no change occurred.

hanqingwu commented 4 months ago

Can you provide some logs about apisix , please?