Skip to content

Commit

Permalink
chore(deps): bump github.com/kong/go-kong from 0.47.0 to 0.48.0 (#5012)
Browse files Browse the repository at this point in the history
* chore(deps): bump github.com/kong/go-kong from 0.47.0 to 0.48.0

Bumps [github.com/kong/go-kong](https:/kong/go-kong) from 0.47.0 to 0.48.0.
- [Release notes](https:/kong/go-kong/releases)
- [Changelog](https:/Kong/go-kong/blob/main/CHANGELOG.md)
- [Commits](Kong/go-kong@v0.47.0...v0.48.0)

---
updated-dependencies:
- dependency-name: github.com/kong/go-kong
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: adjust route priority calculation code after changing route priority to uint64

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Patryk Małek <[email protected]>
  • Loading branch information
dependabot[bot] and pmalek authored Oct 31, 2023
1 parent daa6bc0 commit 0422f3b
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 76 deletions.
5 changes: 5 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,8 @@ issues:
- forbidigo
text: "use of `(gatewayv1alpha2|gatewayv1beta1)"
path: (internal/gatewayapi/aliases.go|pkg/apis/.*/.*\.go)

- linters:
- revive
text: "var-declaration: should drop = 0 from declaration of var .*; it is the zero value"
path: \.go
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/google/uuid v1.4.0
github.com/jpillora/backoff v1.0.0
github.com/kong/deck v1.27.1
github.com/kong/go-kong v0.47.0
github.com/kong/go-kong v0.48.0
github.com/kong/kubernetes-telemetry v0.1.1
github.com/kong/kubernetes-testing-framework v0.41.1
github.com/lithammer/dedent v1.1.0
Expand Down Expand Up @@ -178,7 +178,7 @@ require (
github.com/sourcegraph/conc v0.3.0
github.com/spf13/cast v1.5.1 // indirect
github.com/ssgelm/cookiejarparser v1.0.1 // indirect
github.com/tidwall/gjson v1.16.0 // indirect
github.com/tidwall/gjson v1.17.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGC
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/kong/deck v1.27.1 h1:9R/pZpwOTYz80MHz5naoN0B/k+T+wBfCtGo1nliQQ+c=
github.com/kong/deck v1.27.1/go.mod h1:6FvrNHuCDf0I9PkUd5sPrK9EnfG4aQLhs0vPmdDRylE=
github.com/kong/go-kong v0.47.0 h1:fuZjRnUChITogljM4mY4HGGTKTaZM50970Wwg6EvQgs=
github.com/kong/go-kong v0.47.0/go.mod h1:QaLx1EsT+roe5V6h7aKghwLn0bXg7l/Bg8wzlcCmygc=
github.com/kong/go-kong v0.48.0 h1:vK1OpoxO50qlKdwPfmx9ChvkTKRsoCCB3b3iHo1umLc=
github.com/kong/go-kong v0.48.0/go.mod h1:qH4CEFqT83ywmu1TlMZX09clQH4B8/dX88CtT/jdv/E=
github.com/kong/kubernetes-telemetry v0.1.1 h1:q8iABCuonO16p5q6QVygr7J39G5o5jK5Y3w3ZlE8JC4=
github.com/kong/kubernetes-telemetry v0.1.1/go.mod h1:0yzRZVPwKeOQUFMWbROEJzUE1z8WWngWiujoYtdEEPA=
github.com/kong/kubernetes-testing-framework v0.41.1 h1:rYPOUZu7961lNApLkr4QaqsKaJBuY9HClCa0r7K4P+8=
Expand Down Expand Up @@ -435,8 +435,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/testcontainers/testcontainers-go v0.26.0 h1:uqcYdoOHBy1ca7gKODfBd9uTHVK3a7UL848z09MVZ0c=
github.com/testcontainers/testcontainers-go v0.26.0/go.mod h1:ICriE9bLX5CLxL9OFQ2N+2N+f+803LNJ1utJb1+Inx0=
github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg=
github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
Expand Down
4 changes: 2 additions & 2 deletions internal/dataplane/parser/atc/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

// ApplyExpression sets a Matcher as a Kong route's expression and assigns the route the given priority.
func ApplyExpression(r *kong.Route, m Matcher, priority int) {
func ApplyExpression(r *kong.Route, m Matcher, priority uint64) {
r.Expression = kong.String(m.Expression())
r.Priority = kong.Int(priority)
r.Priority = kong.Uint64(priority)
}
10 changes: 5 additions & 5 deletions internal/dataplane/parser/translate_httproute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ func TestIngressRulesFromSplitHTTPRouteMatchWithPriority(t *testing.T) {
Expression: kong.String(`http.path == "/v1/foo"`),
PreserveHost: kong.Bool(true),
StripPath: kong.Bool(false),
Priority: kong.Int(1024),
Priority: kong.Uint64(1024),
},
ExpressionRoutes: true,
},
Expand Down Expand Up @@ -1949,7 +1949,7 @@ func TestIngressRulesFromSplitHTTPRouteMatchWithPriority(t *testing.T) {
Expression: kong.String(`(http.host == "foo.com") && (http.path == "/v1/foo")`),
PreserveHost: kong.Bool(true),
StripPath: kong.Bool(false),
Priority: kong.Int(1024),
Priority: kong.Uint64(1024),
},
Plugins: []kong.Plugin{
{
Expand Down Expand Up @@ -2027,7 +2027,7 @@ func TestIngressRulesFromSplitHTTPRouteMatchWithPriority(t *testing.T) {
Expression: kong.String(`(http.host =^ ".foo.com") && (http.path == "/v1/foo")`),
PreserveHost: kong.Bool(true),
StripPath: kong.Bool(false),
Priority: kong.Int(1024),
Priority: kong.Uint64(1024),
},
ExpressionRoutes: true,
},
Expand Down Expand Up @@ -2079,7 +2079,7 @@ func TestIngressRulesFromSplitHTTPRouteMatchWithPriority(t *testing.T) {
Expression: kong.String(`http.host == "a.foo.com"`),
PreserveHost: kong.Bool(true),
StripPath: kong.Bool(false),
Priority: kong.Int(1024),
Priority: kong.Uint64(1024),
},
ExpressionRoutes: true,
},
Expand Down Expand Up @@ -2128,7 +2128,7 @@ func TestIngressRulesFromSplitHTTPRouteMatchWithPriority(t *testing.T) {
Expression: kong.String(translators.CatchAllHTTPExpression),
PreserveHost: kong.Bool(true),
StripPath: kong.Bool(false),
Priority: kong.Int(1024),
Priority: kong.Uint64(1024),
},
ExpressionRoutes: true,
},
Expand Down
5 changes: 5 additions & 0 deletions internal/dataplane/parser/translators/atc_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const (
ResourceKindBitsGRPCRoute = 1
)

type (
// RoutePriorityType is the type of priority field of Kong routes.
RoutePriorityType = uint64
)

const (
// CatchAllHTTPExpression is the expression to match all HTTP/HTTPS requests.
// For rules with no matches and no hostnames in its parent HTTPRoute or GRPCRoute,
Expand Down
20 changes: 10 additions & 10 deletions internal/dataplane/parser/translators/grpcroute_atc.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func CalculateGRCPRouteMatchPriorityTraits(match SplitGRPCRouteMatch) GRPCRouteP
//
// REVIEW: althogh not specified in official docs, do we need to assign a bit for GRPC method match type
// to assign higher priority for method match with `Exact` match?
func (t GRPCRoutePriorityTraits) EncodeToPriority() int {
func (t GRPCRoutePriorityTraits) EncodeToPriority() RoutePriorityType {
const (
// PreciseHostnameShiftBits assigns bit 49 for marking if the hostname is non-wildcard.
PreciseHostnameShiftBits = 49
Expand All @@ -318,15 +318,15 @@ func (t GRPCRoutePriorityTraits) EncodeToPriority() int {
// and start from all 1s, then decrease by one for each GRPCRoute.
)

var priority int
var priority RoutePriorityType
priority += ResourceKindBitsGRPCRoute << FromResourceKindPriorityShiftBits
if t.PreciseHostname {
priority += (1 << PreciseHostnameShiftBits)
}
priority += t.HostnameLength << HostnameLengthShiftBits
priority += t.ServiceLength << ServiceLengthShiftBits
priority += t.MethodLength << MethodLengthShiftBits
priority += t.HeaderCount << HeaderCountShiftBits
priority += RoutePriorityType(t.HostnameLength) << HostnameLengthShiftBits
priority += RoutePriorityType(t.ServiceLength) << ServiceLengthShiftBits
priority += RoutePriorityType(t.MethodLength) << MethodLengthShiftBits
priority += RoutePriorityType(t.HeaderCount) << HeaderCountShiftBits

return priority
}
Expand All @@ -343,7 +343,7 @@ type SplitGRPCRouteMatch struct {

type SplitGRPCRouteMatchToPriority struct {
Match SplitGRPCRouteMatch
Priority int
Priority uint64
}

// AssignRoutePriorityToSplitGRPCRouteMatches assigns priority to ALL split GRPCRoute matches
Expand All @@ -357,7 +357,7 @@ func AssignRoutePriorityToSplitGRPCRouteMatches(
logger logr.Logger,
splitGRPCouteMatches []SplitGRPCRouteMatch,
) []SplitGRPCRouteMatchToPriority {
priorityToSplitGRPCRouteMatches := map[int][]SplitGRPCRouteMatch{}
priorityToSplitGRPCRouteMatches := map[RoutePriorityType][]SplitGRPCRouteMatch{}
for _, match := range splitGRPCouteMatches {
priority := CalculateGRCPRouteMatchPriorityTraits(match).EncodeToPriority()
priorityToSplitGRPCRouteMatches[priority] = append(priorityToSplitGRPCRouteMatches[priority], match)
Expand All @@ -370,7 +370,7 @@ func AssignRoutePriorityToSplitGRPCRouteMatches(
// sort them then starts with 2^14 -1 and decrease by one for each GRPCRoute;
// If only one GRPCRoute occupies the priority, fill the relative order bits with all 1s.
const relativeOrderAssignedBits = 14
const defaultRelativeOrderPriorityBits = (1 << relativeOrderAssignedBits) - 1
const defaultRelativeOrderPriorityBits RoutePriorityType = (1 << relativeOrderAssignedBits) - 1

for priority, matches := range priorityToSplitGRPCRouteMatches {
if len(matches) == 1 {
Expand All @@ -387,7 +387,7 @@ func AssignRoutePriorityToSplitGRPCRouteMatches(
})

for i, match := range matches {
relativeOrderBits := defaultRelativeOrderPriorityBits - i
relativeOrderBits := defaultRelativeOrderPriorityBits - RoutePriorityType(i)
// Although it is very unlikely that there are 2^14 = 16384 GRPCRoutes
// should be given priority by their relative order, here we limit the
// relativeOrderBits to be at least 0.
Expand Down
30 changes: 15 additions & 15 deletions internal/dataplane/parser/translators/grpcroute_atc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) {
Route: kong.Route{
Name: kong.String("grpcroute.default.single-match.0.0"),
Expression: kong.String(`(http.path ^= "/service0/") && (http.headers.x_foo == "Bar")`),
Priority: kong.Int(1),
Priority: kong.Uint64(1),
},
},
},
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) {
Route: kong.Route{
Name: kong.String("grpcroute.default.single-match-with-hostname.0.0"),
Expression: kong.String(`(http.path == "/service0/method0") && ((http.host == "foo.com") || (http.host =^ ".foo.com"))`),
Priority: kong.Int(1),
Priority: kong.Uint64(1),
},
},
},
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) {
Route: kong.Route{
Name: kong.String("grpcroute.default.multiple-matches.0.0"),
Expression: kong.String(`(http.path =^ "/method0") && ((http.headers.client == "kong-test") && (http.headers.version == "2"))`),
Priority: kong.Int(1),
Priority: kong.Uint64(1),
},
},
{
Expand All @@ -148,7 +148,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) {
Route: kong.Route{
Name: kong.String("grpcroute.default.multiple-matches.0.1"),
Expression: kong.String(`http.path ~ "^/v[012]/.+"`),
Priority: kong.Int(1),
Priority: kong.Uint64(1),
},
},
},
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) {
Route: kong.Route{
Name: kong.String("grpcroute.default.single-match-with-annotations.0.0"),
Expression: kong.String(`(http.path == "/service0/method0") && (tls.sni == "kong.foo.com")`),
Priority: kong.Int(1),
Priority: kong.Uint64(1),
},
},
},
Expand All @@ -210,7 +210,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) {
Route: kong.Route{
Name: kong.String("grpcroute.default.hostname-only.0.0"),
Expression: kong.String(`http.host == "foo.com"`),
Priority: kong.Int(1),
Priority: kong.Uint64(1),
},
},
},
Expand Down Expand Up @@ -604,7 +604,7 @@ func TestGRPCRouteTraitsEncodeToPriority(t *testing.T) {
testCases := []struct {
name string
traits GRPCRoutePriorityTraits
exprectedPriority int
exprectedPriority RoutePriorityType
}{
{
name: "precise hostname",
Expand Down Expand Up @@ -653,7 +653,7 @@ func TestAssignRoutePriorityToSplitGRPCRouteMatches(t *testing.T) {
name string
splitGRPCRouteMatches []SplitGRPCRouteMatch
// GRPCRoute index -> priority
priorities map[splitGRPCRouteMatchIndex]int
priorities map[splitGRPCRouteMatchIndex]RoutePriorityType
}{
{
name: "no dupelicated fixed priority",
Expand Down Expand Up @@ -723,7 +723,7 @@ func TestAssignRoutePriorityToSplitGRPCRouteMatches(t *testing.T) {
},
},
},
priorities: map[splitGRPCRouteMatchIndex]int{
priorities: map[splitGRPCRouteMatchIndex]RoutePriorityType{
{
namespace: "default",
name: "grpcroute-1",
Expand Down Expand Up @@ -821,7 +821,7 @@ func TestAssignRoutePriorityToSplitGRPCRouteMatches(t *testing.T) {
MatchIndex: 0,
},
},
priorities: map[splitGRPCRouteMatchIndex]int{
priorities: map[splitGRPCRouteMatchIndex]RoutePriorityType{
{
namespace: "default",
name: "grpcroute-1",
Expand Down Expand Up @@ -918,7 +918,7 @@ func TestAssignRoutePriorityToSplitGRPCRouteMatches(t *testing.T) {
MatchIndex: 0,
},
},
priorities: map[splitGRPCRouteMatchIndex]int{
priorities: map[splitGRPCRouteMatchIndex]RoutePriorityType{
{
namespace: "default",
name: "grpcroute-1",
Expand Down Expand Up @@ -1028,7 +1028,7 @@ func TestAssignRoutePriorityToSplitGRPCRouteMatches(t *testing.T) {
MatchIndex: 1,
},
},
priorities: map[splitGRPCRouteMatchIndex]int{
priorities: map[splitGRPCRouteMatchIndex]RoutePriorityType{
{
namespace: "default",
name: "grpcroute-1",
Expand Down Expand Up @@ -1130,7 +1130,7 @@ func TestKongExpressionRouteFromSplitGRPCRouteWithPriority(t *testing.T) {
Name: kong.String("grpcroute.default.no-hostname-exact-method._.0.0"),
PreserveHost: kong.Bool(true),
Expression: kong.String(`http.path == "/pets/list"`),
Priority: kong.Int(1024),
Priority: kong.Uint64(1024),
},
ExpressionRoutes: true,
},
Expand Down Expand Up @@ -1182,7 +1182,7 @@ func TestKongExpressionRouteFromSplitGRPCRouteWithPriority(t *testing.T) {
Name: kong.String("grpcroute.default.precise-hostname-regex-method.foo.com.0.0"),
Expression: kong.String(`(http.path ~ "^/name/[a-z0-9]+") && (http.host == "foo.com")`),
PreserveHost: kong.Bool(true),
Priority: kong.Int(1024),
Priority: kong.Uint64(1024),
},
ExpressionRoutes: true,
},
Expand Down Expand Up @@ -1251,7 +1251,7 @@ func TestKongExpressionRouteFromSplitGRPCRouteWithPriority(t *testing.T) {
Name: kong.String("grpcroute.default.wildcard-hostname-header-match._.foo.com.0.1"),
Expression: kong.String(`(http.path ^= "/name/") && (http.headers.foo == "bar") && (http.host =^ ".foo.com")`),
PreserveHost: kong.Bool(true),
Priority: kong.Int(1024),
Priority: kong.Uint64(1024),
},
ExpressionRoutes: true,
},
Expand Down
Loading

0 comments on commit 0422f3b

Please sign in to comment.