diff --git a/README.md b/README.md index 4b0289a..b2f05e3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,415 @@ -# gdebug -A local command line debugger for gRPC applications +# grpcdebug +[![Go Report Card](https://goreportcard.com/badge/github.com/grpc-ecosystem/grpcdebug)](https://goreportcard.com/report/github.com/grpc-ecosystem/grpcdebug) + +grpcdebug is a command line interface focusing on simplifying the debugging +process of gRPC applications. grpcdebug fetches the internal states of the gRPC +library from the application via gRPC protocol and provide a human-friendly UX +to browse them. Currently, it supports Channelz/Health Checking/CSDS (aka. admin +services). In other words, it can fetch statistics about how many RPCs has being +sent or failed on a given gRPC channel, it can inspect address resolution +results, it can dump the in-effective xDS configuration that directs the routing +of RPCs. + +If you are looking for a tool to send gRPC requests and interact with a gRPC +server, please checkout https://github.com/fullstorydev/grpcurl. + +``` +grpcdebug is an gRPC service admin CLI + +Usage: + grpcdebug [flags] + +Available Commands: + channelz Display gRPC states in human readable way. + health Check health status of the target service (default ""). + help Help about any command + xds Fetch xDS related information. + +Flags: + --credential_file string Sets the path of the credential file; used in [tls] mode + -h, --help help for grpcdebug + --security string Defines the type of credentials to use [tls, google-default, insecure] (default "insecure") + --server_name_override string Overrides the peer server name if non empty; used in [tls] mode + -t, --timestamp Print timestamp as RFC3339 instead of human readable strings + -v, --verbose Print verbose information for debugging + +Use "grpcdebug [command] --help" for more information about a command. +``` + +## Table of Contents +- [grpcdebug](#grpcdebug) + - [Table of Contents](#table-of-contents) + - [Installation](#installation) + - [Quick Start](#quick-start) + - [Connect & Security](#connect--security) + - [Insecure Connection](#insecure-connection) + - [TLS Connection - Flags](#tls-connection---flags) + - [Server Connection Config](#server-connection-config) + - [Health](#health) + - [Channelz](#channelz) + - [Usage 1: Raw Channelz Output](#usage-1-raw-channelz-output) + - [Usage 2: List Client Channels](#usage-2-list-client-channels) + - [Usage 3: List Servers](#usage-3-list-servers) + - [Usage 4: Inspect a Channel](#usage-4-inspect-a-channel) + - [Usage 5: Inspect a Subchannel](#usage-5-inspect-a-subchannel) + - [Usage 6: Inspect a Socket](#usage-6-inspect-a-socket) + - [Usage 7: Inspect a Server](#usage-7-inspect-a-server) + - [Debug xDS](#debug-xds) + - [Usage 1: xDS Resources Overview](#usage-1-xds-resources-overview) + - [Usage 2: Dump xDS Configs](#usage-2-dump-xds-configs) + - [Usage 3: Filter xDS Configs](#usage-3-filter-xds-configs) + - [Admin Services](#admin-services) + - [gRPC Java:](#grpc-java) + - [gRPC Go:](#grpc-go) + - [gRPC C++:](#grpc-c) + +## Installation + +Minimum Golang Version 1.12. Official Golang install guide: https://golang.org/doc/install. + +```shell +go get github.com/grpc-ecosystem/grpcdebug +``` + +## Quick Start + +If certain commands if confusing, please try to use `-h` to get more context. Suggestions and ideas are welcome, please post them to https://github.com/grpc-ecosystem/grpcdebug/issues! + +If you haven't got your gRPC application instrumented, feel free to try out the mocking `testserver` which implemented admin services. + +```shell +cd internal/testing/testserver +go run main.go +# Serving Business Logic on :10001 +# Serving Insecure Admin Services on :50051 +# Serving Secure Admin Services on :50052 +# ... +``` + +### Connect & Security + +#### Insecure Connection + +To connect to a gRPC endpoint without any credentials, we don't any special +flags. If the local network can connect to the given gRPC endpoint, it should +just work. For example, if I have a gRPC application exposing admin services at +`localhost:50051`: + +```shell +grpcdebug localhost:50051 channelz channels +``` + +#### TLS Connection - Flags + +One way to establish a TLS connection with grpcdebug is specifying the credentials via command line flags. For example: + +```shell +grpcdebug localhost:50052 --security=tls --credential_file=./internal/testing/ca.pem --server_name_override="*.test.youtube.com" channelz channels +``` + +#### Server Connection Config + +Alternatively, like OpenSSH clients, you can specify the security settings in a +`grpcdebug_config` file. grpcdebug CLI will find matching connection config and +then use it to connect. + +``` +Server + RealAddress + Security + CredentialFile + ServerNameOverride +``` + +Here is an example config file [grpcdebug_config](https://github.com/grpc-ecosystem/grpcdebug/blob/main/internal/testing/grpcdebug_config). + +Each server config can have following settings: + +* Pattern: the string right after `Server ` which dictates if this rule should apply; +* RealAddress: if present, override the given target address, which allows giving nicknames/aliases to frequently used addresses; +* Security: allows `insecure` or `tls`, expecting more in future; +* CredentialFile: path to the credential file; +* ServerNameOverride: override the hostname, useful for local reproductions to comply the certificates' common name requirement. + +grpcdebug searches the config file in following order: + +1. Check if environment variable `GRPCDEBUG_CONFIG` is set, if so, load from the given path; +2. Try to load the `grpcdebug_config` file in current working directory; +3. Try to load the `grpcdebug_config` file in the user config directory (Linux: `$HOME/.config`, macOS: `$HOME/Library/Application Support`, Windows: `%AppData%`, see [`os.UserConfigDir()`](https://golang.org/pkg/os/#UserConfigDir)). + +For example, we can connect to our mock test server's secure admin port via: + +```shell +GRPCDEBUG_CONFIG=internal/testing/grpcdebug_config grpcdebug localhost:50052 channelz channels +# Or +GRPCDEBUG_CONFIG=internal/testing/grpcdebug_config grpcdebug prod channelz channels +``` + +### Health + +grpcdebug can be used to fetch the health checking status of peer gRPC +application (see +[health.proto](https://github.com/grpc/grpc/blob/master/src/proto/grpc/health/v1/health.proto)). +gRPC's health checking works at service-level, meaning services registered on +the same gRPC server may have different health status. The health status of +service "" is used to represent the overall health status of the gRPC +application. + +To simply fetch the overall health status: + +```shell +grpcdebug localhost:50051 health +# SERVING +# or +# NOT_SERVING +``` + +Or fetch individual service's health status: + +```shell +grpcdebug localhost:50051 health "" helloworld.Greeter +# : SERVING +# helloworld.Greeter: SERVING +``` + +### Channelz + +Channelz is a channel tracing library that allows applications to remotely query +gRPC internal debug information. Also, Channelz has a web interface (see +[gdebug](https://github.com/grpc/grpc-experiments/tree/master/gdebug)). +grpcdebug is able to fetch information and present it in a more readable way. + + +#### Usage 1: Raw Channelz Output + +For all Channelz commands, you can add `--json` to get the raw Channelz output. + +```shell +grpcdebug localhost:50051 channelz channels --json +grpcdebug localhost:50051 channelz servers --json +``` + +#### Usage 2: List Client Channels + +```shell +grpcdebug localhost:50051 channelz channels +# Channel ID Target State Calls(Started/Succeeded/Failed) Created Time +# 7 localhost:10001 READY 5136/4631/505 8 minutes ago +``` + +#### Usage 3: List Servers + +```shell +grpcdebug localhost:50051 channelz servers +# Server ID Listen Addresses Calls(Started/Succeeded/Failed) Last Call Started +# 1 [:::10001] 2852/2530/322 now +# 2 [:::50051] 29/28/0 now +# 3 [:::50052] 4/4/0 26 seconds ago +``` + +#### Usage 4: Inspect a Channel + +You can identify a channel via the Channel ID or a URL matching its target (if multiple hit, return first match). + +```shell +grpcdebug localhost:50051 channelz channel localhost:10001 +grpcdebug localhost:50051 channelz channel 7 +# Channel ID: 7 +# Target: localhost:10001 +# State: READY +# Calls Started: 3976 +# Calls Succeeded: 3520 +# Calls Failed: 456 +# Created Time: 6 minutes ago +# --- +# Subchannel ID Target State Calls(Started/Succeeded/Failed) CreatedTime +# 8 localhost:10001 READY 3976/3520/456 6 minutes ago +# --- +# Severity Time Child Ref Description +# CT_INFO 6 minutes ago Channel Created +# CT_INFO 6 minutes ago Resolver state updated: {Addresses:[{Addr:localhost:10001 ServerName: Attributes: Type:0 Metadata:}] ServiceConfig: Attributes:} (resolver returned new addresses) +# CT_INFO 6 minutes ago Channel switches to new LB policy "pick_first" +# CT_INFO 6 minutes ago subchannel(subchannel_id:8 ) Subchannel(id:8) created +# CT_INFO 6 minutes ago Channel Connectivity change to CONNECTING +# CT_INFO 6 minutes ago Channel Connectivity change to READY +``` + +#### Usage 5: Inspect a Subchannel + +```shell +grpcdebug localhost:50051 channelz subchannel 8 +# Subchannel ID: 8 +# Target: localhost:10001 +# State: READY +# Calls Started: 4490 +# Calls Succeeded: 3966 +# Calls Failed: 524 +# Created Time: 7 minutes ago +# --- +# Socket ID Local->Remote Streams(Started/Succeeded/Failed) Messages(Sent/Received) +# 9 ::1:47436->::1:10001 4490/4490/0 4490/3966 +``` + +#### Usage 6: Inspect a Socket + +```shell +grpcdebug localhost:50051 channelz socket 9 +# Socket ID: 9 +# Address: ::1:47436->::1:10001 +# Streams Started: 4807 +# Streams Succeeded: 4807 +# Streams Failed: 0 +# Messages Sent: 4807 +# Messages Received: 4243 +# Keep Alives Sent: 0 +# Last Local Stream Created: now +# Last Remote Stream Created: a long while ago +# Last Message Sent Created: now +# Last Message Received Created: now +# Local Flow Control Window: 65535 +# Remote Flow Control Window: 65535 +# --- +# Socket Options Name Value +# SO_LINGER [type.googleapis.com/grpc.channelz.v1.SocketOptionLinger]:{duration:{}} +# SO_RCVTIMEO [type.googleapis.com/grpc.channelz.v1.SocketOptionTimeout]:{duration:{}} +# SO_SNDTIMEO [type.googleapis.com/grpc.channelz.v1.SocketOptionTimeout]:{duration:{}} +# TCP_INFO [type.googleapis.com/grpc.channelz.v1.SocketOptionTcpInfo]:{tcpi_state:1 tcpi_options:7 tcpi_rto:204000 tcpi_ato:40000 tcpi_snd_mss:32768 tcpi_rcv_mss:1093 tcpi_last_data_sent:16 tcpi_last_data_recv:16 tcpi_last_ack_recv:16 tcpi_pmtu:65536 tcpi_rcv_ssthresh:65476 tcpi_rtt:192 tcpi_rttvar:153 tcpi_snd_ssthresh:2147483647 tcpi_snd_cwnd:10 tcpi_advmss:65464 tcpi_reordering:3} +# --- +# Security Model: TLS +# Standard Name: TLS_AES_128_GCM_SHA256 +``` + +#### Usage 7: Inspect a Server + +```shell +grpcdebug localhost:50051 channelz server 1 +# Server Id: 1 +# Listen Addresses: [:::10001] +# Calls Started: 5250 +# Calls Succeeded: 4647 +# Calls Failed: 603 +# Last Call Started: now +# --- +# Socket ID Local->Remote Streams(Started/Succeeded/Failed) Messages(Sent/Received) +# 10 ::1:10001->::1:47436 5250/5250/0 4647/5250 +``` + +### Debug xDS + +[xDS](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/operations/dynamic_configuration) +is a data plane configuration API commonly used in service mesh projects. It's +created by Envoy, used by Istio, Traffic Director, and gRPC. + +#### Usage 1: xDS Resources Overview + +The xDS resources status might be REQUESTED/DOES_NOT_EXIST/ACKED/NACKED (see [config_dump.proto](https://github.com/envoyproxy/envoy/blob/b0ce15c96cebd89cf391869e49017325cd7faaa8/api/envoy/admin/v3/config_dump.proto#L22)). This view is intended for a quick scan if a configuration is propagated from the service mesh control plane. + +```shell +grpcdebug localhost:50051 xds status +# Name Status Version Type LastUpdated +# xds-test-server:1337 ACKED 1617141154495058478 type.googleapis.com/envoy.config.listener.v3.Listener 2 days ago +# URL_MAP/1040920224690_sergii-psm-test-url-map_0_xds-test-server:1337 ACKED 1617141154495058478 type.googleapis.com/envoy.config.route.v3.RouteConfiguration 2 days ago +# cloud-internal-istio:cloud_mp_1040920224690_6530603179561593229 ACKED 1617141154495058478 type.googleapis.com/envoy.config.cluster.v3.Cluster 2 days ago +# cloud-internal-istio:cloud_mp_1040920224690_6530603179561593229 ACKED 1 type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment 2 days ago +``` + +#### Usage 2: Dump xDS Configs + +```shell +grpcdebug localhost:50051 xds config +# { +# "config": [ +# { +# "node": { +# "id": "projects/1040920224690/networks/default/nodes/5cc9170c-d5b4-4061-b431-c1d43e6ac0ab", +# "cluster": "cluster", +# "metadata": { +# "INSTANCE_IP": "192.168.120.31", +# "TRAFFICDIRECTOR_GCP_PROJECT_NUMBER": "1040920224690", +# "TRAFFICDIRECTOR_NETWORK_NAME": "default" +# }, +# ... +``` + +For an example config dump, see [csds_config_dump.json](https://github.com/grpc-ecosystem/grpcdebug/blob/main/internal/testing/testserver/csds_config_dump.json). + +#### Usage 3: Filter xDS Configs + +The dumped xDS config can be quite verbose, if I only interested in certain xDS type, grpcdebug can only print the selected section. + +```shell +grpcdebug localhost:50051 xds config eds +# { +# "dynamicEndpointConfigs": [ +# { +# "versionInfo": "1", +# "endpointConfig": { +# "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", +# "clusterName": "cloud-internal-istio:cloud_mp_1040920224690_6530603179561593229", +# "endpoints": [ +# { +# "locality": { +# "subZone": "jf:us-central1-a_7062512536751318190_neg" +# }, +# "lbEndpoints": [ +# { +# "endpoint": { +# "address": { +# "socketAddress": { +# "address": "192.168.120.26", +# "portValue": 8080 +# } +# } +# }, +# "healthStatus": "HEALTHY" +# } +# ], +# "loadBalancingWeight": 100 +# } +# ] +# }, +# "lastUpdated": "2021-03-31T01:20:33.936Z", +# "clientStatus": "ACKED" +# } +# ] +# } +``` + +## Admin Services + +### gRPC Java: + +```java +server = ServerBuilder.forPort(50051) + .useTransportSecurity(certChainFile, privateKeyFile) + .addServices(AdminInterface.getStandardServices()) + .build() + .start(); +server.awaitTermination(); +``` + + +### gRPC Go: + +```golang +lis, err := net.Listen("tcp", ":50051") +if err != nil { + log.Fatalf("failed to listen: %v", err) +} +defer lis.Close() +grpcServer := grpc.NewServer(...opts) +adminServices.RegisterAdminServicesToServer(grpcServer) +if err := grpcServer.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) +} +``` + + +### gRPC C++: + +```cpp +grpc::ServerBuilder builder; +grpc::AddAdminServices(&builder); +builder.AddListeningPort(":50051", grpc::ServerCredentials(...)); +std::unique_ptr server(builder.BuildAndStart()); +``` diff --git a/cmd/channelz.go b/cmd/channelz.go new file mode 100644 index 0000000..7dc7492 --- /dev/null +++ b/cmd/channelz.go @@ -0,0 +1,434 @@ +package cmd + +import ( + "encoding/json" + "fmt" + "net" + "strconv" + + "github.com/grpc-ecosystem/grpcdebug/cmd/transport" + + "github.com/dustin/go-humanize" + "github.com/golang/protobuf/ptypes" + timestamppb "github.com/golang/protobuf/ptypes/timestamp" + "github.com/spf13/cobra" + zpb "google.golang.org/grpc/channelz/grpc_channelz_v1" +) + +var ( + jsonOutputFlag bool +) + +func prettyTime(ts *timestamppb.Timestamp) string { + if ts.Seconds == 0 && ts.Nanos == 0 { + return "" + } + if timestampFlag { + return ptypes.TimestampString(ts) + } + t, _ := ptypes.Timestamp(ts) + return humanize.Time(t) +} + +func prettySeverity(s zpb.ChannelTraceEvent_Severity) string { + return zpb.ChannelTraceEvent_Severity_name[int32(s)] +} + +func prettyConnectivityState(state zpb.ChannelConnectivityState_State) string { + return zpb.ChannelConnectivityState_State_name[int32(state)] +} + +func prettyAddress(addr *zpb.Address) string { + if ipPort := addr.GetTcpipAddress(); ipPort != nil { + var ip net.IP = net.IP(ipPort.IpAddress) + return fmt.Sprintf("%v:%v", ip, ipPort.Port) + } + panic(fmt.Sprintf("Address type not supported for %s", addr)) +} + +func printChannelTraceEvents(events []*zpb.ChannelTraceEvent) { + fmt.Fprintln(w, "Severity\tTime\tChild Ref\tDescription\t") + for _, event := range events { + var childRef string + switch event.ChildRef.(type) { + case *zpb.ChannelTraceEvent_SubchannelRef: + childRef = fmt.Sprintf("subchannel(%v)", event.GetSubchannelRef()) + case *zpb.ChannelTraceEvent_ChannelRef: + childRef = fmt.Sprintf("channel(%v)", event.GetChannelRef()) + } + fmt.Fprintf( + w, "%v\t%v\t%v\t%v\t\n", + prettySeverity(event.Severity), + prettyTime(event.Timestamp), + childRef, + event.Description, + ) + } + w.Flush() +} + +func printSockets(sockets []*zpb.Socket) { + fmt.Fprintln(w, "Socket ID\tLocal->Remote\tStreams(Started/Succeeded/Failed)\tMessages(Sent/Received)\t") + for _, socket := range sockets { + fmt.Fprintf( + w, "%v\t%v\t%v/%v/%v\t%v/%v\t\n", + socket.Ref.SocketId, + fmt.Sprintf("%v->%v", prettyAddress(socket.Local), prettyAddress(socket.Remote)), + socket.Data.StreamsStarted, + socket.Data.StreamsSucceeded, + socket.Data.StreamsFailed, + socket.Data.MessagesSent, + socket.Data.MessagesReceived, + ) + } + w.Flush() +} + +func printAsJson(data interface{}) error { + json, err := json.MarshalIndent(data, "", " ") + if err != nil { + return err + } + fmt.Println(string(json)) + return nil +} + +func channelzChannelsCommandRunWithError(cmd *cobra.Command, args []string) error { + var channels = transport.Channels() + // Print as JSON + if jsonOutputFlag { + return printAsJson(channels) + } + // Print as table + fmt.Fprintln(w, "Channel ID\tTarget\tState\tCalls(Started/Succeeded/Failed)\tCreated Time\t") + for _, channel := range channels { + fmt.Fprintf( + w, "%v\t%v\t%v\t%v/%v/%v\t%v\t\n", + channel.Ref.ChannelId, + channel.Data.Target, + prettyConnectivityState(channel.Data.State.State), + channel.Data.CallsStarted, + channel.Data.CallsSucceeded, + channel.Data.CallsFailed, + prettyTime(channel.Data.Trace.CreationTimestamp), + ) + } + w.Flush() + return nil +} + +var channelzChannelsCmd = &cobra.Command{ + Use: "channels", + Short: "List client channels for the target application.", + Args: cobra.NoArgs, + RunE: channelzChannelsCommandRunWithError, +} + +func channelzChannelCommandRunWithError(cmd *cobra.Command, args []string) error { + var idOrTarget string = args[0] + var selected *zpb.Channel + var channels []*zpb.Channel = transport.Channels() + if id, err := strconv.ParseInt(idOrTarget, 10, 64); err == nil { + // Find by ID + for _, channel := range channels { + if channel.Ref.ChannelId == id { + selected = channel + break + } + } + } else { + // Find by matching target + for _, channel := range channels { + if channel.Data.Target == idOrTarget { + if selected != nil { + return fmt.Errorf("More than one channel is connecting to target %v", idOrTarget) + } + selected = channel + } + } + } + if selected == nil { + return fmt.Errorf("Cannot find channel with ID or target equal to %v", idOrTarget) + } + // Print as JSON + if jsonOutputFlag { + return printAsJson(selected) + } + // Print as table + // Print Channel information + fmt.Fprintf(w, "Channel ID:\t%v\t\n", selected.Ref.ChannelId) + fmt.Fprintf(w, "Target:\t%v\t\n", selected.Data.Target) + fmt.Fprintf(w, "State:\t%v\t\n", prettyConnectivityState(selected.Data.State.State)) + fmt.Fprintf(w, "Calls Started:\t%v\t\n", selected.Data.CallsStarted) + fmt.Fprintf(w, "Calls Succeeded:\t%v\t\n", selected.Data.CallsSucceeded) + fmt.Fprintf(w, "Calls Failed:\t%v\t\n", selected.Data.CallsFailed) + fmt.Fprintf(w, "Created Time:\t%v\t\n", prettyTime(selected.Data.Trace.CreationTimestamp)) + w.Flush() + // Print Subchannel list + if len(selected.SubchannelRef) > 0 { + fmt.Println("---") + fmt.Fprintln(w, "Subchannel ID\tTarget\tState\tCalls(Started/Succeeded/Failed)\tCreatedTime\t") + for _, subchannelRef := range selected.SubchannelRef { + var subchannel = transport.Subchannel(subchannelRef.SubchannelId) + fmt.Fprintf( + w, "%v\t%v\t%v\t%v/%v/%v\t%v\t\n", + subchannel.Ref.SubchannelId, + subchannel.Data.Target, + prettyConnectivityState(subchannel.Data.State.State), + subchannel.Data.CallsStarted, + subchannel.Data.CallsSucceeded, + subchannel.Data.CallsFailed, + prettyTime(subchannel.Data.Trace.CreationTimestamp), + ) + } + w.Flush() + } + // Print channel trace events + if len(selected.Data.Trace.Events) != 0 { + fmt.Println("---") + printChannelTraceEvents(selected.Data.Trace.Events) + } + return nil +} + +var channelzChannelCmd = &cobra.Command{ + Use: "channel ", + Short: "Display channel states in human readable way.", + Args: cobra.ExactArgs(1), + RunE: channelzChannelCommandRunWithError, +} + +func channelzSubchannelCommandRunWithError(cmd *cobra.Command, args []string) error { + var idOrTarget string = args[0] + var selected *zpb.Subchannel + var subchannels []*zpb.Subchannel = transport.Subchannels() + if id, err := strconv.ParseInt(idOrTarget, 10, 64); err == nil { + for _, subchannel := range subchannels { + if subchannel.Ref.SubchannelId == id { + selected = subchannel + break + } + } + } else { + for _, subchannel := range subchannels { + if subchannel.Data.Target == idOrTarget { + if selected != nil { + return fmt.Errorf("More than one subchannel is connecting to target %v", idOrTarget) + } + selected = subchannel + } + } + } + if selected == nil { + return fmt.Errorf("Cannot find subchannel with ID or target equal to %v", idOrTarget) + } + // Print as JSON + if jsonOutputFlag { + return printAsJson(selected) + } + // Print as table + // Print Subchannel information + fmt.Fprintf(w, "Subchannel ID:\t%v\t\n", selected.Ref.SubchannelId) + fmt.Fprintf(w, "Target:\t%v\t\n", selected.Data.Target) + fmt.Fprintf(w, "State:\t%v\t\n", prettyConnectivityState(selected.Data.State.State)) + fmt.Fprintf(w, "Calls Started:\t%v\t\n", selected.Data.CallsStarted) + fmt.Fprintf(w, "Calls Succeeded:\t%v\t\n", selected.Data.CallsSucceeded) + fmt.Fprintf(w, "Calls Failed:\t%v\t\n", selected.Data.CallsFailed) + fmt.Fprintf(w, "Created Time:\t%v\t\n", prettyTime(selected.Data.Trace.CreationTimestamp)) + w.Flush() + if len(selected.SocketRef) > 0 { + // Print socket list + fmt.Println("---") + var sockets []*zpb.Socket + for _, socketRef := range selected.SocketRef { + sockets = append(sockets, transport.Socket(socketRef.SocketId)) + } + printSockets(sockets) + } + return nil +} + +var channelzSubchannelCmd = &cobra.Command{ + Use: "subchannel", + Short: "Display subchannel states in human readable way.", + Args: cobra.ExactArgs(1), + RunE: channelzSubchannelCommandRunWithError, +} + +func channelzSocketCommandRunWithError(cmd *cobra.Command, args []string) error { + socketId, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return fmt.Errorf("Invalid socket ID %v", socketId) + } + selected := transport.Socket(socketId) + if selected == nil { + return fmt.Errorf("Cannot find socket with ID %v", socketId) + } + // Print as JSON + if jsonOutputFlag { + return printAsJson(selected) + } + // Print as table + // Print Socket information + fmt.Fprintf(w, "Socket ID:\t%v\t\n", selected.Ref.SocketId) + fmt.Fprintf(w, "Address:\t%v\t\n", fmt.Sprintf("%v->%v", prettyAddress(selected.Local), prettyAddress(selected.Remote))) + fmt.Fprintf(w, "Streams Started:\t%v\t\n", selected.Data.StreamsStarted) + fmt.Fprintf(w, "Streams Succeeded:\t%v\t\n", selected.Data.StreamsSucceeded) + fmt.Fprintf(w, "Streams Failed:\t%v\t\n", selected.Data.StreamsFailed) + fmt.Fprintf(w, "Messages Sent:\t%v\t\n", selected.Data.MessagesSent) + fmt.Fprintf(w, "Messages Received:\t%v\t\n", selected.Data.MessagesReceived) + fmt.Fprintf(w, "Keep Alives Sent:\t%v\t\n", selected.Data.KeepAlivesSent) + fmt.Fprintf(w, "Last Local Stream Created:\t%v\t\n", prettyTime(selected.Data.LastLocalStreamCreatedTimestamp)) + fmt.Fprintf(w, "Last Remote Stream Created:\t%v\t\n", prettyTime(selected.Data.LastRemoteStreamCreatedTimestamp)) + fmt.Fprintf(w, "Last Message Sent Created:\t%v\t\n", prettyTime(selected.Data.LastMessageSentTimestamp)) + fmt.Fprintf(w, "Last Message Received Created:\t%v\t\n", prettyTime(selected.Data.LastMessageReceivedTimestamp)) + fmt.Fprintf(w, "Local Flow Control Window:\t%v\t\n", selected.Data.LocalFlowControlWindow.Value) + fmt.Fprintf(w, "Remote Flow Control Window:\t%v\t\n", selected.Data.RemoteFlowControlWindow.Value) + w.Flush() + if len(selected.Data.Option) > 0 { + fmt.Println("---") + fmt.Fprintln(w, "Socket Options Name\tValue\t") + for _, option := range selected.Data.Option { + if option.Value != "" { + // Prefer human readable value than the Any proto + fmt.Fprintf(w, "%v\t%v\t\n", option.Name, option.Value) + } else { + fmt.Fprintf(w, "%v\t%v\t\n", option.Name, option.Additional) + } + } + w.Flush() + } + // Print security information + if security := selected.GetSecurity(); security != nil { + fmt.Println("---") + switch x := security.Model.(type) { + case *zpb.Security_Tls_: + fmt.Fprintf(w, "Security Model:\t%v\t\n", "TLS") + switch y := security.GetTls().CipherSuite.(type) { + case *zpb.Security_Tls_StandardName: + fmt.Fprintf(w, "Standard Name:\t%v\t\n", security.GetTls().GetStandardName()) + case *zpb.Security_Tls_OtherName: + fmt.Fprintf(w, "Other Name:\t%v\t\n", security.GetTls().GetOtherName()) + default: + return fmt.Errorf("Unexpected Cipher suite name type %T", y) + } + // fmt.Fprintf(w, "Local Certificate:\t%v\t\n", security.GetTls().LocalCertificate) + // fmt.Fprintf(w, "Remote Certificate:\t%v\t\n", security.GetTls().RemoteCertificate) + case *zpb.Security_Other: + fmt.Fprintf(w, "Security Model:\t%v\t\n", "Other") + fmt.Fprintf(w, "Name:\t%v\t\n", security.GetOther().Name) + // fmt.Fprintf(w, "Value:\t%v\t\n", security.GetOther().Value) + default: + return fmt.Errorf("Unexpected security model type %T", x) + } + w.Flush() + } + return nil +} + +var channelzSocketCmd = &cobra.Command{ + Use: "socket", + Short: "Display socket states in human readable way.", + Args: cobra.ExactArgs(1), + RunE: channelzSocketCommandRunWithError, +} + +func channelzServersCommandRunWithError(cmd *cobra.Command, args []string) error { + var servers = transport.Servers() + // Print as JSON + if jsonOutputFlag { + return printAsJson(servers) + } + // Print as table + fmt.Fprintln(w, "Server ID\tListen Addresses\tCalls(Started/Succeeded/Failed)\tLast Call Started\t") + for _, server := range servers { + var listenAddresses []string + for _, socketRef := range server.ListenSocket { + socket := transport.Socket(socketRef.SocketId) + listenAddresses = append(listenAddresses, prettyAddress(socket.Local)) + } + fmt.Fprintf( + w, "%v\t%v\t%v/%v/%v\t%v\t\n", + server.Ref.ServerId, + listenAddresses, + server.Data.CallsStarted, + server.Data.CallsSucceeded, + server.Data.CallsFailed, + prettyTime(server.Data.LastCallStartedTimestamp), + ) + } + w.Flush() + return nil +} + +var channelzServersCmd = &cobra.Command{ + Use: "servers", + Short: "List servers in human readable way.", + Args: cobra.NoArgs, + RunE: channelzServersCommandRunWithError, +} + +func channelzServerCommandRunWithError(cmd *cobra.Command, args []string) error { + var servers = transport.Servers() + var selected *zpb.Server + serverId, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return fmt.Errorf("Invalid server ID %v", serverId) + } + for _, server := range servers { + if server.Ref.ServerId == serverId { + selected = server + break + } + } + if selected == nil { + return fmt.Errorf("Cannot find server with ID %v", serverId) + } + // Print as JSON + if jsonOutputFlag { + return printAsJson(servers) + } + // Print as table + var listenAddresses []string + for _, socketRef := range selected.ListenSocket { + socket := transport.Socket(socketRef.SocketId) + listenAddresses = append(listenAddresses, prettyAddress(socket.Local)) + } + fmt.Fprintf(w, "Server Id:\t%v\t\n", selected.Ref.ServerId) + fmt.Fprintf(w, "Listen Addresses:\t%v\t\n", listenAddresses) + fmt.Fprintf(w, "Calls Started:\t%v\t\n", selected.Data.CallsStarted) + fmt.Fprintf(w, "Calls Succeeded:\t%v\t\n", selected.Data.CallsSucceeded) + fmt.Fprintf(w, "Calls Failed:\t%v\t\n", selected.Data.CallsFailed) + fmt.Fprintf(w, "Last Call Started:\t%v\t\n", prettyTime(selected.Data.LastCallStartedTimestamp)) + w.Flush() + if sockets := transport.ServerSocket(selected.Ref.ServerId); len(sockets) > 0 { + // Print socket list + fmt.Println("---") + printSockets(sockets) + } + return nil +} + +var channelzServerCmd = &cobra.Command{ + Use: "server ", + Short: "Display server state in human readable way.", + Args: cobra.ExactArgs(1), + RunE: channelzServerCommandRunWithError, +} + +var channelzCmd = &cobra.Command{ + Use: "channelz", + Short: "Display gRPC states in human readable way.", + Args: cobra.NoArgs, +} + +func init() { + rootCmd.AddCommand(channelzCmd) + channelzCmd.PersistentFlags().BoolVarP(&jsonOutputFlag, "json", "o", false, "Whether to print the result as JSON") + channelzCmd.AddCommand(channelzChannelCmd) + channelzCmd.AddCommand(channelzChannelsCmd) + channelzCmd.AddCommand(channelzSubchannelCmd) + channelzCmd.AddCommand(channelzSocketCmd) + channelzCmd.AddCommand(channelzServersCmd) + channelzCmd.AddCommand(channelzServerCmd) +} diff --git a/cmd/config/config.go b/cmd/config/config.go new file mode 100644 index 0000000..8f0206b --- /dev/null +++ b/cmd/config/config.go @@ -0,0 +1,183 @@ +package config + +import ( + "errors" + "fmt" + "io/ioutil" + "log" + "os" + "path" + "regexp" + "runtime" + "strings" + + "github.com/grpc-ecosystem/grpcdebug/cmd/verbose" +) + +// SecurityType is the enum type of available security modes +type SecurityType int + +const ( + // TypeInsecure is the insecure security mode and it is the default value + TypeInsecure SecurityType = iota + // TypeTls is the TLS security mode, which requires caller to provide + // credentials to connect to peer + TypeTls +) + +// The environment variable name of getting the server configs +const grpcdebugServerConfigEnvName = "GRPCDEBUG_CONFIG" + +func (e SecurityType) String() string { + switch e { + case TypeInsecure: + return "Insecure" + case TypeTls: + return "TLS" + default: + return fmt.Sprintf("%d", int(e)) + } +} + +// ServerConfig is the configuration for how to connect to a target +type ServerConfig struct { + Pattern string + RealAddress string + Security SecurityType + CredentialFile string + ServerNameOverride string +} + +func parseServerPattern(x string) (string, error) { + var matcher = regexp.MustCompile(`^Server\s+?([A-Za-z0-9-_\.\*\?:]*)$`) + tokens := matcher.FindStringSubmatch(x) + if len(tokens) != 2 { + return "", fmt.Errorf("Invalid server pattern: %v", x) + } + return strings.TrimSpace(tokens[1]), nil +} + +func parseServerOption(x string) (string, string, error) { + var matcher = regexp.MustCompile(`^(\w+?)\s+?(\S*)$`) + tokens := matcher.FindStringSubmatch(x) + if len(tokens) != 3 { + return "", "", fmt.Errorf("Invalid server option: %v", x) + } + return strings.TrimSpace(tokens[1]), strings.TrimSpace(tokens[2]), nil +} + +func loadServerConfigsFromFile(path string) []ServerConfig { + file, err := os.Open(path) + if err != nil { + panic(err) + } + bytes, err := ioutil.ReadAll(file) + if err != nil { + panic(err) + } + lines := strings.Split(string(bytes), "\n") + var configs []ServerConfig + var current *ServerConfig + for i, line := range lines { + if strings.HasPrefix(line, "Server") { + pattern, err := parseServerPattern(line) + if err != nil { + log.Fatalf("Failed to parse config [%v:%d]: %v", path, i, err) + } + configs = append(configs, ServerConfig{Pattern: pattern}) + current = &configs[len(configs)-1] + } else { + stem := strings.TrimSpace(line) + if stem == "" { + // Allow black lines, skip them + continue + } + key, value, err := parseServerOption(stem) + if err != nil { + log.Fatalf("Failed to parse config [%v:%d]: %v", path, i, err) + } + switch key { + case "RealAddress": + current.RealAddress = value + case "Security": + switch strings.ToLower(value) { + case "insecure": + current.Security = TypeInsecure + case "tls": + current.Security = TypeTls + default: + log.Fatalf("Unsupported security model: %v", value) + } + case "CredentialFile": + current.CredentialFile = value + case "ServerNameOverride": + current.ServerNameOverride = value + } + } + } + verbose.Debugf("Loaded server configs from %v: %v", path, configs) + return configs +} + +func UserConfigDir() (string, error) { + var dir string + switch runtime.GOOS { + case "windows": + dir = os.Getenv("AppData") + if dir == "" { + return "", errors.New("%AppData% is not defined") + } + + case "darwin", "ios": + dir = os.Getenv("HOME") + if dir == "" { + return "", errors.New("$HOME is not defined") + } + dir += "/Library/Application Support" + + case "plan9": + dir = os.Getenv("home") + if dir == "" { + return "", errors.New("$home is not defined") + } + dir += "/lib" + + default: // Unix + dir = os.Getenv("XDG_CONFIG_HOME") + if dir == "" { + dir = os.Getenv("HOME") + if dir == "" { + return "", errors.New("neither $XDG_CONFIG_HOME nor $HOME are defined") + } + dir += "/.config" + } + } + return dir, nil +} + +func loadServerConfigs() []ServerConfig { + if value := os.Getenv(grpcdebugServerConfigEnvName); value != "" { + return loadServerConfigsFromFile(value) + } + // Try to load from work directory, if exists + if _, err := os.Stat("./grpcdebug_config"); err == nil { + return loadServerConfigsFromFile("./grpcdebug_config") + } + // Try to load from user config directory, if exists + dir, _ := UserConfigDir() + defaultUserConfig := path.Join(dir, "grpcdebug_config") + if _, err := os.Stat(defaultUserConfig); err == nil { + return loadServerConfigsFromFile(defaultUserConfig) + } + return nil +} + +// GetServerConfig returns a connect configuration for the given target +func GetServerConfig(target string) ServerConfig { + for _, config := range loadServerConfigs() { + if config.Pattern == target { + return config + } + } + return ServerConfig{RealAddress: target} +} diff --git a/cmd/health.go b/cmd/health.go new file mode 100644 index 0000000..b4368ee --- /dev/null +++ b/cmd/health.go @@ -0,0 +1,32 @@ +package cmd + +import ( + "fmt" + + "github.com/grpc-ecosystem/grpcdebug/cmd/transport" + "github.com/spf13/cobra" +) + +var healthCmd = &cobra.Command{ + Use: "health [service names]", + Short: "Check health status of the target service (default \"\").", + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) == 0 { + fmt.Println(transport.GetHealthStatus("")) + return nil + } + for _, service := range args { + fmt.Fprintf( + w, "%v:\t%v\t\n", + service, + transport.GetHealthStatus(service), + ) + } + w.Flush() + return nil + }, +} + +func init() { + rootCmd.AddCommand(healthCmd) +} diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..e676d4a --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,111 @@ +// Defines the root command and global flags + +package cmd + +import ( + "fmt" + "log" + "os" + "text/tabwriter" + + "github.com/grpc-ecosystem/grpcdebug/cmd/config" + "github.com/grpc-ecosystem/grpcdebug/cmd/transport" + "github.com/grpc-ecosystem/grpcdebug/cmd/verbose" + + "github.com/spf13/cobra" +) + +var verboseFlag, timestampFlag bool +var address, security, credFile, serverNameOverride string + +// The table formater +var w = tabwriter.NewWriter(os.Stdout, 10, 0, 3, ' ', 0) + +var rootUsageTemplate = `Usage:{{if .Runnable}} + {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} + grpcdebug [flags] {{ .CommandPath | ChildCommandPath }} {{end}}{{if gt (len .Aliases) 0}} + +Aliases: + {{.NameAndAliases}}{{end}}{{if .HasExample}} + +Examples: +{{.Example}}{{end}}{{if .HasAvailableSubCommands}} + +Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}} + {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}} + +Flags: +{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}} + +Global Flags: +{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}} + +Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}} + {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}} + +Use "grpcdebug {{ .CommandPath | ChildCommandPath }} [command] --help" for more information about a command.{{end}} +` + +var rootCmd = &cobra.Command{ + Use: "grpcdebug", + Short: "grpcdebug is an gRPC service admin CLI", +} + +func initConfig() { + if verboseFlag { + verbose.EnableDebugOutput() + } + c := config.GetServerConfig(address) + if credFile != "" { + c.CredentialFile = credFile + } + if serverNameOverride != "" { + c.ServerNameOverride = serverNameOverride + } + if security == "tls" { + c.Security = config.TypeTls + if c.CredentialFile == "" { + rootCmd.Usage() + log.Fatalf("Please specify credential file under [tls] mode.") + } + } else if security != "insecure" { + rootCmd.Usage() + log.Fatalf("Unrecognized security mode: %v", security) + } + transport.Connect(c) +} + +// ChildCommandPath used in template +func ChildCommandPath(path string) string { + if len(path) <= 10 { + return "" + } + return path[10:] +} + +func init() { + cobra.AddTemplateFunc("ChildCommandPath", ChildCommandPath) + cobra.OnInitialize(initConfig) + rootCmd.SetUsageTemplate(rootUsageTemplate) + + rootCmd.PersistentFlags().BoolVarP(&verboseFlag, "verbose", "v", false, "Print verbose information for debugging") + rootCmd.PersistentFlags().BoolVarP(×tampFlag, "timestamp", "t", false, "Print timestamp as RFC3339 instead of human readable strings") + rootCmd.PersistentFlags().StringVar(&security, "security", "insecure", "Defines the type of credentials to use [tls, google-default, insecure]") + rootCmd.PersistentFlags().StringVar(&credFile, "credential_file", "", "Sets the path of the credential file; used in [tls] mode") + rootCmd.PersistentFlags().StringVar(&serverNameOverride, "server_name_override", "", "Overrides the peer server name if non empty; used in [tls] mode") +} + +// Execute executes the root command. +func Execute() { + if len(os.Args) > 1 { + address = os.Args[1] + os.Args = os.Args[1:] + } else { + rootCmd.Usage() + os.Exit(1) + } + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/cmd/transport/grpc.go b/cmd/transport/grpc.go new file mode 100644 index 0000000..e3ace31 --- /dev/null +++ b/cmd/transport/grpc.go @@ -0,0 +1,168 @@ +package transport + +import ( + "context" + "log" + "time" + + csdspb "github.com/envoyproxy/go-control-plane/envoy/service/status/v3" + "github.com/grpc-ecosystem/grpcdebug/cmd/config" + "github.com/grpc-ecosystem/grpcdebug/cmd/verbose" + "google.golang.org/grpc" + zpb "google.golang.org/grpc/channelz/grpc_channelz_v1" + "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/credentials" + healthpb "google.golang.org/grpc/health/grpc_health_v1" +) + +var conn *grpc.ClientConn +var channelzClient zpb.ChannelzClient +var csdsClient csdspb.ClientStatusDiscoveryServiceClient +var healthClient healthpb.HealthClient + +// Connect connects to the service at address and creates stubs +func Connect(c config.ServerConfig) { + verbose.Debugf("Connecting with %v", c) + var err error + var credOption grpc.DialOption + if c.CredentialFile != "" { + cred, err := credentials.NewClientTLSFromFile(c.CredentialFile, c.ServerNameOverride) + if err != nil { + log.Fatalf("failed to create credential: %v", err) + } + credOption = grpc.WithTransportCredentials(cred) + } else { + credOption = grpc.WithInsecure() + } + // Pick the address + var address string + if c.RealAddress != "" { + address = c.RealAddress + } else { + address = c.Pattern + } + // Dial + conn, err = grpc.Dial(address, credOption) + if err != nil { + log.Fatalf("failed to connect: %v", err) + } + channelzClient = zpb.NewChannelzClient(conn) + csdsClient = csdspb.NewClientStatusDiscoveryServiceClient(conn) + healthClient = healthpb.NewHealthClient(conn) + // Wait for ready + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + var state connectivity.State = conn.GetState() + for state != connectivity.Ready { + conn.WaitForStateChange(ctx, state) + if ctx.Err() != nil { + log.Fatalf("failed to establish connection to address: %v", address) + } + state = conn.GetState() + } +} + +// IsConnected checks if the connection is ready to use +func IsConnected() bool { + if conn == nil { + return false + } + return conn.GetState() == connectivity.Ready +} + +// Channels returns all available channels +func Channels() []*zpb.Channel { + channels, err := channelzClient.GetTopChannels(context.Background(), &zpb.GetTopChannelsRequest{}) + if err != nil { + log.Fatalf("failed to fetch top channels: %v", err) + } + return channels.Channel +} + +// Subchannel returns the queried subchannel +func Subchannel(subchannelID int64) *zpb.Subchannel { + subchannel, err := channelzClient.GetSubchannel(context.Background(), &zpb.GetSubchannelRequest{SubchannelId: subchannelID}) + if err != nil { + log.Fatalf("failed to fetch subchannel (id=%v): %v", subchannelID, err) + } + return subchannel.Subchannel +} + +// Subchannels traverses all channels and fetches all subchannels +func Subchannels() []*zpb.Subchannel { + var s []*zpb.Subchannel + for _, channel := range Channels() { + for _, subchannelRef := range channel.SubchannelRef { + s = append(s, Subchannel(subchannelRef.SubchannelId)) + } + } + return s +} + +// Servers returns all available servers +func Servers() []*zpb.Server { + servers, err := channelzClient.GetServers(context.Background(), &zpb.GetServersRequest{}) + if err != nil { + log.Fatalf("failed to fetch servers: %v", err) + } + return servers.Server +} + +// Socket returns a socket +func Socket(socketID int64) *zpb.Socket { + socket, err := channelzClient.GetSocket(context.Background(), &zpb.GetSocketRequest{SocketId: socketID}) + if err != nil { + log.Fatalf("failed to fetch socket (id=%v): %v", socketID, err) + } + return socket.Socket +} + +// ServerSocket returns all sockets of this server +func ServerSocket(serverId int64) []*zpb.Socket { + var s []*zpb.Socket + serverSocketResp, err := channelzClient.GetServerSockets( + context.Background(), + &zpb.GetServerSocketsRequest{ServerId: serverId}, + ) + if err != nil { + log.Fatalf("failed to fetch server sockets (id=%v): %v", serverId, err) + } + for _, socketRef := range serverSocketResp.SocketRef { + s = append(s, Socket(socketRef.SocketId)) + } + return s +} + +// Sockets returns all sockets for servers +func Sockets() []*zpb.Socket { + var s []*zpb.Socket + // Gather client sockets + for _, subchannel := range Subchannels() { + for _, socketRef := range subchannel.SocketRef { + s = append(s, Socket(socketRef.SocketId)) + } + } + // Gather server sockets + for _, server := range Servers() { + s = append(s, ServerSocket(server.Ref.ServerId)...) + } + return s +} + +// FetchClientStatus fetches the xDS resources status +func FetchClientStatus() *csdspb.ClientStatusResponse { + resp, err := csdsClient.FetchClientStatus(context.Background(), &csdspb.ClientStatusRequest{}) + if err != nil { + log.Fatalf("failed to fetch xds config: %v", err) + } + return resp +} + +// GetHealthStatus fetches the health checking status of the service from peer +func GetHealthStatus(service string) string { + resp, err := healthClient.Check(context.Background(), &healthpb.HealthCheckRequest{Service: service}) + if err != nil { + log.Fatalf("failed to fetch health status for \"%s\": %v", service, err) + } + return healthpb.HealthCheckResponse_ServingStatus_name[int32(resp.Status)] +} diff --git a/cmd/verbose/verbose.go b/cmd/verbose/verbose.go new file mode 100644 index 0000000..8dd5944 --- /dev/null +++ b/cmd/verbose/verbose.go @@ -0,0 +1,17 @@ +package verbose + +import "log" + +var enableDebugOutput = false + +// EnableDebugOutput enables debugging output +func EnableDebugOutput() { + enableDebugOutput = true +} + +// Debugf prints log if debugging is enabled +func Debugf(format string, v ...interface{}) { + if enableDebugOutput { + log.Printf(format, v...) + } +} diff --git a/cmd/xds.go b/cmd/xds.go new file mode 100644 index 0000000..a94b1dc --- /dev/null +++ b/cmd/xds.go @@ -0,0 +1,206 @@ +package cmd + +import ( + "fmt" + "strings" + + "github.com/grpc-ecosystem/grpcdebug/cmd/transport" + + adminpb "github.com/envoyproxy/go-control-plane/envoy/admin/v3" + clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" + endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" + routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" + csdspb "github.com/envoyproxy/go-control-plane/envoy/service/status/v3" + "github.com/golang/protobuf/ptypes" + timestamppb "github.com/golang/protobuf/ptypes/timestamp" + "github.com/spf13/cobra" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" +) + +func printJson(m proto.Message) error { + var option protojson.MarshalOptions + option.Multiline = true + option.Indent = " " + option.UseProtoNames = false + option.UseEnumNumbers = false + jsonbytes, err := option.Marshal(m) + if err != nil { + return err + } + fmt.Println(string(jsonbytes)) + return nil +} + +func sortPerXdsConfigs(clientStatus *csdspb.ClientStatusResponse) { + var xdsConfigs [4]*csdspb.PerXdsConfig + for _, xdsConfig := range clientStatus.Config[0].XdsConfig { + switch xdsConfig.PerXdsConfig.(type) { + case *csdspb.PerXdsConfig_ListenerConfig: + xdsConfigs[0] = xdsConfig + case *csdspb.PerXdsConfig_RouteConfig: + xdsConfigs[1] = xdsConfig + case *csdspb.PerXdsConfig_ClusterConfig: + xdsConfigs[2] = xdsConfig + case *csdspb.PerXdsConfig_EndpointConfig: + xdsConfigs[3] = xdsConfig + } + } + clientStatus.Config[0].XdsConfig = xdsConfigs[:] +} + +func xdsConfigCommandRunWithError(cmd *cobra.Command, args []string) error { + clientStatus := transport.FetchClientStatus() + if len(args) == 0 { + sortPerXdsConfigs(clientStatus) + return printJson(clientStatus) + } + // Filter the CSDS output + var demand string + demand = strings.ToLower(args[0]) + for _, xdsConfig := range clientStatus.Config[0].XdsConfig { + switch xdsConfig.PerXdsConfig.(type) { + case *csdspb.PerXdsConfig_ListenerConfig: + if demand == "lds" { + return printJson(xdsConfig.GetListenerConfig()) + } + case *csdspb.PerXdsConfig_RouteConfig: + if demand == "rds" { + return printJson(xdsConfig.GetRouteConfig()) + } + case *csdspb.PerXdsConfig_ClusterConfig: + if demand == "cds" { + return printJson(xdsConfig.GetClusterConfig()) + } + case *csdspb.PerXdsConfig_EndpointConfig: + if demand == "eds" { + return printJson(xdsConfig.GetEndpointConfig()) + } + } + } + return fmt.Errorf("Failed to find xDS config with type %s", args[0]) +} + +var xdsConfigCmd = &cobra.Command{ + Use: "config [lds|rds|cds|eds]", + Short: "Dump the operating xDS configs.", + RunE: xdsConfigCommandRunWithError, + Args: cobra.MaximumNArgs(1), +} + +type xdsResourceStatusEntry struct { + Name string + Status adminpb.ClientResourceStatus + Version string + Type string + LastUpdated *timestamppb.Timestamp +} + +func prettyClientResourceStatus(s adminpb.ClientResourceStatus) string { + return adminpb.ClientResourceStatus_name[int32(s)] +} + +func printStatusEntry(entry *xdsResourceStatusEntry) { + fmt.Fprintf( + w, "%v\t%v\t%v\t%v\t%v\t\n", + entry.Name, + prettyClientResourceStatus(entry.Status), + entry.Version, + entry.Type, + prettyTime(entry.LastUpdated), + ) +} + +func xdsStatusCommandRunWithError(cmd *cobra.Command, args []string) error { + clientStatus := transport.FetchClientStatus() + + fmt.Fprintln(w, "Name\tStatus\tVersion\tType\tLastUpdated") + config := clientStatus.Config[0] + for _, xdsConfig := range config.XdsConfig { + switch xdsConfig.PerXdsConfig.(type) { + case *csdspb.PerXdsConfig_ListenerConfig: + for _, dynamicListener := range xdsConfig.GetListenerConfig().DynamicListeners { + var entry = xdsResourceStatusEntry{ + Name: dynamicListener.Name, + Status: dynamicListener.ClientStatus, + } + if state := dynamicListener.GetActiveState(); state != nil { + entry.Version = state.VersionInfo + entry.Type = state.Listener.TypeUrl + entry.LastUpdated = state.LastUpdated + } + printStatusEntry(&entry) + } + case *csdspb.PerXdsConfig_RouteConfig: + for _, dynamicRouteConfig := range xdsConfig.GetRouteConfig().DynamicRouteConfigs { + var entry = xdsResourceStatusEntry{ + Status: dynamicRouteConfig.ClientStatus, + Version: dynamicRouteConfig.VersionInfo, + Type: dynamicRouteConfig.RouteConfig.TypeUrl, + LastUpdated: dynamicRouteConfig.LastUpdated, + } + if packed := dynamicRouteConfig.GetRouteConfig(); packed != nil { + var routeConfig routepb.RouteConfiguration + if err := ptypes.UnmarshalAny(packed, &routeConfig); err != nil { + return err + } + entry.Name = routeConfig.Name + } + printStatusEntry(&entry) + } + case *csdspb.PerXdsConfig_ClusterConfig: + for _, dynamicCluster := range xdsConfig.GetClusterConfig().DynamicActiveClusters { + var entry = xdsResourceStatusEntry{ + Status: dynamicCluster.ClientStatus, + Version: dynamicCluster.VersionInfo, + Type: dynamicCluster.Cluster.TypeUrl, + LastUpdated: dynamicCluster.LastUpdated, + } + if packed := dynamicCluster.GetCluster(); packed != nil { + var cluster clusterpb.Cluster + if err := ptypes.UnmarshalAny(packed, &cluster); err != nil { + return err + } + entry.Name = cluster.Name + } + printStatusEntry(&entry) + } + case *csdspb.PerXdsConfig_EndpointConfig: + for _, dynamicEndpoint := range xdsConfig.GetEndpointConfig().GetDynamicEndpointConfigs() { + var entry = xdsResourceStatusEntry{ + Status: dynamicEndpoint.ClientStatus, + Version: dynamicEndpoint.VersionInfo, + Type: dynamicEndpoint.EndpointConfig.TypeUrl, + LastUpdated: dynamicEndpoint.LastUpdated, + } + if packed := dynamicEndpoint.GetEndpointConfig(); packed != nil { + var endpoint endpointpb.ClusterLoadAssignment + if err := ptypes.UnmarshalAny(packed, &endpoint); err != nil { + return err + } + entry.Name = endpoint.ClusterName + } + printStatusEntry(&entry) + } + } + } + w.Flush() + return nil +} + +var xdsStatusCmd = &cobra.Command{ + Use: "status", + Short: "Print the config synchronization status.", + RunE: xdsStatusCommandRunWithError, +} + +var xdsCmd = &cobra.Command{ + Use: "xds", + Short: "Fetch xDS related information.", +} + +func init() { + xdsCmd.AddCommand(xdsConfigCmd) + xdsCmd.AddCommand(xdsStatusCmd) + rootCmd.AddCommand(xdsCmd) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..be9e77b --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module github.com/grpc-ecosystem/grpcdebug + +go 1.12 + +require ( + github.com/dustin/go-humanize v1.0.0 + github.com/envoyproxy/go-control-plane v0.9.9-0.20210208192213-66ad1e49efae + github.com/golang/protobuf v1.4.2 + github.com/spf13/cobra v1.1.1 + google.golang.org/grpc v1.27.0 + google.golang.org/protobuf v1.23.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ddc84ac --- /dev/null +++ b/go.sum @@ -0,0 +1,332 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210208192213-66ad1e49efae h1:nkcv88fZ2PjhCcaDo/WRWYdiszKvOt5ZgzTKztpES48= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210208192213-66ad1e49efae/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4= +github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a h1:Ob5/580gVHBJZgXnff1cZDbG+xLtMVE5mDRTe+nIsX4= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/internal/testing/ca.pem b/internal/testing/ca.pem new file mode 100644 index 0000000..6c8511a --- /dev/null +++ b/internal/testing/ca.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV +BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX +aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla +Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 +YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT +BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 ++L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu +g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd +Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV +HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau +sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m +oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG +Dfcog5wrJytaQ6UA0wE= +-----END CERTIFICATE----- diff --git a/internal/testing/grpcdebug_config b/internal/testing/grpcdebug_config new file mode 100644 index 0000000..de1a8d6 --- /dev/null +++ b/internal/testing/grpcdebug_config @@ -0,0 +1,14 @@ +Server dev + RealAddress localhost:50051 + Security Insecure + +Server prod + RealAddress localhost:50052 + Security TLS + CredentialFile ./internal/testing/ca.pem + ServerNameOverride *.test.youtube.com + +Server localhost:50052 + Security TLS + CredentialFile ./internal/testing/ca.pem + ServerNameOverride *.test.youtube.com diff --git a/internal/testing/testserver/csds_config_dump.json b/internal/testing/testserver/csds_config_dump.json new file mode 100644 index 0000000..2a5d5b8 --- /dev/null +++ b/internal/testing/testserver/csds_config_dump.json @@ -0,0 +1,200 @@ +{ + "config": [ + { + "node": { + "id": "projects/1040920224690/networks/default/nodes/5cc9170c-d5b4-4061-b431-c1d43e6ac0ab", + "cluster": "cluster", + "metadata": { + "INSTANCE_IP": "192.168.120.31", + "TRAFFICDIRECTOR_GCP_PROJECT_NUMBER": "1040920224690", + "TRAFFICDIRECTOR_NETWORK_NAME": "default" + }, + "locality": { + "zone": "us-central1-a" + }, + "userAgentName": "gRPC Java", + "userAgentVersion": "1.38.0-SNAPSHOT", + "clientFeatures": [ + "envoy.lb.does_not_support_overprovisioning" + ] + }, + "xdsConfig": [ + { + "listenerConfig": { + "versionInfo": "1617141154495058478", + "dynamicListeners": [ + { + "name": "xds-test-server:1337", + "activeState": { + "versionInfo": "1617141154495058478", + "listener": { + "@type": "type.googleapis.com/envoy.config.listener.v3.Listener", + "apiListener": { + "apiListener": { + "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager", + "httpFilters": [ + { + "name": "envoy.filters.http.fault", + "typedConfig": { + "@type": "type.googleapis.com/envoy.extensions.filters.http.fault.v3.HTTPFault" + } + }, + { + "name": "envoy.filters.http.router", + "typedConfig": { + "@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router", + "suppressEnvoyHeaders": true + } + } + ], + "rds": { + "configSource": { + "ads": {}, + "resourceApiVersion": "V3" + }, + "routeConfigName": "URL_MAP/1040920224690_sergii-psm-test-url-map_0_xds-test-server:1337" + }, + "statPrefix": "trafficdirector" + } + }, + "name": "xds-test-server:1337" + }, + "lastUpdated": "2021-03-31T01:20:33.144Z" + }, + "clientStatus": "ACKED" + } + ] + } + }, + { + "routeConfig": { + "dynamicRouteConfigs": [ + { + "versionInfo": "1617141154495058478", + "routeConfig": { + "@type": "type.googleapis.com/envoy.config.route.v3.RouteConfiguration", + "name": "URL_MAP/1040920224690_sergii-psm-test-url-map_0_xds-test-server:1337", + "virtualHosts": [ + { + "domains": [ + "xds-test-server:1337" + ], + "routes": [ + { + "match": { + "prefix": "" + }, + "route": { + "cluster": "cloud-internal-istio:cloud_mp_1040920224690_6530603179561593229", + "timeout": "30s", + "retryPolicy": { + "retryOn": "gateway-error", + "numRetries": 1, + "perTryTimeout": "30s" + } + } + } + ] + } + ] + }, + "lastUpdated": "2021-03-31T01:20:33.302Z", + "clientStatus": "ACKED" + } + ] + } + }, + { + "clusterConfig": { + "versionInfo": "1617141154495058478", + "dynamicActiveClusters": [ + { + "versionInfo": "1617141154495058478", + "cluster": { + "@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster", + "circuitBreakers": { + "thresholds": [ + { + "maxConnections": 2147483647, + "maxPendingRequests": 2147483647, + "maxRequests": 2147483647, + "maxRetries": 2147483647 + } + ] + }, + "commonLbConfig": { + "healthyPanicThreshold": { + "value": 1 + }, + "localityWeightedLbConfig": {} + }, + "connectTimeout": "30s", + "edsClusterConfig": { + "edsConfig": { + "ads": {}, + "initialFetchTimeout": "15s", + "resourceApiVersion": "V3" + } + }, + "http2ProtocolOptions": { + "maxConcurrentStreams": 100 + }, + "lrsServer": { + "self": {} + }, + "metadata": { + "filterMetadata": { + "com.google.trafficdirector": { + "backend_service_name": "sergii-psm-test-backend-service" + } + } + }, + "name": "cloud-internal-istio:cloud_mp_1040920224690_6530603179561593229", + "type": "EDS" + }, + "lastUpdated": "2021-03-31T01:20:33.853Z", + "clientStatus": "ACKED" + } + ] + } + }, + { + "endpointConfig": { + "dynamicEndpointConfigs": [ + { + "versionInfo": "1", + "endpointConfig": { + "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", + "clusterName": "cloud-internal-istio:cloud_mp_1040920224690_6530603179561593229", + "endpoints": [ + { + "locality": { + "subZone": "jf:us-central1-a_7062512536751318190_neg" + }, + "lbEndpoints": [ + { + "endpoint": { + "address": { + "socketAddress": { + "address": "192.168.120.26", + "portValue": 8080 + } + } + }, + "healthStatus": "HEALTHY" + } + ], + "loadBalancingWeight": 100 + } + ] + }, + "lastUpdated": "2021-03-31T01:20:33.936Z", + "clientStatus": "ACKED" + } + ] + } + } + ] + } + ] +} diff --git a/internal/testing/testserver/main.go b/internal/testing/testserver/main.go new file mode 100644 index 0000000..1793d03 --- /dev/null +++ b/internal/testing/testserver/main.go @@ -0,0 +1,147 @@ +// Testserver mocking the responses of Channelz/CSDS/Health + +package main + +import ( + "context" + "crypto/tls" + "flag" + "fmt" + "io/ioutil" + "log" + "math/rand" + "net" + "os" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/channelz/service" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/health" + "google.golang.org/grpc/reflection" + "google.golang.org/grpc/testdata" + + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/fault/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" + csdspb "github.com/envoyproxy/go-control-plane/envoy/service/status/v3" + pb "google.golang.org/grpc/examples/helloworld/helloworld" + healthpb "google.golang.org/grpc/health/grpc_health_v1" + "google.golang.org/protobuf/encoding/protojson" +) + +var ( + servingPortFlag = flag.Int("serving", 10001, "the serving port") + adminPortFlag = flag.Int("admin", 50051, "the admin port") + secureAdminPortFlag = flag.Int("secure_admin", 50052, "the secure admin port") + healthFlag = flag.Bool("health", true, "the health checking status") + qpsFlag = flag.Int("qps", 10, "The size of the generated load against itself") + abortPercentageFlag = flag.Int("abort", 10, "The percentage of failed RPCs") +) + +// Implements the Greeter service +type server struct { + pb.UnimplementedGreeterServer +} + +func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + if int(r.Int31n(100)) <= *abortPercentageFlag { + return nil, grpc.Errorf( + codes.Code(r.Int31n(15)+1), + "Fault injected", + ) + } + return &pb.HelloReply{Message: "Hello " + in.Name}, nil +} + +// Implements the CSDS service +type mockCsdsServer struct { + csdspb.UnimplementedClientStatusDiscoveryServiceServer +} + +func (*mockCsdsServer) FetchClientStatus(ctx context.Context, req *csdspb.ClientStatusRequest) (*csdspb.ClientStatusResponse, error) { + file, err := os.Open("csds_config_dump.json") + if err != nil { + panic(err) + } + configDump, err := ioutil.ReadAll(file) + if err != nil { + panic(err) + } + var response csdspb.ClientStatusResponse + if err := protojson.Unmarshal([]byte(configDump), &response); err != nil { + panic(err) + } + return &response, nil +} + +func setupAdminServer(s *grpc.Server) { + reflection.Register(s) + service.RegisterChannelzServiceToServer(s) + csdspb.RegisterClientStatusDiscoveryServiceServer(s, &mockCsdsServer{}) + healthcheck := health.NewServer() + if *healthFlag { + healthcheck.SetServingStatus("", healthpb.HealthCheckResponse_SERVING) + healthcheck.SetServingStatus("helloworld.Greeter", healthpb.HealthCheckResponse_SERVING) + } else { + healthcheck.SetServingStatus("", healthpb.HealthCheckResponse_NOT_SERVING) + healthcheck.SetServingStatus("helloworld.Greeter", healthpb.HealthCheckResponse_NOT_SERVING) + } + healthpb.RegisterHealthServer(s, healthcheck) +} + +func main() { + // Parse the flags + flag.Parse() + // Creates the primary server + lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *servingPortFlag)) + if err != nil { + panic(err) + } + defer lis.Close() + fmt.Printf("Serving Business Logic on :%d\n", *servingPortFlag) + cert, err := tls.LoadX509KeyPair(testdata.Path("server1.pem"), testdata.Path("server1.key")) + if err != nil { + log.Fatalf("failed to load key pair: %s", err) + } + s := grpc.NewServer(grpc.Creds(credentials.NewServerTLSFromCert(&cert))) + pb.RegisterGreeterServer(s, &server{}) + go s.Serve(lis) + // Creates the admin server without credentials + insecureListener, err := net.Listen("tcp", fmt.Sprintf(":%d", *adminPortFlag)) + if err != nil { + panic(err) + } + defer insecureListener.Close() + insecureAdminServer := grpc.NewServer() + setupAdminServer(insecureAdminServer) + go insecureAdminServer.Serve(insecureListener) + fmt.Printf("Serving Insecure Admin Services on :%d\n", *adminPortFlag) + // Creates the admin server with credentials + secureListener, err := net.Listen("tcp", fmt.Sprintf(":%d", *secureAdminPortFlag)) + if err != nil { + panic(err) + } + defer secureListener.Close() + secureAdminServer := grpc.NewServer(grpc.Creds(credentials.NewServerTLSFromCert(&cert))) + setupAdminServer(secureAdminServer) + go secureAdminServer.Serve(secureListener) + fmt.Printf("Serving Secure Admin Services on :%d\n", *secureAdminPortFlag) + // Creates a client to hydrate the primary server + creds, err := credentials.NewClientTLSFromFile(testdata.Path("ca.pem"), "*.test.youtube.com") + if err != nil { + panic(err) + } + conn, err := grpc.Dial(fmt.Sprintf("localhost:%d", *servingPortFlag), grpc.WithTransportCredentials(creds)) + if err != nil { + panic(err) + } + defer conn.Close() + greeterClient := pb.NewGreeterClient(conn) + for { + greeterClient.SayHello(context.Background(), &pb.HelloRequest{Name: "world"}) + time.Sleep(time.Second / time.Duration(*qpsFlag)) + } +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..c406113 --- /dev/null +++ b/main.go @@ -0,0 +1,159 @@ +package main + +import ( + cmd "github.com/grpc-ecosystem/grpcdebug/cmd" + + // Preload as much proto descriptors as possible, so the released binaries can + // have better forward compatibility. + _ "github.com/envoyproxy/go-control-plane/envoy/admin/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/accesslog/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/bootstrap/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/common/matcher/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/grpc_credential/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/metrics/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/overload/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/ratelimit/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/rbac/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/tap/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/config/trace/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/data/accesslog/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/data/cluster/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/data/core/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/data/dns/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/data/tap/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/file/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/grpc/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/wasm/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/clusters/aggregate/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/clusters/dynamic_forward_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/common/dynamic_forward_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/common/matching/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/common/ratelimit/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/common/tap/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/compression/brotli/compressor/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/compression/brotli/decompressor/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/compression/gzip/compressor/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/compression/gzip/decompressor/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/common/dependency/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/common/fault/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/common/matcher/action/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/adaptive_concurrency/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/admission_control/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/aws_lambda/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/aws_request_signing/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/buffer/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/cache/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/cdn_loop/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/compressor/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/cors/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/csrf/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/decompressor/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/dynamic_forward_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/dynamo/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/ext_authz/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/ext_proc/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/fault/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_http1_bridge/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_http1_reverse_bridge/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_json_transcoder/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_stats/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_web/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/gzip/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/header_to_metadata/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/health_check/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/ip_tagging/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/jwt_authn/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/kill_request/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/local_ratelimit/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/lua/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/oauth2/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/on_demand/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/original_src/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/ratelimit/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/rbac/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/squash/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/tap/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/wasm/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/listener/http_inspector/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/listener/original_dst/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/listener/original_src/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/listener/proxy_protocol/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/listener/tls_inspector/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/client_ssl_auth/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/direct_response/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/dubbo_proxy/router/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/dubbo_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/echo/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/ext_authz/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/kafka_broker/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/local_ratelimit/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/mongo_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/mysql_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/postgres_proxy/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/ratelimit/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/rbac/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/redis_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/rocketmq_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/sni_cluster/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/sni_dynamic_forward_proxy/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/tcp_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/thrift_proxy/filters/ratelimit/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/thrift_proxy/router/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/thrift_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/wasm/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/zookeeper_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/udp/dns_filter/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/udp/udp_proxy/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/internal_redirect/allow_listed_routes/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/internal_redirect/previous_routes/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/internal_redirect/safe_cross_scheme/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/network/socket_interface/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/rate_limit_descriptors/expr/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/retry/host/omit_host_metadata/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/retry/priority/previous_priorities/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/stat_sinks/wasm/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/alts/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/proxy_protocol/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/quic/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/raw_buffer/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/starttls/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tap/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/wasm/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/extensions/watchdog/profile_action/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/service/accesslog/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/cluster/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/endpoint/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/event_reporting/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3alpha" + _ "github.com/envoyproxy/go-control-plane/envoy/service/extension/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/health/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/listener/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/load_stats/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/metrics/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/ratelimit/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/route/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/runtime/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/secret/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/status/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/tap/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/service/trace/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/type/metadata/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/type/tracing/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/type/v3" + _ "github.com/envoyproxy/go-control-plane/envoy/watchdog/v3alpha" +) + +func main() { + cmd.Execute() +}