mesh

package
v1.86.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Mesh package provides support for the mesh graph handlers such as supported path variables and query params, as well as types for mesh graph processing.

Index

Constants

View Source
const (
	BoxByCluster   string = "cluster"
	BoxByNamespace string = "namespace"
)
View Source
const (
	BoxTypeCluster       string = "cluster"
	BoxTypeNamespace     string = "namespace"
	External             string = "_external_" // Special cluster name for external deployment
	InfraTypeCluster     string = "cluster"    // cluster node (not box) with no other infra (very rare)
	InfraTypeDataPlane   string = "dataplane"  // single node representing 1 or more dataPlane namespaces
	InfraTypeGrafana     string = "grafana"
	InfraTypeIstiod      string = "istiod"
	InfraTypeKiali       string = "kiali"
	InfraTypeMetricStore string = "metricStore"
	InfraTypeNamespace   string = "namespace"
	InfraTypeTraceStore  string = "traceStore"
	NodeTypeBox          string = "box"                 // The special "box" node. isBox will be set to a BoxType
	NodeTypeInfra        string = "infra"               // Any non-box node of interest
	TF                   string = "2006-01-02 15:04:05" // TF is the TimeFormat for timestamps
)
View Source
const (
	VendorCytoscape string = "cytoscape"
)

The supported vendors

Variables

StatusGetter var allows test code to mock out this function with a mock

Functions

func BadRequest

func BadRequest(message string)

BadRequest panics with BadRequest and the provided message

func CheckError

func CheckError(err error)

CheckError panics with the supplied error if it is non-nil

func CheckUnavailable

func CheckUnavailable(err error)

CheckUnavailable panics with StatusServiceUnavailable (503) and the supplied error if it is non-nil

func Error

func Error(message string)

Error panics with InternalServerError (500) and the provided message

func Forbidden

func Forbidden(message string)

Forbidden panics with Forbidden and the provided message

func Id

func Id(cluster, namespace, name, infraType, version string, isExternal bool) (id string, err error)

Id returns the unique node ID

func IsOK

func IsOK(telemetryVal string) bool

IsOK just validates that a telemetry label value is not empty

Types

type AccessibleNamespace

type AccessibleNamespace struct {
	Cluster           string
	CreationTimestamp time.Time
	Name              string
}

type AccessibleNamespaces

type AccessibleNamespaces map[ClusterSensitiveKey]*AccessibleNamespace

AccessibleNamepaces is a map with Key: ClusterSensitive namespace Key, Value: *AccessibleNamespace

type Appender

type Appender interface {
	// AppendGraph performs the appender work on the provided traffic map. The map may be initially empty.
	// An appender is allowed to add or remove map entries. namespaceInfo will be nil for Finalizer appenders.
	AppendGraph(meshMap MeshMap, globalInfo *AppenderGlobalInfo, namespaceInfo *AppenderNamespaceInfo)

	// IsFinalizer returns true if the appender should run only on the final TrafficMap, or false if the appender should
	// run against every requested namespace.
	IsFinalizer() bool

	// Name returns a unique appender name and which is the name used to identify the appender (e.g in 'appenders' query param)
	Name() string
}

Appender is implemented by any code offering to append a service graph with supplemental information. On error the appender should panic and it will be handled as an error response.

type AppenderGlobalInfo

type AppenderGlobalInfo struct {
	Business          *business.Layer
	ClientFactory     kubernetes.ClientFactory
	Config            *config.Config
	Grafana           *grafana.Service
	IstioStatusGetter IstioStatusGetter
	KialiCache        cache.KialiCache
	PromClient        *prometheus.Client

	Vendor AppenderVendorInfo // telemetry vendor's global info
}

AppenderGlobalInfo caches information relevant to a single graph. It allows an appender to populate the cache and then it, or another appender can re-use the information. A new instance is generated for graph and is initially empty.

func NewAppenderGlobalInfo

func NewAppenderGlobalInfo() *AppenderGlobalInfo

type AppenderNamespaceInfo

type AppenderNamespaceInfo struct {
	Namespace string             // always provided
	Vendor    AppenderVendorInfo // telemetry vendor's namespace info
}

AppenderNamespaceInfo caches information relevant to a single namespace. It allows one appender to populate the cache and another to then re-use the information. A new instance is generated for each namespace of a single graph and is initially seeded with only Namespace.

func NewAppenderNamespaceInfo

func NewAppenderNamespaceInfo(namespace string) *AppenderNamespaceInfo

type AppenderVendorInfo

