Skip to content

Commit

Permalink
Fix usage of proxy-init ignore flags (closes #541)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Calcado committed Dec 18, 2017
1 parent 12802e5 commit 971c872
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion proxy-init/cmd/root.go
Expand Up @@ -43,7 +43,7 @@ func init() {
RootCmd.PersistentFlags().IntVarP(&outgoingProxyPort, "outgoing-proxy-port", "o", -1, "Port to redirect outgoing traffic")
RootCmd.PersistentFlags().BoolVar(&simulateOnly, "simulate", false, "Don't execute any command, just print what would be executed")
RootCmd.PersistentFlags().IntSliceVarP(&portsToRedirect, "ports-to-redirect", "r", make([]int, 0), "Port to redirect to proxy, if no port is specified then ALL ports are redirected")
RootCmd.PersistentFlags().IntSliceVar(&inboundPortsToIgnore, "inbound-ports-to-ignore", make([]int, 0), "Inound ports to ignore and not redirect to proxy. This has higher precedence than any other parameters.")
RootCmd.PersistentFlags().IntSliceVar(&inboundPortsToIgnore, "inbound-ports-to-ignore", make([]int, 0), "Inbound ports to ignore and not redirect to proxy. This has higher precedence than any other parameters.")
RootCmd.PersistentFlags().IntSliceVar(&outboundPortsToIgnore, "outbound-ports-to-ignore", make([]int, 0), "Outbound ports to ignore and not redirect to proxy. This has higher precedence than any other parameters.")
RootCmd.PersistentFlags().IntVarP(&proxyUserId, "proxy-uid", "u", -1, "User ID that the proxy is running under. Any traffic coming from this user will be ignored to avoid infinite redirection loops.")
}
Expand Down
9 changes: 7 additions & 2 deletions proxy-init/integration_test/iptables/http_test.go
Expand Up @@ -114,8 +114,13 @@ func TestPodWithSomePortsIgnored(t *testing.T) {
t.Run("doesnt redirect when through port that is ignored", func(t *testing.T) {
marksParallelIfConfigured(t)
response := expectSuccessfulGetRequestTo(t, podIgnoredSomePortsIp, ignoredContainerPort)

if response == "proxy" {
t.Fatalf("Expected connection through ignored port to directly hit service, but hit [%s]", response)
}

if !strings.Contains(response, ignoredContainerPort) {
t.Fatalf("Expected iptables to ignore connection to %s, got back %s", ignoredContainerPort, response)
t.Fatalf("Expected to be able to connect to %s without redirects, but got back %s", ignoredContainerPort, response)
}
})
}
Expand Down Expand Up @@ -144,8 +149,8 @@ func TestPodMakesOutboundConnection(t *testing.T) {

t.Run("connecting to another pod from proxy container does not get redirected to proxy", func(t *testing.T) {
marksParallelIfConfigured(t)
targetPodIp := podWithNoRulesIp
targetPodName := podWithNoRulesName
targetPodIp := podWithNoRulesIp

response := makeCallFromContainerToAnother(t, proxyPodIp, proxyContainerPort, targetPodIp, notTheProxyContainerPort)

Expand Down
2 changes: 1 addition & 1 deletion proxy-init/integration_test/iptables/iptablestest-lab.yaml
Expand Up @@ -167,7 +167,7 @@ spec:
- name: conduit-init
image: gcr.io/runconduit/proxy-init:latest
imagePullPolicy: Never
args: ["-p", "8080", "-o", "8080", "-u", "2102", "-i", "7070"]
args: ["-p", "8080", "-o", "8080", "-u", "2102", "--inbound-ports-to-ignore", "7070"]
securityContext:
capabilities:
add:
Expand Down

0 comments on commit 971c872

Please sign in to comment.