Skip to content

Extension: add dynamic metadata #16266

Closed
Closed

Description

@aguinet

Title: Simple extension to add dynamic metadata

Description:
This extension simply allows to add user-defined dynamic metadata. This is intended to be used with matchers, so that the "result" of a matching process can imply specific metadata.

I have implemented a Proof-of-Concept of this here: curiefense@6fdd5c0

Here is a usage example: curiefense@26f8480#diff-e7b7df56dda737de6cebca4a1ebe1b9d391811c12d2ff1a782409a8d6f8e9f5dR42-R79

I would like some advices before going further:

Thanks for any insights!

Regards,

cc @snowp

Activity

  1. added
    enhancement
    triage
    on May 1, 2021
  2. snowp commented on May 4, 2021

    @snowp
    Contributor

    SGTM, happy to sponsor this. High level this sounds right, we can flesh out the details in PR reviews

    For your first point I think you could achieve this nesting by having the API specify the Struct to set instead of a specific Value? That way you get more flexibility in setting multiple values, and solve the hierarchy issue. This raises some questions around wanting to have multiple filters set the same fields, but I think a simple merge -> last write wins mechanism would work well initially, with other merging strategies possible via configuration down the line.

  3. added
    no stalebot
    and removed
    triage
    on May 4, 2021
  4. aguinet commented on May 5, 2021

    @aguinet
    ContributorAuthor

    I tried merging two struct objects with Protobuf's Struct::mergeFrom function, but it seems too aggressive for what we want to do.

    In our case, the example is for instance two matchers that would create unique tags. One way to describe this would something like this:

              - name: mytag0
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.common.matching.v3.ExtensionWithMatcher
                  extension_config:
                   name: envoy.filters.http.set_metadata
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.filters.http.set_metadata.v3.Config
                      metadata_namespace: curiefense
                      value:
                        tags:
                          mytag0: 0             
                   matcher:...
              - name: mytag1
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.common.matching.v3.ExtensionWithMatcher
                  extension_config:
                    name: envoy.filters.http.set_metadata
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.filters.http.set_metadata.v3.Config
                      metadata_namespace: curiefense
                      value:
                        tags:
                          mytag1: 1
                  matcher:
                    ...
    

    In this case, MergeFrom would just replace the full content of tags with the new subobject. For instance, if the two filters are executed, we end up with:

    tags:
      mytag1: 1
    

    whereas we would have liked:

    tags:
      mytag0: 1
      mytag1: 1
    

    I was thinking instead implementing a "recursive merge" behavior, where only the last values in the object tree are replaced if they already exists, with a proper documentation explaining what is happening.

    I'm afraid this would make a specific behavior for this filter, which might be different from what currently exists in Envoy. What do you think?

    Thanks!

  5. added a commit that references this issue on May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementno stalebot

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions