Skip to content

Commit

Permalink
change: switch the default Envoy version to 1.32 (#789)
Browse files Browse the repository at this point in the history
* change: switch the default Envoy version to 1.32

Signed-off-by: spacewander <[email protected]>

* add AddData

Signed-off-by: spacewander <[email protected]>

* build

Signed-off-by: spacewander <[email protected]>

* build

Signed-off-by: spacewander <[email protected]>

---------

Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander authored Nov 19, 2024
1 parent 0eac2c0 commit 5affbd8
Show file tree
Hide file tree
Showing 32 changed files with 192 additions and 144 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
envoy_version:
- 1.29
- 1.31
- 1.32
- dev
env:
ENVOY_API_VERSION: ${{ matrix.envoy_version }}
Expand All @@ -50,13 +51,13 @@ jobs:
FULL_ENVOY_VERSION=${ENVOY_API_VERSION}.0
if [[ $ENVOY_API_VERSION == dev ]]; then
# update this once there are more breaking changes
FULL_ENVOY_VERSION=1.31.1-0.20240909145059-353737786a7f
# This is the envoy:contrib-dev image pull in 2024-09-25.
FULL_ENVOY_VERSION=1.32.1-0.20241112025658-4fd9bb670eeb
# This is the envoy:contrib-dev image pull in 2024-11-12.
# Use docker inspect --format='{{index .RepoDigests 0}}' envoyproxy/envoy:contrib-dev to get the sha256 ID.
# We don't use the envoy:contrib-dev tag directly because it will be rewritten by the latest commit and
# our test suite uses IfPresent policy to pull image.
# We don't use the CI to catch the breaking change from the upstream so far.
export PROXY_IMAGE=envoyproxy/envoy@sha256:845c392c1f128a00c49439d129ca9f2c12ff8748aeb42c8aa2b3b8240d6e0d5b
export PROXY_IMAGE=envoyproxy/envoy@sha256:0eec2cbd45c2055ea37c2321e8b83f6907a95e98c250492b48ad9dab6a20a8cb
echo PROXY_IMAGE=$PROXY_IMAGE >> $GITHUB_ENV
fi
pushd ..
Expand Down Expand Up @@ -254,6 +255,8 @@ jobs:
./api-module-test-cover-1.29/cover_integration.out,
./api-module-test-cover-1.31/cover.out,
./api-module-test-cover-1.31/cover_integration.out,
./api-module-test-cover-1.32/cover.out,
./api-module-test-cover-1.32/cover_integration.out,
./api-module-test-cover-dev/cover.out,
./api-module-test-cover-dev/cover_integration.out,
./types-module-test-cover/cover.out,
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ linters:
- bodyclose
- contextcheck
- errcheck
- exportloopref # replace it with copyloopref once we upgrade the minimal Go requirement to 1.22
- copyloopvar
- forcetypeassert
- gocheckcompilerdirectives
- gocritic
Expand Down
6 changes: 3 additions & 3 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ module mosn.io/htnn/api

// This module puts the filtermanager and the API and test framework which can be used in the plugins.

go 1.21
go 1.22

require (
github.com/agiledragon/gomonkey/v2 v2.11.0
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa
github.com/envoyproxy/envoy v1.31.0
github.com/envoyproxy/envoy v1.32.0
github.com/envoyproxy/go-control-plane v0.12.1-0.20240117015050-472addddff92 // version used by istio 1.21
github.com/envoyproxy/protoc-gen-validate v1.0.4
github.com/go-logr/logr v1.4.1
Expand All @@ -31,7 +31,7 @@ require (
go.uber.org/zap v1.27.0
golang.org/x/net v0.24.0
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.34.1
google.golang.org/protobuf v1.35.1
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
8 changes: 4 additions & 4 deletions api/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.31.0 h1:NsTo+medzu0bMffXAjl+zKaViLOShKuIZWQnKKYq0/4=
github.com/envoyproxy/envoy v1.31.0/go.mod h1:ujBFxE543X8OePZG+FbeR9LnpBxTLu64IAU7A20EB9A=
github.com/envoyproxy/envoy v1.32.0 h1:l3WDpm1VsQ+HuvTTKV01p+hIEvoRPB4Mndt9pAg5B2Y=
github.com/envoyproxy/envoy v1.32.0/go.mod h1:KGS+IUehDX1mSIdqodPTWskKOo7bZMLLy3GHxvOKcJk=
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 @@ -59,8 +59,8 @@ 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.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
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=
Expand Down
6 changes: 6 additions & 0 deletions api/pkg/filtermanager/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ type StreamFilterCallbacks interface {
// ClearRouteCache clears the route cache for the current request, and filtermanager will re-fetch the route in the next filter.
// Please be careful to invoke it, since filtermanager will raise an 404 route_not_found response when failed to re-fetch a route.
ClearRouteCache()
// RefreshRouteCache works like ClearRouteCache, but it will re-fetch the route immediately.
RefreshRouteCache()

// Methods added by HTNN

Expand Down Expand Up @@ -248,6 +250,10 @@ type FilterProcessCallbacks interface {
SendLocalReply(responseCode int, bodyText string, headers map[string][]string, grpcStatus int64, details string)
// RecoverPanic recover panic in defer and terminate the request by SendLocalReply with 500 status code.
RecoverPanic()
// AddData add extra data when processing headers/trailers.
// For example, turn a headers only request into a request with a body, add more body when processing trailers, and so on.
// The second argument isStreaming supplies if this caller streams data or buffers the full body.
AddData(data []byte, isStreaming bool)

// hide Continue() method from the user
}
Expand Down
12 changes: 10 additions & 2 deletions api/pkg/filtermanager/api_impl_129.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ func (cb *filterManagerCallbackHandler) ClearRouteCache() {
api.LogErrorf("ClearRouteCache is not implemented: %s", debug.Stack())
}

func (cb *filterManagerCallbackHandler) RefreshRouteCache() {
api.LogErrorf("RefreshRouteCache is not implemented: %s", debug.Stack())
}

func (cb *filterManagerCallbackHandler) AddData([]byte, bool) {
api.LogErrorf("AddData is not implemented: %s", debug.Stack())
}

func (cb *filterManagerCallbackHandler) DecoderFilterCallbacks() api.DecoderFilterCallbacks {
return cb.FilterCallbackHandler
return cb
}

func (cb *filterManagerCallbackHandler) EncoderFilterCallbacks() api.EncoderFilterCallbacks {
return cb.FilterCallbackHandler
return cb
}

func (cb *filterManagerCallbackHandler) Continue(st capi.StatusType, _ bool) {
Expand Down
69 changes: 69 additions & 0 deletions api/pkg/filtermanager/api_impl_131_132.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright The HTNN Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !envoy1.29 && !envoydev

package filtermanager

import (
"runtime/debug"

capi "github.com/envoyproxy/envoy/contrib/golang/common/go/api"

"mosn.io/htnn/api/pkg/filtermanager/api"
)

func (cb *filterManagerCallbackHandler) RefreshRouteCache() {
api.LogErrorf("RefreshRouteCache is not implemented: %s", debug.Stack())
}

type decoderFilterCallbackHandlerWrapper struct {
capi.DecoderFilterCallbacks
}

func NewDecoderFilterCallbackHandlerWrapper(h capi.DecoderFilterCallbacks) api.DecoderFilterCallbacks {
return &decoderFilterCallbackHandlerWrapper{DecoderFilterCallbacks: h}
}

func (w *decoderFilterCallbackHandlerWrapper) AddData([]byte, bool) {
api.LogErrorf("AddData is not implemented: %s", debug.Stack())
}

func (cb *filterManagerCallbackHandler) DecoderFilterCallbacks() api.DecoderFilterCallbacks {
return NewDecoderFilterCallbackHandlerWrapper(cb.FilterCallbackHandler.DecoderFilterCallbacks())
}

type encoderFilterCallbackHandlerWrapper struct {
capi.EncoderFilterCallbacks
}

func NewEncoderFilterCallbackHandlerWrapper(h capi.EncoderFilterCallbacks) api.EncoderFilterCallbacks {
return &encoderFilterCallbackHandlerWrapper{EncoderFilterCallbacks: h}
}

func (w *encoderFilterCallbackHandlerWrapper) AddData([]byte, bool) {
api.LogErrorf("AddData is not implemented: %s", debug.Stack())
}

func (cb *filterManagerCallbackHandler) EncoderFilterCallbacks() api.EncoderFilterCallbacks {
return NewEncoderFilterCallbackHandlerWrapper(cb.FilterCallbackHandler.EncoderFilterCallbacks())
}

func (cb *filterManagerCallbackHandler) Continue(st capi.StatusType, decoding bool) {
if decoding {
cb.FilterCallbackHandler.DecoderFilterCallbacks().Continue(st)
} else {
cb.FilterCallbackHandler.EncoderFilterCallbacks().Continue(st)
}
}
2 changes: 1 addition & 1 deletion api/pkg/filtermanager/api_impl_latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !envoy1.29
//go:build envoydev

package filtermanager

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,51 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build envoydev
//go:build envoy1.29 || envoy1.31

package filtermanager

import (
capi "github.com/envoyproxy/envoy/contrib/golang/common/go/api"

"mosn.io/htnn/api/pkg/filtermanager/api"
)

const (
supportGettingHeadersOnLog = true
supportGettingHeadersOnLog = false
)

func (m *filterManager) OnLog(reqHdr capi.RequestHeaderMap, reqTrailer capi.RequestTrailerMap, rspHdr capi.ResponseHeaderMap, rspTrailer capi.ResponseTrailerMap) {
func (m *filterManager) OnLog(_ capi.RequestHeaderMap, _ capi.RequestTrailerMap, _ capi.ResponseHeaderMap, _ capi.ResponseTrailerMap) {
if m.canSkipOnLog {
return
}

wrappedReqHdr := &filterManagerRequestHeaderMap{
RequestHeaderMap: reqHdr,
}
m.runOnLogPhase(wrappedReqHdr, reqTrailer, rspHdr, rspTrailer)
var reqHdr api.RequestHeaderMap
m.hdrLock.Lock()
reqHdr = m.reqHdr
m.hdrLock.Unlock()
var rspHdr api.ResponseHeaderMap
m.hdrLock.Lock()
rspHdr = m.rspHdr
m.hdrLock.Unlock()

m.runOnLogPhase(reqHdr, nil, rspHdr, nil)
}

type filterManagerWrapper struct {
*filterManager
}

func (w *filterManagerWrapper) OnLog() {
w.filterManager.OnLog(nil, nil, nil, nil)
}

func wrapFilterManager(fm *filterManager) capi.StreamFilter {
return fm
return &filterManagerWrapper{fm}
}

// This method is test only
// This method is only for test
func unwrapFilterManager(wrapper capi.StreamFilter) *filterManager {
return wrapper.(*filterManager)
fmw, _ := wrapper.(*filterManagerWrapper)
return fmw.filterManager
}
40 changes: 11 additions & 29 deletions api/pkg/filtermanager/filtermanager_latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,35 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !envoydev
//go:build !envoy1.29 && !envoy1.31

package filtermanager

import (
capi "github.com/envoyproxy/envoy/contrib/golang/common/go/api"

"mosn.io/htnn/api/pkg/filtermanager/api"
)

const (
supportGettingHeadersOnLog = false
supportGettingHeadersOnLog = true
)

func (m *filterManager) OnLog(_ capi.RequestHeaderMap, _ capi.RequestTrailerMap, _ capi.ResponseHeaderMap, _ capi.ResponseTrailerMap) {
func (m *filterManager) OnLog(reqHdr capi.RequestHeaderMap, reqTrailer capi.RequestTrailerMap, rspHdr capi.ResponseHeaderMap, rspTrailer capi.ResponseTrailerMap) {
if m.canSkipOnLog {
return
}

var reqHdr api.RequestHeaderMap
m.hdrLock.Lock()
reqHdr = m.reqHdr
m.hdrLock.Unlock()
var rspHdr api.ResponseHeaderMap
m.hdrLock.Lock()
rspHdr = m.rspHdr
m.hdrLock.Unlock()

m.runOnLogPhase(reqHdr, nil, rspHdr, nil)
}

type filterManagerWrapper struct {
*filterManager
}

func (w *filterManagerWrapper) OnLog() {
w.filterManager.OnLog(nil, nil, nil, nil)
wrappedReqHdr := &filterManagerRequestHeaderMap{
RequestHeaderMap: reqHdr,
}
m.runOnLogPhase(wrappedReqHdr, reqTrailer, rspHdr, rspTrailer)
}

// we will get rid of this wrapper once Envoy 1.32 is released

func wrapFilterManager(fm *filterManager) capi.StreamFilter {
return &filterManagerWrapper{fm}
return fm
}

// This method is test only
// This method is only for test
func unwrapFilterManager(wrapper capi.StreamFilter) *filterManager {
fmw, _ := wrapper.(*filterManagerWrapper)
return fmw.filterManager
p, _ := wrapper.(*filterManager)
return p
}
2 changes: 1 addition & 1 deletion api/plugins/tests/integration/dataplane/data_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func StartDataPlane(t *testing.T, opt *Option) (*DataPlane, error) {
// Since we only care about the coverage in CI, it is fine so far.
}

image := "m.daocloud.io/docker.io/envoyproxy/envoy:contrib-v1.31.2"
image := "m.daocloud.io/docker.io/envoyproxy/envoy:contrib-v1.32.0"

specifiedImage := os.Getenv("PROXY_IMAGE")
if specifiedImage != "" {
Expand Down
6 changes: 6 additions & 0 deletions api/plugins/tests/pkg/envoy/capi.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ func (i *filterCallbackHandler) GetProperty(key string) (string, error) {
func (i *filterCallbackHandler) ClearRouteCache() {
}

func (i *filterCallbackHandler) RefreshRouteCache() {
}

func (i *filterCallbackHandler) AddData([]byte, bool) {
}

func (i *filterCallbackHandler) LookupConsumer(_, _ string) (api.Consumer, bool) {
return nil, false
}
Expand Down
Loading

0 comments on commit 5affbd8

Please sign in to comment.