Skip to content

Commit

Permalink
test: update priority in route to 2^46 - 1 (#444)
Browse files Browse the repository at this point in the history
* update priority in route to 2^46 - 1

* define const for max route priority
  • Loading branch information
randmonkey authored May 10, 2024
1 parent 2c2b379 commit 353b66d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions kong/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ type Route struct {
ResponseBuffering *bool `json:"response_buffering,omitempty" yaml:"response_buffering,omitempty"`
}

const (
// maxRoutePriorityBits is the maximum number of bits that can be used in `priority` field of route.
maxRoutePriorityBits = 46
// MaxRoutePriority is the maximum value can be used in `priority` field of routes when Kong gateway runs expression router.
// Kong gateway 3.7 has limited it to 2^46-1 .
MaxRoutePriority = (1 << maxRoutePriorityBits) - 1
)

// CIDRPort represents a set of CIDR and a port.
// +k8s:deepcopy-gen=true
type CIDRPort struct {
Expand Down
2 changes: 1 addition & 1 deletion kong/route_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func TestRoutesValidationExpressions(T *testing.T) {
name: "valid expression with priority",
route: &Route{
Expression: String(`lower(http.path) ^= "/prefix/"`),
Priority: Uint64(3382097767104500),
Priority: Uint64(MaxRoutePriority),
},
valid: true,
},
Expand Down

0 comments on commit 353b66d

Please sign in to comment.