Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update example to adapt Envoy 1.31 #742

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/dev_your_plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ DOCKER_MIRROR = m.daocloud.io/
# Both images use glibc 2.31. Ensure libc in the images match each other.
BUILD_IMAGE ?= $(DOCKER_MIRROR)docker.io/library/golang:1.21-bullseye
# We don't use istio/proxyv2 because it is not designed to be run separately (need to work around permission issue).
PROXY_IMAGE ?= $(DOCKER_MIRROR)docker.io/envoyproxy/envoy:contrib-v1.29.5
PROXY_IMAGE ?= $(DOCKER_MIRROR)docker.io/envoyproxy/envoy:contrib-v1.31.2
# We may need to use timestamp if we need to update the image in one PR
DEV_TOOLS_IMAGE ?= $(DOCKER_MIRROR)ghcr.io/mosn/htnn-dev-tools:2024-03-05
DEV_TOOLS_IMAGE ?= $(DOCKER_MIRROR)ghcr.io/mosn/htnn-dev-tools:2024-07-12

PROTOC = protoc

Expand Down
2 changes: 1 addition & 1 deletion examples/dev_your_plugin/cmd/libgolang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

func init() {
http.RegisterHttpFilterConfigFactoryAndParser("fm", filtermanager.FilterManagerFactory, &filtermanager.FilterManagerConfigParser{})
http.RegisterHttpFilterFactoryAndConfigParser("fm", filtermanager.FilterManagerFactory, &filtermanager.FilterManagerConfigParser{})
}

func main() {}
6 changes: 3 additions & 3 deletions examples/dev_your_plugin/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module mosn.io/htnn/dev_your_plugin
go 1.21

require (
github.com/envoyproxy/envoy v1.29.4
github.com/envoyproxy/envoy v1.31.0
github.com/stretchr/testify v1.9.0
google.golang.org/protobuf v1.33.0
mosn.io/htnn/api v0.3.2
google.golang.org/protobuf v1.34.1
mosn.io/htnn/api v0.3.3-0.20240924080219-d01ea9d6301e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it fair to say this api is not compatible for envoy 1.29 after the lib upgraded? Or we support both 1.28 and 1.31?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote a compatible layer for Envoy 1.29, so both Envoy 1.29 and 1.31 are supported. If we need to support Envoy 1.30, we can write a compatible layer for it.

Here are the steps to support Envoy 1.29: https://github.com/mosn/htnn/blob/main/site/content/en/docs/developer-guide/dataplane_support.md#choosing-the-target-data-plane-version. We use replace in go.mod and build tag to switch the Envoy SDK we used as Go doesn't support multiple version of the same library in one module. If you use the latest Envoy (1.31), you don't need to do anything - the support is out of the box.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! We're using envoy 1.31 for now, and having some old versions running in production as well. In case we will probably need to support multiple envoy versions in the long term for some useful filters, I would like to have your clarification here in the examples to guide us about maintaining multiple envoy versions for this example golang filter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wonderflow
Feel free to open an issue to ask for a new example about running HTNN on the old Envoy.
For now, you can refer to

COPY patch/switch-envoy-go-version.sh patch/switch-envoy-go-version.sh
COPY common.mk common.mk
# hadolint ignore=DL3003
RUN ./patch/switch-envoy-go-version.sh 1.29.5 && \
cd plugins/ && \
ENVOY_API_VERSION=1.29 make build-so-local

In this living code we build a shared lib target to the istio 1.21.3's data plane (which is covered by the e2e tests).

BTW, I don't recommend using HTNN on Envoy < 1.29. Versions before that are too old unless you can backport the latest Envoy Golang filter to an old version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dockefile above is helpful, thanks! What is our compatible strategy? I don't want old version support, but in the feature let's say when envoy 1.32 or newer version come out, when will we retire the 1.29 support?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is our compatible strategy?

We will maintain the Envoy X support as long as Envoy still provides security updates for version X or the istio version used by Ant Group (currently 1.21) requires version X.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's cool

)

require (
Expand Down
12 changes: 6 additions & 6 deletions examples/dev_your_plugin/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/P
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/envoy v1.29.4 h1:1c52LYxzA6arnSjpTfDyxCSrtztwVAnzekcGHirvq8Y=
github.com/envoyproxy/envoy v1.29.4/go.mod h1:c2OGLXJVY9BaTYPiWFRz6eUNaC+3TfqFKmkWS9brdKo=
github.com/envoyproxy/envoy v1.31.0 h1:NsTo+medzu0bMffXAjl+zKaViLOShKuIZWQnKKYq0/4=
github.com/envoyproxy/envoy v1.31.0/go.mod h1:ujBFxE543X8OePZG+FbeR9LnpBxTLu64IAU7A20EB9A=
github.com/envoyproxy/go-control-plane v0.12.1-0.20240117015050-472addddff92 h1:/3bsjkhOTh0swUKDBxL1+3MrXCxrf/sEEMseiIEJg00=
github.com/envoyproxy/go-control-plane v0.12.1-0.20240117015050-472addddff92/go.mod h1:ZBTaoJ23lqITozF0M6G4/IragXCQKCnYbmlmtHvwRG0=
github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A=
Expand Down Expand Up @@ -50,12 +50,12 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mosn.io/htnn/api v0.3.2 h1:3j63WhEkurhqCcly5PxDQkrP59AbIt2Qn0DwpsukQnU=
mosn.io/htnn/api v0.3.2/go.mod h1:DumqbmMou8J1/DzEDaRIZWpan82bOqxGceWxTju7WkU=
mosn.io/htnn/api v0.3.3-0.20240924080219-d01ea9d6301e h1:1BhDXAM4E1q4rKuOx61F2yozOKnazOg+Yj36UGiHPqs=
mosn.io/htnn/api v0.3.3-0.20240924080219-d01ea9d6301e/go.mod h1:LuQVGTOQos5tOLl7c+z4ukFO1eOfm/Q3GNQ+8OnlIhE=
2 changes: 1 addition & 1 deletion plugins/plugins/demo/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type filter struct {
config *config
}

// The doc of each API can be found in package pkg/filtermanager/api
// The doc of each API can be found in https://pkg.go.dev/mosn.io/htnn/api/pkg/filtermanager/api

func (f *filter) DecodeHeaders(headers api.RequestHeaderMap, endStream bool) api.ResultAction {
headers.Add(f.config.HostName, f.hello())
Expand Down
Loading