Skip to content

Commit 9e5104e

Browse files
committed
fix: calculate HTTPRoute Priority
Signed-off-by: ashing <[email protected]>
1 parent d9ae07a commit 9e5104e

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

.github/actions/add-pr-comment

Submodule add-pr-comment added at dd126dd

.github/workflows/apisix-conformance-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,11 @@ jobs:
124124
echo '```yaml' >> report.md
125125
cat apisix-ingress-controller-conformance-report.yaml >> report.md
126126
echo '```' >> report.md
127+
128+
- name: Report Conformance Test Result to PR Comment
129+
if: ${{ github.event_name == 'pull_request' }}
130+
uses: ./.github/actions/add-pr-comment
131+
with:
132+
message-id: 'apisix-conformance-test-report'
133+
message-path: |
134+
report.md

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
[submodule ".github/actions/markdown-link-check"]
2222
path = .github/actions/markdown-link-check
2323
url = https://github.com/gaurav-nelson/github-action-markdown-link-check.git
24+
[submodule ".github/actions/add-pr-comment"]
25+
path = .github/actions/add-pr-comment
26+
url = https://github.com/mshick/add-pr-comment.git

internal/provider/adc/translator/httproute.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,14 @@ func (t *Translator) translateBackendRef(tctx *provider.TranslateContext, ref ga
381381
// ref: https://github.com/Kong/kubernetes-ingress-controller/blob/57472721319e2c63e56cb8540425257e8e02520f/internal/dataplane/translator/subtranslator/httproute_atc.go#L279-L296
382382
func calculateHTTPRoutePriority(match *gatewayv1.HTTPRouteMatch, ruleIndex int, hosts []string) uint64 {
383383
const (
384-
// PreciseHostnameShiftBits assigns bit 43-50 for the length of hostname(max length=253).
385-
PreciseHostnameShiftBits = 43
386-
// HostnameLengthShiftBits assigns bits 35-42 for the length of hostname(max length=253).
387-
HostnameLengthShiftBits = 35
388-
// ExactPathShiftBits assigns bit 34 to mark if the match is exact path match.
389-
ExactPathShiftBits = 34
390-
// PathLengthShiftBits assigns bits 23-32 to path length. (max length = 1024, but must start with /)
391-
PathLengthShiftBits = 23
384+
// PreciseHostnameShiftBits assigns bit 31-38 for the length of hostname(max length=253).
385+
// which has 8 bits, so the max length of hostname is 2^8-1 = 255.
386+
PreciseHostnameShiftBits = 31
387+
388+
// HostnameLengthShiftBits assigns bits 23-30 for the length of hostname(max length=253).
389+
// which has 8 bits, so the max length of hostname is 2^8-1 = 255.
390+
HostnameLengthShiftBits = 23
391+
392392
// MethodMatchShiftBits assigns bit 22 to mark if method is specified.
393393
MethodMatchShiftBits = 22
394394
// HeaderNumberShiftBits assign bits 17-21 to number of headers. (max number of headers = 16)
@@ -429,20 +429,6 @@ func calculateHTTPRoutePriority(match *gatewayv1.HTTPRouteMatch, ruleIndex int,
429429
priority |= (uint64(maxHostnameLength) << HostnameLengthShiftBits)
430430
}
431431

432-
// ExactPathShiftBits
433-
if match.Path != nil && match.Path.Type != nil && *match.Path.Type == gatewayv1.PathMatchExact {
434-
priority |= (1 << ExactPathShiftBits)
435-
}
436-
437-
// PathLengthShiftBits
438-
// max length of path is 1024, but path must start with /, so we use PathLength-1 to fill the bits.
439-
if match.Path != nil && match.Path.Value != nil {
440-
pathLength := len(*match.Path.Value)
441-
if pathLength > 0 {
442-
priority |= (uint64(pathLength-1) << PathLengthShiftBits)
443-
}
444-
}
445-
446432
// MethodMatchShiftBits
447433
if match.Method != nil {
448434
priority |= (1 << MethodMatchShiftBits)

0 commit comments

Comments
 (0)