v2

package
v0.0.0-...-fd0897c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2018 License: Apache-2.0 Imports: 32 Imported by: 0

README

Debug interface

Debugging for v2 is a bit different - we no longer use a cache.

The debug handlers are configured on the monitoring port (default 9093).


PILOT=istio-pilot:9093

curl $PILOT/debug/edsz
curl $PILOT/debug/ldsz
curl $PILOT/debug/cdsz



# General metrics
curl $PILOT/metrics 


Each handler takes an extra parameter, "debug=0|1" which flips the verbosity of the messages for that component (similar with envoy).

Each handler takes an extra parameter "push=1", which triggers a config push to all connected endpoints.

Handlers should list, in json format:

  • one entry for each connected envoy
  • the timestamp of the connection

Example for EDS:

{

   // Cluster
   "echosrv.istio-system.svc.cluster.local|grpc-ping": {
    "EdsClients": {
      // One for each connected envoy. 
      "sidecar~172.17.0.8~echosrv-deployment-5b7878cc9-dlm8j.istio-system~istio-system.svc.cluster.local-116": {
        // Should match the info in the node (this is the real remote address)
        "PeerAddr": "172.17.0.8:42044",
        "Clusters": [
          // Should match the cluster, this is what is monitored
          "echosrv.istio-system.svc.cluster.local|grpc-ping"
        ],
        // Time the sidecar connected to pilot
        "Connect": "2018-03-22T15:01:07.527304202Z"
      },
      "sidecar~172.17.0.9~echosrv-deployment-5b7878cc9-wb9b7.istio-system~istio-system.svc.cluster.local-75": {
        "PeerAddr": "172.17.0.9:47182",
        "Clusters": [
          "echosrv.istio-system.svc.cluster.local|grpc-ping"
        ],
        "Connect": "2018-03-22T15:01:00.465066249Z"
      }
    },
    // The info pushed to each connected sidecar watching the cluster.
    "LoadAssignment": {
      "cluster_name": "echosrv.istio-system.svc.cluster.local|grpc-ping",
      "endpoints": [
        {
          "locality": {},
          "lb_endpoints": [
           {
              // Should match the endpoint and port from 'kubectl get ep'
              "endpoint": {
                "address": {
                  "Address": {
                    "SocketAddress": {
                      "address": "172.17.0.8",
                      "PortSpecifier": {
                        "PortValue": 8079
                      },
                      "ipv4_compat": true
                    }
                  }
                }
              }
            },
          ]
          }
      ]
      }
    }


Log messages

Verbose messages for v2 is controlled by env variables PILOT_DEBUG_{EDS,CDS,LDS}. Setting it to "0" disables debug, setting it to "1" enables - debug is currently enabled by default, since it is not very verbose.

Messages are prefixed with EDS/LDS/CDS.

What we log and how to use it:

  • sidecar connecting to pilot: "EDS/CSD/LDS: REQ ...". This includes the node, IP and the discovery request proto. Should show up when the sidecar starts up.
  • sidecar disconnecting from pilot: xDS: close. This happens when a pod is stopped.
  • push events - whenever we push a config the the sidecar.
  • "XDS: Registry event..." - indicates a registry event, should be followed by PUSH messages for each endpoint.
  • "EDS: no instances": pay close attention to this event, it indicates that Envoy asked for a cluster but pilot doesn't have any valid instance. At some point after, when the instance eventually shows up you should see an EDS PUSH message.

In addition, the registry has slightly more verbose messages about the events, so it is possible to map an event in the registry to config pushes.

Example requests and responses

EDS:


    node:<id:"ingress~~istio-ingress-6796c456f4-7zqtm.istio-system~istio-system.svc.cluster.local"
    cluster:"istio-ingress"
    build_version:"0/1.6.0-dev//RELEASE" >
    resource_names:"echosrv.istio-system.svc.cluster.local|http-echo"
    type_url:"type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"

Documentation

Index

Constants

View Source
const (

	// ClusterType is used for cluster discovery. Typically first request received
	ClusterType = typePrefix + "Cluster"
	// EndpointType is used for EDS and ADS endpoint discovery. Typically second request.
	EndpointType = typePrefix + "ClusterLoadAssignment"
	// ListenerType is sent after clusters and endpoints.
	ListenerType = typePrefix + "Listener"
	// RouteType is sent after listeners.
	RouteType = typePrefix + "Route"
)

Variables

This section is empty.

Functions

func EDSz

func EDSz(w http.ResponseWriter, req *http.Request)

EDSz implements a status and debug interface for EDS. It is mapped to /debug/edsz on the monitor port (9093).

func PushAll

func PushAll()

PushAll implements old style invalidation, generated when any rule or endpoint changes. Primary code path is from v1 discoveryService.clearCache(), which is added as a handler to the model ConfigStorageCache and Controller.

Types

type ConfigCache

type ConfigCache struct {
	// contains filtered or unexported fields
}

ConfigCache for xDS resources

func NewConfigCache

func NewConfigCache(services model.ServiceDiscovery, configs model.ConfigStore) *ConfigCache

NewConfigCache spins up a new config cache

func (*ConfigCache) ID

func (cache *ConfigCache) ID(node *core.Node) string

ID ...

func (*ConfigCache) OnConfigEvent

func (cache *ConfigCache) OnConfigEvent(svc model.Config, event model.Event)

OnConfigEvent ...

func (*ConfigCache) OnFetchRequest

func (cache *ConfigCache) OnFetchRequest(*v2.DiscoveryRequest)

OnFetchRequest ...

func (*ConfigCache) OnFetchResponse

func (cache *ConfigCache) OnFetchResponse(*v2.DiscoveryRequest, *v2.DiscoveryResponse)

OnFetchResponse ...

func (*ConfigCache) OnServiceEvent

func (cache *ConfigCache) OnServiceEvent(svc *model.Service, event model.Event)

OnServiceEvent ...

func (*ConfigCache) OnStreamClosed

func (cache *ConfigCache) OnStreamClosed(int64)

OnStreamClosed ...

func (*ConfigCache) OnStreamOpen

func (cache *ConfigCache) OnStreamOpen(int64, string)

OnStreamOpen ...

func (*ConfigCache) OnStreamRequest

func (cache *ConfigCache) OnStreamRequest(int64, *v2.DiscoveryRequest)

OnStreamRequest ...

func (*ConfigCache) OnStreamResponse

func (cache *ConfigCache) OnStreamResponse(int64, *v2.DiscoveryRequest, *v2.DiscoveryResponse)

OnStreamResponse ...

func (*ConfigCache) Register

func (cache *ConfigCache) Register(grpcServer *grpc.Server)

Register with gRPC server

func (*ConfigCache) RegisterInput

func (cache *ConfigCache) RegisterInput(services model.Controller, configs model.ConfigStoreCache)

RegisterInput connects with the controllers

type DiscoveryServer

type DiscoveryServer struct {
	// GrpcServer supports gRPC for xDS v2 services.
	GrpcServer *grpc.Server

	// MemRegistry is used for debug and load testing, allow adding services. Visible for testing.
	MemRegistry *MemServiceDiscovery

	// ConfigGenerator is responsible for generating data plane configuration using Istio networking
	// APIs and service registry info
	ConfigGenerator *v1alpha3.ConfigGeneratorImpl
	// contains filtered or unexported fields
}

DiscoveryServer is Pilot's gRPC implementation for Envoy's v2 xds APIs

func NewDiscoveryServer

func NewDiscoveryServer(grpcServer *grpc.Server, env model.Environment, generator *v1alpha3.ConfigGeneratorImpl) *DiscoveryServer

NewDiscoveryServer creates DiscoveryServer that sources data from Pilot's internal mesh data structures

func (*DiscoveryServer) FetchEndpoints

FetchEndpoints implements xdsapi.EndpointDiscoveryServiceServer.FetchEndpoints().

func (*DiscoveryServer) InitDebug

func (s *DiscoveryServer) InitDebug(mux *http.ServeMux, sctl *aggregate.Controller)

InitDebug initializes the debug handlers and adds a debug in-memory registry.

func (*DiscoveryServer) StreamAggregatedResources

StreamAggregatedResources implements the ADS interface.

func (*DiscoveryServer) StreamEndpoints

StreamEndpoints implements xdsapi.EndpointDiscoveryServiceServer.StreamEndpoints().

func (*DiscoveryServer) StreamLoadStats

StreamLoadStats implements xdsapi.EndpointDiscoveryServiceServer.StreamLoadStats().

type EdsCluster

type EdsCluster struct {
	LoadAssignment *xdsapi.ClusterLoadAssignment

	// FirstUse is the time the cluster was first used, for debugging
	FirstUse time.Time

	// EdsClients keeps track of all nodes monitoring the cluster.
	EdsClients map[string]*XdsConnection

	// NonEmptyTime is the time the cluster first had a non-empty set of endpoints
	NonEmptyTime time.Time
	// contains filtered or unexported fields
}

EdsCluster tracks eds-related info for monitored clusters. In practice it'll include all clusters until we support on-demand cluster loading.

type MemServiceDiscovery

type MemServiceDiscovery struct {
	WantGetProxyServiceInstances  []*model.ServiceInstance
	ServicesError                 error
	GetServiceError               error
	InstancesError                error
	GetProxyServiceInstancesError error
	// contains filtered or unexported fields
}

MemServiceDiscovery is a mock discovery interface

func NewMemServiceDiscovery

func NewMemServiceDiscovery(services map[string]*model.Service, versions int) *MemServiceDiscovery

NewMemServiceDiscovery builds an in-memory MemServiceDiscovery

func (*MemServiceDiscovery) AddEndpoint

func (sd *MemServiceDiscovery) AddEndpoint(service, servicePortName string, servicePort int, address string, port int) *model.ServiceInstance

AddEndpoint adds an endpoint to a service.

func (*MemServiceDiscovery) AddInstance

func (sd *MemServiceDiscovery) AddInstance(service string, instance *model.ServiceInstance)

AddInstance adds an in-memory instance.

func (*MemServiceDiscovery) AddService

func (sd *MemServiceDiscovery) AddService(name string, svc *model.Service)

AddService adds an in-memory service.

func (*MemServiceDiscovery) ClearErrors

func (sd *MemServiceDiscovery) ClearErrors()

ClearErrors clear errors used for mocking failures during model.MemServiceDiscovery interface methods

func (*MemServiceDiscovery) GetIstioServiceAccounts

func (sd *MemServiceDiscovery) GetIstioServiceAccounts(hostname string, ports []string) []string

GetIstioServiceAccounts gets the Istio service accounts for a service hostname.

func (*MemServiceDiscovery) GetProxyServiceInstances

func (sd *MemServiceDiscovery) GetProxyServiceInstances(node model.Proxy) ([]*model.ServiceInstance, error)

GetProxyServiceInstances returns service instances associated with a node, resulting in 'in' services.

func (*MemServiceDiscovery) GetService

func (sd *MemServiceDiscovery) GetService(hostname string) (*model.Service, error)

GetService implements discovery interface

func (*MemServiceDiscovery) Instances

func (sd *MemServiceDiscovery) Instances(hostname string, ports []string,
	labels model.LabelsCollection) ([]*model.ServiceInstance, error)

Instances filters the service instances by labels. This assumes single port, as is used by EDS/ADS.

func (*MemServiceDiscovery) ManagementPorts

func (sd *MemServiceDiscovery) ManagementPorts(addr string) model.PortList

ManagementPorts implements discovery interface

func (*MemServiceDiscovery) Services

func (sd *MemServiceDiscovery) Services() ([]*model.Service, error)

Services implements discovery interface

type XdsConnection

type XdsConnection struct {
	// PeerAddr is the address of the client envoy, from network layer
	PeerAddr string

	// Time of connection, for debugging
	Connect time.Time

	// ConID is the connection identifier, used as a key in the connection table.
	// Currently based on the node name and a counter.
	ConID string

	HTTPListeners []*xdsapi.Listener
	RouteConfigs  map[string][]*xdsapi.RouteConfiguration

	// current list of clusters monitored by the client
	Clusters []string

	// Routes is the list of watched Routes.
	Routes []string

	// LDSWatch is set if the remote server is watching Listeners
	LDSWatch bool
	// CDSWatch is set if the remote server is watching Clusters
	CDSWatch bool
	// contains filtered or unexported fields
}

XdsConnection is a listener connection type.

type XdsEvent

type XdsEvent struct {
	// contains filtered or unexported fields
}

XdsEvent represents a config or registry event that results in a push.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL