mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-09-26 19:31:17 +08:00
hotfix: swap envoy rule header nil to last position (#662)
This commit is contained in:
@@ -53,9 +53,9 @@ func (c *ConnectOptions) Cleanup(logCtx context.Context) {
|
||||
if c.dhcp != nil {
|
||||
err := c.dhcp.ReleaseIP(ctx, ipv4, ipv6)
|
||||
if err != nil {
|
||||
plog.G(logCtx).Errorf("Failed to release IP to DHCP server: %v", err)
|
||||
plog.G(logCtx).Errorf("Failed to IPv4 %v IPv6 %v: %v", ipv4, ipv6, err)
|
||||
} else {
|
||||
plog.G(logCtx).Infof("Releaseed IPv4 %v IPv6 %v to DHCP server", ipv4, ipv6)
|
||||
plog.G(logCtx).Infof("Released IPv4 %v IPv6 %v", ipv4, ipv6)
|
||||
}
|
||||
}
|
||||
if c.clientset != nil {
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -193,9 +193,9 @@ func (h *admissionReviewHandler) handleDelete(ar v1.AdmissionReview) *v1.Admissi
|
||||
defer h.Unlock()
|
||||
err := h.dhcp.ReleaseIP(context.Background(), ipv4, ipv6)
|
||||
if err != nil {
|
||||
plog.G(context.Background()).Errorf("Failed to release IPv4 %v IPv6 %s to DHCP server: %v", ipv4, ipv6, err)
|
||||
plog.G(context.Background()).Errorf("Failed to release IPv4 %v IPv6 %s: %v", ipv4, ipv6, err)
|
||||
} else {
|
||||
plog.G(context.Background()).Debugf("Release IPv4 %v IPv6 %v to DHCP server", ipv4, ipv6)
|
||||
plog.G(context.Background()).Debugf("Release IPv4 %v IPv6 %v", ipv4, ipv6)
|
||||
}
|
||||
}
|
||||
return &v1.AdmissionResponse{Allowed: true}
|
||||
|
Reference in New Issue
Block a user