slime-io / slime

An intelligent ServiceMesh manager based on Istio
https://slime-io.github.io/
Other
424 stars 78 forks source link

plugin: wasm/rider plugin support default config #413

Closed YonkaFang closed 1 year ago

YonkaFang commented 1 year ago

背景

目前istio对wasm的支持会在pilot-agent中做远程插件到本地插件的转换,这个过程不具备最终一致性,也即 如果获取远程插件的过程中网络抖动一下获取失败的话,会导致envoy xds配置不可用,并且没有主动纠错、恢复机制。

同时,ECDS下发的插件不可用时带来的影响不只是配置拒绝,还会影响当前插件链的正常工作,也即影响业务请求处理。

所以有必要提高容错性: 通过ECDS的default config字段来做插件降级,让最坏情况的影响仅仅是插件本身无效。

设计

增加plugin module配置字段 map<string, google.protobuf.Struct> configDiscoveryDefaultConfig,用于配置不同插件类型的默认配置,key为 type url。

以rider为例,配置如下:

      configDiscoveryDefaultConfig:
        "type.googleapis.com/proxy.filters.http.rider.v3alpha1.FilterConfig":
          '@type': type.googleapis.com/udpa.type.v1.TypedStruct
          type_url: type.googleapis.com/proxy.filters.http.rider.v3alpha1.FilterConfig
          value:
            plugin:
              code:
                local:
                  inline_string: |
                    local test = {}
                    return test
              name: test
              vm_config:
                package_path: /usr/local/lib/rider/?/init.lua;/usr/local/lib/rider/?.lua;

生成的envoyfilter如下:

        config_discovery:
          config_source:
            ads: {}
          default_config:
            '@type': type.googleapis.com/udpa.type.v1.TypedStruct
            type_url: type.googleapis.com/proxy.filters.http.rider.v3alpha1.FilterConfig
            value:
              plugin:
                code:
                  local:
                    inline_string: |
                      local test = {}
                      return test
                name: test
                vm_config:
                  package_path: /usr/local/lib/rider/?/init.lua;/usr/local/lib/rider/?.lua;
          type_urls:
          - type.googleapis.com/proxy.filters.http.rider.v3alpha1.FilterConfig
YonkaFang commented 1 year ago
      configDiscoveryDefaultConfig:
        "type.googleapis.com/proxy.filters.http.rider.v3alpha1.FilterConfig":
          '@type': type.googleapis.com/udpa.type.v1.TypedStruct
          type_url: type.googleapis.com/proxy.filters.http.rider.v3alpha1.FilterConfig
          value:
            plugin:
              code:
                local:
                  inline_string: |
                    local test = {}
                    return test
              name: test
              vm_config:
                package_path: /usr/local/lib/rider/?/init.lua;/usr/local/lib/rider/?.lua;
        "type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm":
          '@type': type.googleapis.com/udpa.type.v1.TypedStruct
          type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
          value:
            config:
              name: default-wasm
              root_id: default-id
              vm_config:
                code:
                  local:
                    filename: /etc/envoy/default.wasm
                runtime: envoy.wasm.runtime.v8
YonkaFang commented 1 year ago

内容错误,实际为 https://github.com/slime-io/slime/pull/415 。 正确的PR见 ref 。