Skip to content

Commit

Permalink
feat(transparent-proxy): fix failed e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Chen <1180092+jijiechen@users.noreply.github.com>
  • Loading branch information
jijiechen committed Mar 13, 2024
1 parent 1fc16c4 commit 063bc90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions app/cni/pkg/cni/annotations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cni

import (
"fmt"
"strconv"
"strings"

Expand All @@ -25,7 +26,7 @@ var annotationRegistry = map[string]*annotationParam{
"excludeOutboundPorts": {"traffic.kuma.io/exclude-outbound-ports", defaultRedirectExcludePort, validatePortList},
"inboundPort": {"kuma.io/transparent-proxying-inbound-port", defaultInboundPort, validatePortList},
"inboundPortV6": {"kuma.io/transparent-proxying-inbound-v6-port", defaultInboundPortV6, validatePortList},
"ipFamilyMode": {"kuma.io/transparent-proxying-ip-family-mode", defaultIPFamilyMode, validateBool},
"ipFamilyMode": {"kuma.io/transparent-proxying-ip-family-mode", defaultIPFamilyMode, validateIpFamilyMode},
"outboundPort": {"kuma.io/transparent-proxying-outbound-port", defaultOutboundPort, validatePortList},
"isGateway": {"kuma.io/gateway", "false", alwaysValidFunc},
"builtinDNS": {"kuma.io/builtin-dns", "false", alwaysValidFunc},
Expand Down Expand Up @@ -97,18 +98,18 @@ func validatePortList(ports string) error {
return nil
}

func validateBool(val string) error {
func validateIpFamilyMode(val string) error {
if val == "" {
return errors.New("value is empty")
}

validValues := []string{"yes", "no", "true", "false"}
validValues := []string{"dualstack", "ipv4", "ipv6"}
for _, valid := range validValues {
if valid == val {
return nil
}
}
return errors.New("value is not valid")
return errors.New(fmt.Sprintf("value '%s' is not a valid IP family mode", val))
}

func getAnnotationOrDefault(name string, annotations map[string]string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/transparentproxy/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (pr *PodRedirect) AsKumactlCommandLine() []string {
}

result = append(result, "--ip-family-mode", pr.IpFamilyMode)
if pr.IpFamilyMode == metadata.IpFamilyModeDualStack &&
if pr.IpFamilyMode != metadata.IpFamilyModeIPv4 &&
pr.RedirectPortInboundV6 > 0 &&
pr.RedirectPortInboundV6 != pr.RedirectPortInbound {
result = append(result,
Expand Down

0 comments on commit 063bc90

Please sign in to comment.