Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified build/yetis
Binary file not shown.
2 changes: 1 addition & 1 deletion client/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package common

const YetisVersion = "v0.3.0"
const YetisVersion = "v0.3.1"
14 changes: 4 additions & 10 deletions proxy/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down
19 changes: 13 additions & 6 deletions server/handlers_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -141,6 +147,7 @@ func ListDeployment() ([]DeploymentView, error) {
Age: ageSince(p.createdAt),
Command: p.spec.Cmd,
LivenessPort: p.spec.LivenessProbe.Port(),
PortInfo: portInfo,
})
})

Expand Down
Loading