diff --git a/build/yetis b/build/yetis index db13199..6e8e17c 100755 Binary files a/build/yetis and b/build/yetis differ diff --git a/client/commands.go b/client/commands.go index ea9dba5..f5ae2c7 100644 --- a/client/commands.go +++ b/client/commands.go @@ -74,7 +74,7 @@ func printDeploymentTable() (int, bool) { tw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) fmt.Fprintln(tw, "NAME\tSTATUS\tPID\tRESTARTS\tAGE\tCOMMAND\tPORT") for _, d := range views { - fmt.Fprintln(tw, fmt.Sprintf("%s\t%s\t%d\t%d\t%s\t%s\t%d", d.Name, d.Status, d.Pid, d.Restarts, d.Age, d.Command, d.LivenessPort)) + fmt.Fprintln(tw, fmt.Sprintf("%s\t%s\t%d\t%d\t%s\t%s\t%s", d.Name, d.Status, d.Pid, d.Restarts, d.Age, d.Command, d.PortInfo)) } tw.Flush() return len(views), true diff --git a/common/version.go b/common/version.go index e6d464f..e0fcb35 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const YetisVersion = "v0.3.0" +const YetisVersion = "v0.3.1" diff --git a/proxy/exec.go b/proxy/exec.go index d0dd484..9da0ddb 100644 --- a/proxy/exec.go +++ b/proxy/exec.go @@ -50,7 +50,7 @@ func UpdatePortForwarding(fromPort, oldToPort, newToPort int) error { } func getLine(fromPort, toPort int) (int, error) { - output, err := exec.Command("iptables", strings.Split("-t nat -L OUTPUT --line-numbers", " ")...).Output() + output, err := exec.Command("iptables", strings.Split("-t nat -L OUTPUT --line-numbers -n", " ")...).Output() if err != nil { return 0, fmt.Errorf("failed to list iptables rules: %s", err) } @@ -59,17 +59,11 @@ func getLine(fromPort, toPort int) (int, error) { func extractLine(output string, fromPort, toPort int) (int, error) { lines := strings.Split(output, "\n") - fromPortStr := strconv.Itoa(fromPort) - // for some reason iptables list replaces the well-known ports with their names. - switch fromPort { - case 80: - fromPortStr = "http" - case 443: - fromPortStr = "https" - } + fromPortStr := strconv.Itoa(fromPort) + toPortStr := strconv.Itoa(toPort) for _, line := range lines { - if strings.Contains(line, fromPortStr) && strings.Contains(line, strconv.Itoa(toPort)) { + if strings.Contains(line, fromPortStr) && strings.Contains(line, toPortStr) { lexes := strings.Split(line, " ") num, err := strconv.Atoi(lexes[0]) if err != nil { diff --git a/server/handlers_deployment.go b/server/handlers_deployment.go index 225a1c7..915300a 100644 --- a/server/handlers_deployment.go +++ b/server/handlers_deployment.go @@ -121,18 +121,24 @@ func isYetisPortUsed(c common.DeploymentSpec) bool { } type DeploymentView struct { - Name string - Status string - Pid int - Restarts int - Age string - Command string + Name string + Status string + Pid int + Restarts int + Age string + Command string + // Deprecated. LivenessPort int + PortInfo string } func ListDeployment() ([]DeploymentView, error) { var res []DeploymentView rangeDeployments(func(name string, p deployment) { + portInfo := strconv.Itoa(p.spec.LivenessProbe.Port()) + if p.spec.Proxy.Port > 0 { + portInfo = strconv.Itoa(p.spec.Proxy.Port) + " to " + strconv.Itoa(p.spec.LivenessProbe.Port()) + } res = append(res, DeploymentView{ Name: name, Status: p.status.String(), @@ -141,6 +147,7 @@ func ListDeployment() ([]DeploymentView, error) { Age: ageSince(p.createdAt), Command: p.spec.Cmd, LivenessPort: p.spec.LivenessProbe.Port(), + PortInfo: portInfo, }) })