type AppenderVendorInfo map[string]interface{}

func NewAppenderVendorInfo

func NewAppenderVendorInfo() AppenderVendorInfo

type ClusterSensitiveKey

type ClusterSensitiveKey = string

ClusterSensitiveKey is the recommended [string] type for maps keying on a cluster-sensitive name

func GetClusterSensitiveKey

func GetClusterSensitiveKey(cluster, name string) ClusterSensitiveKey

GetClusterSensitiveKey returns a valid key for maps using a ClusterSensitiveKey

type CommonOptions

type CommonOptions struct {
	Params    url.Values // make available the raw query params for vendor-specific handling
	QueryTime int64      // unix time in seconds
}

CommonOptions are those supplied to Vendors

type ConfigOptions

type ConfigOptions struct {
	BoxBy string
	CommonOptions
	MeshName string
}

ConfigOptions are those supplied to Config Vendors

type ConfigVendor

type ConfigVendor interface {

	// NewConfig is required by the ConfigVendor interface.  It must produce a valid
	// Config for the provided TrafficMap, It is recommended to use the graph/util.go
	// definitions for error handling. Refer to the Cytoscape implementation as an example.
	NewConfig(meshMap MeshMap, o ConfigOptions) interface{}
}

ConfigVendor is an interface that must be satisfied for each config vendor implementation.

type Edge

type Edge struct {
	Dest     *Node
	Metadata Metadata // app-specific data
	Source   *Node
}

func NewEdge

func NewEdge(source, dest *Node) Edge

NewEdge constructor

type IstioStatusGetter added in v1.86.0

type IstioStatusGetter interface {
	GetStatus(ctx context.Context, cluster string) (kubernetes.IstioComponentStatus, error)
}

IstioStatusGetter gets the status of the mesh graph components

type MeshMap

type MeshMap map[string]*Node

MeshMap is a map of app Nodes, each optionally holding Edge data. Metadata is a general purpose map for holding any desired node or edge information.

func NewMeshMap

func NewMeshMap() MeshMap

NewMeshMap constructor

func (MeshMap) Edges

func (tm MeshMap) Edges() []*Edge

Edges returns all of the edges in the traffic map.

type Metadata

type Metadata map[MetadataKey]interface{}

Metadata is a map for storing node and edge metadata values reported by the vendors

func NewMetadata

func NewMetadata() Metadata

NewMetadata returns an empty Metadata map

type MetadataKey

type MetadataKey string

MetadataKey is a mnemonic type name for string

const (
	HealthData     MetadataKey = "healthData"
	InfraData      MetadataKey = "infraData"
	IsCanary       MetadataKey = "isCanary"
	IsExternal     MetadataKey = "isExternal"
	IsInaccessible MetadataKey = "isInaccessible"
	IsMTLS         MetadataKey = "isMTLS"
	Version        MetadataKey = "version"
)

Metadata keys to be used instead of literal strings

type NamespaceInfo

type NamespaceInfo struct {
	Duration time.Duration
	IsIstio  bool
	Name     string
}

type NamespaceInfoMap

type NamespaceInfoMap map[string]NamespaceInfo

func NewNamespaceInfoMap

func NewNamespaceInfoMap() NamespaceInfoMap

type Node

type Node struct {
	Cluster   string   // cluster name
	Edges     []*Edge  // child nodes
	ID        string   // unique identifier for the node
	InfraName string   // infra name
	InfraType string   // set to appropriate InfraType
	Metadata  Metadata // app-specific data
	Namespace string   // namespace name
	NodeType  string   // Node type
}

func NewNode

func NewNode(id, nodeType, infraType, cluster, namespace, name string) *Node

NewNode constructor assigns the specified ID

func (*Node) AddEdge

func (s *Node) AddEdge(dest *Node) *Edge

AddEdge adds an edge to the specified dest node

type Options

type Options struct {
	AccessibleNamespaces AccessibleNamespaces
	Appenders            RequestedAppenders // requested appenders, nil if param not supplied
	ConfigVendor         string
	Namespaces           NamespaceInfoMap
	ConfigOptions
}

Options comprises all available options

func NewOptions

func NewOptions(r *http.Request) Options

type RequestedAppenders

type RequestedAppenders struct {
	All           bool
	AppenderNames []string
}

type Response

type Response struct {
	Message string
	Code    int
}

func Panic

func Panic(message string, code int) Response

Panic panics with the provided HTTP response code and message

Directories

Path Synopsis
config

Jump to

Keyboard shortcuts

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