Skip to content

Commit

Permalink
change: switch the default Envoy version to 1.32
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Nov 4, 2024
1 parent 21c6743 commit 631db37
Show file tree
Hide file tree
Showing 31 changed files with 134 additions and 141 deletions.
7 changes: 4 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.20241102031349-fcdc9d6d5a9d
# This is the envoy:contrib-dev image pull in 2024-11-04.
# 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:d7e833bc15746ff10734cabfbe9211d637ce4ea1d4e1bb678ed13b91e602a647
echo PROXY_IMAGE=$PROXY_IMAGE >> $GITHUB_ENV
fi
pushd ..
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
2 changes: 2 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
4 changes: 4 additions & 0 deletions api/pkg/filtermanager/api_impl_129.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ 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) DecoderFilterCallbacks() api.DecoderFilterCallbacks {
return cb.FilterCallbackHandler
}
Expand Down
27 changes: 27 additions & 0 deletions api/pkg/filtermanager/api_impl_131_132.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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"

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

func (cb *filterManagerCallbackHandler) RefreshRouteCache() {
api.LogErrorf("RefreshRouteCache is not implemented: %s", debug.Stack())
}
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 !envoydev && !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
3 changes: 3 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,9 @@ func (i *filterCallbackHandler) GetProperty(key string) (string, error) {
func (i *filterCallbackHandler) ClearRouteCache() {
}

func (i *filterCallbackHandler) RefreshRouteCache() {
}

func (i *filterCallbackHandler) LookupConsumer(_, _ string) (api.Consumer, bool) {
return nil, false
}
Expand Down
60 changes: 0 additions & 60 deletions api/tests/integration/filtermanager_dev_test.go

This file was deleted.

32 changes: 31 additions & 1 deletion api/tests/integration/filtermanager_latest_test.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 !envoy1.29 && !envoy1.31

package integration

Expand Down Expand Up @@ -309,3 +309,33 @@ Response trailers received:
})
}
}

func TestFilterManagerLogWithTrailers(t *testing.T) {
dp, err := dataplane.StartDataPlane(t, &dataplane.Option{
ExpectLogPattern: []string{
`receive request trailers: .*expires:Wed, 21 Oct 2015 07:28:00 GMT.*`,
},
})
if err != nil {
t.Fatalf("failed to start data plane: %v", err)
return
}
defer dp.Stop()

lp := &filtermanager.FilterManagerConfig{
Plugins: []*model.FilterConfig{
{
Name: "onLog",
Config: &Config{},
},
},
}

controlPlane.UseGoPluginConfig(t, lp, dp)
hdr := http.Header{}
trailer := http.Header{}
trailer.Add("Expires", "Wed, 21 Oct 2015 07:28:00 GMT")
resp, err := dp.PostWithTrailer("/echo", hdr, bytes.NewReader([]byte("test")), trailer)
require.Nil(t, err)
assert.Equal(t, 200, resp.StatusCode)
}
4 changes: 2 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ 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.22-bullseye
ENVOY_API_VERSION ?= 1.31
PROXY_IMAGE ?= $(DOCKER_MIRROR)docker.io/envoyproxy/envoy:contrib-v1.31.2
ENVOY_API_VERSION ?= 1.32
PROXY_IMAGE ?= $(DOCKER_MIRROR)docker.io/envoyproxy/envoy:contrib-v1.32.0
# We also support other Envoy versions. See https://github.com/mosn/htnn/tree/main/site/content/en/docs/developer-guide/dataplane_support.md

# We may need to use timestamp if we need to update the image in one PR
Expand Down
2 changes: 1 addition & 1 deletion controller/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module mosn.io/htnn/controller
// a non-release version of mosn.io/htnn/xxx module, you may need to manually update the
// dependency yourself, such as using replace in go.mod

go 1.21.5
go 1.22

require (
github.com/agiledragon/gomonkey/v2 v2.11.0
Expand Down
Loading

0 comments on commit 631db37

Please sign in to comment.