hotfix: swap envoy rule header nil to last position (#662)

This commit is contained in:
naison
2025-07-04 19:53:16 +08:00
committed by GitHub
parent 61a33ff5bd
commit e490f72a78
3 changed files with 16 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"sort"
"strings"
"time"
@@ -260,6 +261,17 @@ func addVirtualRule(v []*controlplane.Virtual, ns, nodeID string, port []control
if v[index].Ports == nil {
v[index].Ports = port
}
// envoy rule have order, eg:
// 1. null header to a
// 2. foo=bar to b
// then will never hit to b
// so needs to let null header to last rule
for x := range v {
sort.SliceStable(v[x].Rules, func(i, j int) bool {
return len(v[x].Rules[i].Headers) != 0
})
}
return v
}