Skip to content

Envoy WASM singleton service per envoy instance #15860

Closed

Description

@NomadXD

Title: Envoy WASM singleton service per envoy instance

Description:
I have a requirement where I have to make a HTTP request to an external service and pull some data periodically. I implemented a HTTP filter in Rust and doing the HTTP call from the onTick in the RootContext. But RootContext gets created for each worker thread and for each worker thread , a HTTP occur. In the docs, there is an option for a Singleton service where I have to specify singleton: true. https://www.envoyproxy.io/docs/envoy/latest/configuration/other_features/wasm_service#config-wasm-service. However the config example is not very descriptive.

Configured as follows as mentioned in the docs. But envoy rejects the config at start up saying error initializing configuration '/etc/envoy/envoy.yaml': Protobuf message (type envoy.config.bootstrap.v3.Bootstrap reason INVALID_ARGUMENT:wasm: Cannot find field.) has unknown fields. Envoy version used in 1.17.1

admin:
  access_log_path: /dev/null
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 9000
wasm:
  config:
    config:
      name: "my_plugin"
      vm_config:
        runtime: "envoy.wasm.runtime.v8"
        code:
          local:
            filename: "/usr/local/bin/singleton_service.wasm"
    singleton: true
static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 9095

Activity

  1. added
    triage
    on Apr 6, 2021
  2. PiotrSikora commented on Apr 7, 2021

    @PiotrSikora
    Contributor

    That's not the way to configure a bootstrap extension, you need something like this:

    admin:
      access_log_path: /dev/null
      address:
        socket_address:
          address: 0.0.0.0
          port_value: 9000
    
    bootstrap_extensions:
    - name: envoy.bootstrap.wasm
      typed_config:
        '@type': type.googleapis.com/envoy.extensions.wasm.v3.WasmService
        singleton: true
        config:
          vm_config:
            runtime: "envoy.wasm.runtime.v8"
            code:
              local:
                filename: "/usr/local/bin/singleton_service.wasm"
    
    static_resources:
      listeners:
      - address:
          socket_address:
            address: 0.0.0.0
            port_value: 9095
  3. added and removed
    triage
    on Apr 7, 2021
  4. NomadXD commented on Apr 7, 2021

    @NomadXD
    ContributorAuthor

    @PiotrSikora Thank you. I think the docs for that relevant section has not been updated yet.

  5. PiotrSikora commented on Apr 7, 2021

    @PiotrSikora
    Contributor

    @NomadXD patches welcome!

  6. NomadXD commented on Apr 8, 2021

    @NomadXD
    ContributorAuthor

    @PiotrSikora Sure. Would like to contribute. Any specific procedure that I have to follow before sending a PR for the docs ?

  7. PiotrSikora commented on Apr 9, 2021

    @PiotrSikora
    Contributor

    No, simply update docs/root/configuration/other_features/wasm_service.rst and make sure that it generates properly (e.g. using ./ci/run_envoy_docker.sh './ci/do_ci.sh docs').

    If you want more about contributing to Envoy in general, there is CONTRIBUTING.md file that you could read.

  8. github-actions commented on May 9, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

  9. added
    stale
    on May 9, 2021
  10. PiotrSikora commented on May 14, 2021

    @PiotrSikora
    Contributor

    Fixed in #15914.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/wasmstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions