Skip to content

Commit

Permalink
Add unix-socket support for istioctl pc endpoint (istio#16288)
Browse files Browse the repository at this point in the history
* Add unix-socket support for istioctl pc endpoint

* Fix golint
  • Loading branch information
kebe7jun authored and istio-testing committed Aug 15, 2019
1 parent 332bf64 commit 1719248
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 12 deletions.
19 changes: 16 additions & 3 deletions istioctl/pkg/writer/envoy/clusters/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ func (c *ConfigWriter) Prime(b []byte) error {
}

func retrieveEndpointAddress(host *adminapi.HostStatus) string {
return host.Address.GetSocketAddress().Address
addr := host.Address.GetSocketAddress()
if addr != nil {
return addr.Address
}
return "unix://" + host.Address.GetPipe().Path
}

func retrieveEndpointPort(l *adminapi.HostStatus) uint32 {
return l.Address.GetSocketAddress().GetPortValue()
addr := l.Address.GetSocketAddress()
if addr != nil {
return addr.GetPortValue()
}
return 0
}

func retrieveEndpointStatus(l *adminapi.HostStatus) core.HealthStatus {
Expand Down Expand Up @@ -125,7 +133,12 @@ func (c *ConfigWriter) PrintEndpointsSummary(filter EndpointFilter) error {
clusterEndpoint = retrieveSortedEndpointClusterSlice(clusterEndpoint)
fmt.Fprintln(w, "ENDPOINT\tSTATUS\tOUTLIER CHECK\tCLUSTER")
for _, ce := range clusterEndpoint {
endpoint := ce.address + ":" + strconv.Itoa(ce.port)
var endpoint string
if ce.port != 0 {
endpoint = ce.address + ":" + strconv.Itoa(ce.port)
} else {
endpoint = ce.address
}
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", endpoint, core.HealthStatus_name[int32(ce.status)], printFailedOutlierCheck(ce.failedOutlierCheck), ce.cluster)
}

Expand Down
50 changes: 50 additions & 0 deletions istioctl/pkg/writer/envoy/clusters/testdata/clusters.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,56 @@
}
}
]
},
{
"name": "inbound_9092",
"host_statuses": [
{
"address": {
"pipe": {
"path": "/sock/mixer.socket"
}
},
"stats": [
{
"value": "64",
"name": "cx_connect_fail"
},
{
"value": "72",
"name": "cx_total"
},
{
"value": "78",
"name": "rq_error"
},
{
"value": "300076",
"name": "rq_success"
},
{
"name": "rq_timeout"
},
{
"value": "300076",
"name": "rq_total"
},
{
"type": "GAUGE",
"value": "8",
"name": "cx_active"
},
{
"type": "GAUGE",
"name": "rq_active"
}
],
"health_status": {
"eds_health_status": "HEALTHY"
},
"weight": 1
}
]
}
]
}
50 changes: 50 additions & 0 deletions istioctl/pkg/writer/envoy/clusters/testdata/clustersnofiltered.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,5 +347,55 @@
}
}
]
},
{
"name": "inbound_9092",
"hostStatuses": [
{
"address": {
"pipe": {
"path": "/sock/mixer.socket"
}
},
"stats": [
{
"value": "64",
"name": "cx_connect_fail"
},
{
"value": "72",
"name": "cx_total"
},
{
"value": "78",
"name": "rq_error"
},
{
"value": "300076",
"name": "rq_success"
},
{
"name": "rq_timeout"
},
{
"value": "300076",
"name": "rq_total"
},
{
"type": "GAUGE",
"value": "8",
"name": "cx_active"
},
{
"type": "GAUGE",
"name": "rq_active"
}
],
"healthStatus": {
"edsHealthStatus": "HEALTHY"
},
"weight": 1
}
]
}
]
19 changes: 10 additions & 9 deletions istioctl/pkg/writer/envoy/clusters/testdata/clustersummary.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
ENDPOINT STATUS OUTLIER CHECK CLUSTER
172.17.0.13:443 HEALTHY OK outbound|443||istio-ingressgateway.istio-system.svc.cluster.local
172.17.0.14:15014 UNHEALTHY OK outbound|15014||istio-policy.istio-system.svc.cluster.local
172.17.0.19:443 HEALTHY OK outbound|443||istio-galley.istio-system.svc.cluster.local
172.17.0.24:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
172.17.0.26:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
172.17.0.27:9080 HEALTHY FAILED outbound|9080||reviews.default.svc.cluster.local
172.17.0.4:443 HEALTHY OK outbound|443||istio-sidecar-injector.istio-system.svc.cluster.local
172.17.0.6:443 HEALTHY OK outbound|443||istio-egressgateway.istio-system.svc.cluster.local
ENDPOINT STATUS OUTLIER CHECK CLUSTER
172.17.0.13:443 HEALTHY OK outbound|443||istio-ingressgateway.istio-system.svc.cluster.local
172.17.0.14:15014 UNHEALTHY OK outbound|15014||istio-policy.istio-system.svc.cluster.local
172.17.0.19:443 HEALTHY OK outbound|443||istio-galley.istio-system.svc.cluster.local
172.17.0.24:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
172.17.0.26:9080 HEALTHY OK outbound|9080||reviews.default.svc.cluster.local
172.17.0.27:9080 HEALTHY FAILED outbound|9080||reviews.default.svc.cluster.local
172.17.0.4:443 HEALTHY OK outbound|443||istio-sidecar-injector.istio-system.svc.cluster.local
172.17.0.6:443 HEALTHY OK outbound|443||istio-egressgateway.istio-system.svc.cluster.local
unix:///sock/mixer.socket HEALTHY OK inbound_9092

0 comments on commit 1719248

Please sign in to comment.