Skip to content

Seeing stats for http connection manager that has been removed from the filter chain #17690

Closed

Description

@akhila1012

Hi all,

I am seeing the following behavior with HTTP connection manager stats and wanted to check if the behavior is expected.
Below is my dynamic listener config

"dynamic_listeners": [
    {
     "name": "listener",
     "active_state": {
      "listener": {
       "@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
       "name": "listener",
       },
       "filter_chains": [
        {
         "filter_chain_match": {
          "server_names": [
           "foo.com"
          ]
         },
        "filters": [
        {
        "name": "envoy.http_connection_manager",
           "typed_config": {
            "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
            "stat_prefix": "foo",
            "rds": {
             "config_source": {
              "ads": {},
              "resource_api_version": "V3"
             },
             "route_config_name": "foo"
            },
       ]
       },
       {
         "filter_chain_match": {
          "server_names": [
           "bar.com"
          ]
         },
        "filters": [
        {
        "name": "envoy.http_connection_manager",
           "typed_config": {
            "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
            "stat_prefix": "bar",
            "rds": {
             "config_source": {
              "ads": {},
              "resource_api_version": "V3"
             },
             "route_config_name": "bar"
            },
          ]
         }
 ]

and with this config, on the stats endpoint, I was seeing the following stats:

http.foo.downstream_cx_active: 0
http.bar.downstream_cx_active:0
.

I have then made an update to the filter chain wherein I removed the filter chain corresponding to bar.com, i.e there's only one HTTP connection manager now matching on foo.com, I was expecting that there won't be anymore HTTP connection manager related stats from stat_prefix bar, but that's not happening. Even after filter chain and listener update, I am seeing stats such as http.bar.downstream_cx_active: 0. The envoy config also seems to be correct, but I am able to see stats corresponding to deleted HTTP connection manager.

May I know if this is the expected behavior from envoy stats?

Activity

  1. added
    triage
    on Aug 12, 2021
  2. changed the title [-]Seeing stats for http connection manager that has been removed from the filter chain on the stats endpoint[/-] [+]Seeing stats for http connection manager that has been removed from the filter chain[/+] on Aug 12, 2021
  3. ggreenway commented on Aug 13, 2021

    @ggreenway
    Member

    Do the extra stats stay there forever, or only for awhile? I think it is expected that they would remain while the old listener config is draining. I think the default time for that is 15 minutes.

  4. added
    question
    and removed
    triage
    on Aug 13, 2021
  5. akhila1012 commented on Aug 13, 2021

    @akhila1012
    Author

    Hello @ggreenway, it's not for a while, I don't see them vanishing until I re-start envoy again. I have enabled debug logs and checked that the stats stay around even after the old listener is completely drained.

    I am observing this happen with all the downstream stats. For example, I have had other filters in the filter chain whose stats also stay around after the filters are removed. Same is not the case for upstream ones i..e when I remove a cluster from a config, the upstream stats corresponding to the cluster are removed once the cluster is removed.

  6. ggreenway commented on Aug 13, 2021

    @ggreenway
    Member

    cc @mattklein123. This seems unexpected to me; is it possible the listener never finishes draining?

  7. mattklein123 commented on Aug 13, 2021

    @mattklein123
    Member

    This is not expected. It's possible this is a bug around the listener intelligent / filter chain update only feature? cc @jmarantz @lambdai

  8. added
    investigate
    and removed
    question
    on Aug 13, 2021
  9. mattklein123 commented on Aug 13, 2021

    @mattklein123
    Member

    (I'm wondering if a scope is shared across the entire listener, but really it should be per-filter chain.)

  10. akhila1012 commented on Aug 13, 2021

    @akhila1012
    Author

    These were the envoy debug logs from the time I removed the filter chain

    [2021-08-13T17:51:00.694194Z][Envoy][1][debug][config]begin add/update listener: name=listener hash=11615887453658398091
    [2021-08-13T17:51:00.694233Z][Envoy][1][debug][config]use in place update filter chain update path for listener name=listener hash=11615887453658398091
    [2021-08-13T17:51:00.694261Z][Envoy][1][debug][config]  filter #0:
    [2021-08-13T17:51:00.694262Z][Envoy][1][debug][config]    name: envoy.filters.listener.tls_inspector
    [2021-08-13T17:51:00.694277Z][Envoy][1][debug][config]  config: {}
    
    [2021-08-13T17:51:00.703653Z][Envoy][1][debug][config]new fc_contexts has 9 filter chains, including 0 newly built
    [2021-08-13T17:51:00.703664Z][Envoy][1][debug][config]add warming listener: name=listener, hash=11615887453658398091, address=[::]:10000
    [2021-08-13T17:51:00.703667Z][Envoy][1][debug][misc]Initialize listener listener local-init-manager.
    [2021-08-13T17:51:00.703669Z][Envoy][1][debug][init]init manager Listener-local-init-manager listener 11615887453658398091 contains no targets
    [2021-08-13T17:51:00.703670Z][Envoy][1][debug][init]init manager Listener-local-init-manager listener 11615887453658398091 initialized, notifying Listener-local-init-watcher listener
    [2021-08-13T17:51:00.703671Z][Envoy][1][debug][config]execute in place filter chain update: name=listener, hash=11615887453658398091, address=[::]:10000
    [2021-08-13T17:51:00.703672Z][Envoy][1][debug][config]replacing existing listener 1
    [2021-08-13T17:51:00.703706Z][Envoy][1][debug][config]replacing existing listener 1
    [2021-08-13T17:51:00.703730Z][Envoy][1][debug][config]replacing existing listener 1
    [2021-08-13T17:51:00.703752Z][Envoy][1][debug][config]replacing existing listener 1
    [2021-08-13T17:51:00.703788Z][Envoy][1][debug][config]replacing existing listener 1
    [2021-08-13T17:51:00.703812Z][Envoy][1][debug][config]replacing existing listener 1
    [2021-08-13T17:51:00.703842Z][Envoy][1][debug][config]replacing existing listener 1
    [2021-08-13T17:51:00.703867Z][Envoy][1][debug][config]replacing existing listener 1
    [2021-08-13T17:51:00.706894Z][Envoy][1][debug][config]draining 1 filter chains in listener listener: name=listener, hash=12608909188243545912, address=[::]:10000
    [2021-08-13T17:51:00.706901Z][Envoy][1][info][upstream]lds: add/update listener 'listener'
    [2021-08-13T17:51:00.706915Z][Envoy][1][debug][config]Resuming discovery requests for type.googleapis.com/envoy.config.route.v3.RouteConfiguration (previous count 1)
    [2021-08-13T17:51:00.706915Z][Envoy][1][debug][config]Resuming discovery requests for type.googleapis.com/envoy.api.v2.RouteConfiguration (previous count 1)
    [2021-08-13T17:51:00.706918Z][Envoy][1][debug][config]gRPC config for type.googleapis.com/envoy.config.listener.v3.Listener accepted with 1 resources with version d7a307b4-20b3-4c6d-8f97-67184a2a8591
    [2021-08-13T17:51:00.706958Z][Envoy][1][debug][config]Resuming discovery requests for type.googleapis.com/envoy.config.listener.v3.Listener (previous count 1)
    [2021-08-13T17:51:03.329722Z][Envoy][1][debug][main]flushing stats
    [2021-08-13T17:53:00.700681Z][Envoy][1][debug][config]removing draining filter chains from listener listener: name=listener, hash=12608909188243545912, address=[::]:10000
    [2021-08-13T17:53:00.701440Z][Envoy][1][debug][config]draining filter chains from listener listener complete: name=listener, hash=12608909188243545912, address=[::]:10000
    [2021-08-13T17:53:00.701496Z][Envoy][1][debug][init]Listener-local-init-watcher listener destroyed
    [2021-08-13T17:53:00.702126Z][Envoy][1][debug][init]init manager RDS local-init-manager foo destroyed
    [2021-08-13T17:53:00.702137Z][Envoy][1][debug][init]target RdsRouteConfigSubscription local-init-target foo destroyed
    [2021-08-13T17:53:00.702139Z][Envoy][1][debug][init]RDS local-init-watcher foo destroyed
    [2021-08-13T17:53:00.702142Z][Envoy][1][debug][init]shared target RdsRouteConfigSubscription init foo destroyed
    [2021-08-13T17:53:00.703057Z][Envoy][1][debug][init]init manager Listener-local-init-manager listener 12608909188243545912 destroyed
    [2021-08-13T17:53:00.703063Z][Envoy][1][debug][init]target Listener-init-target listener destroyed
    
  11. mattklein123 commented on Aug 13, 2021

    @mattklein123
    Member

    Yeah I just looked and I believe the issue is we have a scope for the entire listener, when we actually need it to be per-filter chain. Will switch this to bug, thanks for reporting! cc @lambdai for a potential fix.

  12. added and removed
    investigate
    on Aug 13, 2021
  13. nitgoy commented on Aug 14, 2021

    @nitgoy
    Contributor

    Plugging in the related feature ask #15185. Not sure if that'd help or suffer from exact same issue. But if metrics could be split by filter chain names then we don't need to rely on stat_prefix supplied to individual filters.

  14. self-assigned this
    on Aug 14, 2021
  15. lambdai commented on Aug 14, 2021

    @lambdai
    Contributor

    Is there any concerns around the overhead on introducing new stats scopes?

  16. mattklein123 commented on Aug 16, 2021

    @mattklein123
    Member

    Is there any concerns around the overhead on introducing new stats scopes?

    IMO no, scopes are pretty lightweight and I don't see an issue with having one per filter chain. @jmarantz wdyt?

  17. jmarantz commented on Aug 16, 2021

    @jmarantz
    Contributor

    What's the lifetime of the filter chain? The filters are request-scoped and recycling scopes at that level might have some overhead. But if they last until an xDS update changes the filter configuration that seems fine.

  18. lambdai commented on Aug 17, 2021

    @lambdai
    Contributor

    Thank you for the confirm! The lifetime should be along with filter chain config. It lasts 1+ LDS update.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions