render

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UncontainedID    = "uncontained"
	UncontainedMajor = "Uncontained"

	TheInternetID      = "theinternet"
	IncomingInternetID = "in-" + TheInternetID
	OutgoingInternetID = "out-" + TheInternetID
	InboundMajor       = "The Internet"
	OutboundMajor      = "The Internet"
	InboundMinor       = "Inbound connections"
	OutboundMinor      = "Outbound connections"

	// Topology for pseudo-nodes and IPs so we can differentiate them at the end
	Pseudo = "pseudo"
	IP     = "IP"
)

Constants are used in the tests.

View Source
const IsConnected = "is_connected"

IsConnected is the key added to Node.Metadata by ColorConnected to indicate a node has an edge pointing to it or from it

Variables

View Source
var (
	SelectEndpoint       = TopologySelector(report.Endpoint)
	SelectProcess        = TopologySelector(report.Process)
	SelectContainer      = TopologySelector(report.Container)
	SelectContainerImage = TopologySelector(report.ContainerImage)
	SelectHost           = TopologySelector(report.Host)
	SelectPod            = TopologySelector(report.Pod)
	SelectService        = TopologySelector(report.Service)
)

The topology selectors implement a Renderer which fetch the nodes from the various report topologies.

View Source
var ContainerHostnameRenderer = MakeMap(
	MapContainer2Hostname,
	ContainerRenderer,
)

ContainerHostnameRenderer is a Renderer which produces a renderable container by hostname graph..

View Source
var ContainerImageRenderer = MakeReduce(
	MakeMap(
		MapContainer2ContainerImage,
		ContainerRenderer,
	),
	SelectContainerImage,
)

ContainerImageRenderer is a Renderer which produces a renderable container image graph by merging the container graph and the container image topology.

View Source
var ContainerRenderer = MakeReduce(
	MakeSilentFilter(
		func(n report.Node) bool {

			_, isConnected := n.Latest.Lookup(IsConnected)
			return n.Topology != Pseudo || isConnected
		},
		MakeMap(
			MapProcess2Container,
			ColorConnected(ProcessRenderer),
		),
	),

	SilentFilterUnconnected(MakeMap(
		MapIP2Container,
		MakeReduce(
			MakeMap(
				MapContainer2IP,
				SelectContainer,
			),
			MakeMap(
				MapEndpoint2IP,
				SelectEndpoint,
			),
		),
	)),

	SelectContainer,
)

ContainerRenderer is a Renderer which produces a renderable container graph by merging the process graph and the container topology. NB We only want processes in container _or_ processes with network connections but we need to be careful to ensure we only include each edge once, by only including the ProcessRenderer once.

View Source
var ContainerWithHostIPsRenderer = containerWithHostIPsRenderer{ContainerRenderer}

ContainerWithHostIPsRenderer is a Renderer which produces a container graph enriched with host IPs on containers where NetworkMode is Host

View Source
var ContainerWithImageNameRenderer = containerWithImageNameRenderer{ContainerWithHostIPsRenderer}

ContainerWithImageNameRenderer is a Renderer which produces a container graph where the ranks are the image names, not their IDs

View Source
var EndpointRenderer = FilterNonProcspied(SelectEndpoint)

EndpointRenderer is a Renderer which produces a renderable endpoint graph.

HostRenderer is a Renderer which produces a renderable host graph from the host topology.

View Source
var PodRenderer = MakeReduce(
	MakeSilentFilter(
		func(n report.Node) bool {

			_, isConnected := n.Latest.Lookup(IsConnected)
			return n.Topology != Pseudo || isConnected
		},
		ColorConnected(MakeMap(
			MapContainer2Pod,
			ContainerRenderer,
		)),
	),
	SelectPod,
)

PodRenderer is a Renderer which produces a renderable kubernetes graph by merging the container graph and the pods topology.

View Source
var PodServiceRenderer = MakeReduce(
	MakeMap(
		MapPod2Service,
		PodRenderer,
	),
	SelectService,
)

PodServiceRenderer is a Renderer which produces a renderable kubernetes services graph by merging the pods graph and the services topology.

View Source
var ProcessNameRenderer = MakeMap(
	MapProcess2Name,
	ProcessRenderer,
)

ProcessNameRenderer is a Renderer which produces a renderable process name graph by munging the progess graph.

View Source
var ProcessRenderer = MakeReduce(
	MakeMap(
		MapEndpoint2Process,
		EndpointRenderer,
	),
	SelectProcess,
)

ProcessRenderer is a Renderer which produces a renderable process graph by merging the endpoint graph and the process topology.

View Source
var ProcessWithContainerNameRenderer = processWithContainerNameRenderer{ProcessRenderer}

ProcessWithContainerNameRenderer is a Renderer which produces a process graph enriched with container names where appropriate

Functions

func Complement added in v0.14.0

func Complement(f func(report.Node) bool) func(report.Node) bool

Complement takes a FilterFunc f and returns a FilterFunc that has the same effects, if any, and returns the opposite truth value.

func ImageNameWithoutVersion added in v0.12.0

func ImageNameWithoutVersion(name string) string

ImageNameWithoutVersion splits the image name apart, returning the name without the version, if possible

func IsRunning added in v0.14.0

func IsRunning(n report.Node) bool

IsRunning checks if the node is a running docker container

func IsSystem added in v0.14.0

func IsSystem(n report.Node) bool

IsSystem checks if the node is a "system" node

func LocalNetworks

func LocalNetworks(r report.Report) report.Networks

LocalNetworks returns a superset of the networks (think: CIDRs) that are "local" from the perspective of each host represented in the report. It's used to determine which nodes in the report are "remote", i.e. outside of our infrastructure.

func MakePseudoNodeID

func MakePseudoNodeID(parts ...string) string

MakePseudoNodeID joins the parts of an id into the id of a pseudonode

func MapContainer2ContainerImage

func MapContainer2ContainerImage(n report.Node, _ report.Networks) report.Nodes

MapContainer2ContainerImage maps container Nodes to container image Nodes.

If this function is given a node without a docker_image_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.

func MapContainer2Hostname

func MapContainer2Hostname(n report.Node, _ report.Networks) report.Nodes

MapContainer2Hostname maps container Nodes to 'hostname' renderabled nodes..

func MapContainer2IP

func MapContainer2IP(m report.Node, _ report.Networks) report.Nodes

MapContainer2IP maps container nodes to their IP addresses (outputs multiple nodes). This allows container to be joined directly with the endpoint topology.

func MapContainer2Pod

func MapContainer2Pod(n report.Node, _ report.Networks) report.Nodes

MapContainer2Pod maps container Nodes to pod Nodes.

If this function is given a node without a kubernetes_pod_id (including other pseudo nodes), it will produce an "Unmanaged" pseudo node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.

func MapEndpoint2Host added in v0.14.0

func MapEndpoint2Host(n report.Node, local report.Networks) report.Nodes

MapEndpoint2Host takes nodes from the endpoint topology and produces host nodes or pseudo nodes.

func MapEndpoint2IP

func MapEndpoint2IP(m report.Node, local report.Networks) report.Nodes

MapEndpoint2IP maps endpoint nodes to their IP address, for joining with container nodes. We drop endpoint nodes with pids, as they will be joined to containers through the process topology, and we don't want to double count edges.

func MapEndpoint2Process

func MapEndpoint2Process(n report.Node, local report.Networks) report.Nodes

MapEndpoint2Process maps endpoint Nodes to process Nodes.

If this function is given a pseudo node, then it will just return it; Pseudo nodes will never have pids in them, and therefore will never be able to be turned into a Process node.

Otherwise, this function will produce a node with the correct ID format for a process, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a process graph to get that info.

func MapEndpoint2Pseudo added in v0.14.0

func MapEndpoint2Pseudo(n report.Node, local report.Networks) report.Nodes

MapEndpoint2Pseudo makes internet of host pesudo nodes from a endpoint node.

func MapIP2Container

func MapIP2Container(n report.Node, _ report.Networks) report.Nodes

MapIP2Container maps IP nodes produced from MapContainer2IP back to container nodes. If there is more than one container with a given IP, it is dropped.

func MapPod2Service

func MapPod2Service(pod report.Node, _ report.Networks) report.Nodes

MapPod2Service maps pod Nodes to service Nodes.

If this function is given a node without a kubernetes_pod_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a pod graph to get that info.

func MapProcess2Container

func MapProcess2Container(n report.Node, _ report.Networks) report.Nodes

MapProcess2Container maps process Nodes to container Nodes.

If this function is given a node without a docker_container_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.

func MapProcess2Name

func MapProcess2Name(n report.Node, _ report.Networks) report.Nodes

MapProcess2Name maps process Nodes to Nodes for each process name.

This mapper is unlike the other foo2bar mappers as the intention is not to join the information with another topology.

func MapX2Host added in v0.12.0

func MapX2Host(n report.Node, _ report.Networks) report.Nodes

MapX2Host maps any Nodes to host Nodes.

If this function is given a node without a hostname (including other pseudo nodes), it will drop the node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.

func NewDerivedNode

func NewDerivedNode(id string, node report.Node) report.Node

NewDerivedNode makes a node based on node, but with a new ID

func NewDerivedPseudoNode added in v0.14.0

func NewDerivedPseudoNode(id string, node report.Node) report.Node

NewDerivedPseudoNode makes a new pseudo node with the node as a child

func ResetCache added in v0.12.0

func ResetCache()

ResetCache blows away the rendered node cache.

Types

type CustomRenderer

type CustomRenderer struct {
	RenderFunc func(report.Nodes) report.Nodes
	Renderer
}

CustomRenderer allow for mapping functions that received the entire topology in one call - useful for functions that need to consider the entire graph. We should minimise the use of this renderer type, as it is very inflexible.

func (CustomRenderer) Render

func (c CustomRenderer) Render(rpt report.Report) report.Nodes

Render implements Renderer

type Filter

type Filter struct {
	Renderer
	FilterFunc func(report.Node) bool
	Silent     bool // true means we don't report stats for how many are filtered
}

Filter removes nodes from a view based on a predicate.

func (*Filter) Render

func (f *Filter) Render(rpt report.Report) report.Nodes

Render implements Renderer

func (Filter) Stats

func (f Filter) Stats(rpt report.Report) Stats

Stats implements Renderer

type Map

type Map struct {
	MapFunc
	Renderer
}

Map is a Renderer which produces a set of Nodes from the set of Nodes produced by another Renderer.

func (*Map) Render

func (m *Map) Render(rpt report.Report) report.Nodes

Render transforms a set of Nodes produces by another Renderer. using a map function

func (*Map) Stats

func (m *Map) Stats(rpt report.Report) Stats

Stats implements Renderer

type MapFunc

type MapFunc func(report.Node, report.Networks) report.Nodes

MapFunc is anything which can take an arbitrary Node and return a set of other Nodes.

If the output is empty, the node shall be omitted from the rendered topology.

type Reduce

type Reduce []Renderer

Reduce renderer is a Renderer which merges together the output of several other renderers.

func (*Reduce) Render

func (r *Reduce) Render(rpt report.Report) report.Nodes

Render produces a set of Nodes given a Report.

func (*Reduce) Stats

func (r *Reduce) Stats(rpt report.Report) Stats

Stats implements Renderer

type Renderer

type Renderer interface {
	Render(report.Report) report.Nodes
	Stats(report.Report) Stats
}

Renderer is something that can render a report to a set of Nodes.

func ColorConnected

func ColorConnected(r Renderer) Renderer

ColorConnected colors nodes with the IsConnected key if they have edges to or from them. Edges to/from yourself are not counted here (see #656).

func FilterApplication added in v0.14.0

func FilterApplication(r Renderer) Renderer

FilterApplication is a Renderer which filters out system nodes.

func FilterNonProcspied added in v0.14.0

func FilterNonProcspied(r Renderer) Renderer

FilterNonProcspied removes endpoints which were not found in procspy.

func FilterNoop added in v0.10.0

func FilterNoop(in Renderer) Renderer

FilterNoop does nothing.

func FilterPseudo added in v0.12.0

func FilterPseudo(r Renderer) Renderer

FilterPseudo produces a renderer that removes pseudo nodes from the given renderer

func FilterRunning added in v0.14.0

func FilterRunning(r Renderer) Renderer

FilterRunning filters out running containers.

func FilterStopped added in v0.10.0

func FilterStopped(r Renderer) Renderer

FilterStopped filters out stopped containers.

func FilterSystem

func FilterSystem(r Renderer) Renderer

FilterSystem is a Renderer which filters out system nodes.

func FilterUnconnected

func FilterUnconnected(r Renderer) Renderer

FilterUnconnected produces a renderer that filters unconnected nodes from the given renderer

func MakeFilter added in v0.12.0

func MakeFilter(f func(report.Node) bool, r Renderer) Renderer

MakeFilter makes a new Filter.

func MakeMap added in v0.12.0

func MakeMap(f MapFunc, r Renderer) Renderer

MakeMap makes a new Map

func MakeReduce

func MakeReduce(renderers ...Renderer) Renderer

MakeReduce is the only sane way to produce a Reduce Renderer.

func MakeSilentFilter added in v0.14.0

func MakeSilentFilter(f func(report.Node) bool, r Renderer) Renderer

MakeSilentFilter makes a new Filter which does not report how many nodes it filters in Stats.

func Memoise added in v0.12.0

func Memoise(r Renderer) Renderer

Memoise wraps the renderer in a loving embrace of caching

func SilentFilterUnconnected added in v0.14.0

func SilentFilterUnconnected(r Renderer) Renderer

SilentFilterUnconnected produces a renderer that filters unconnected nodes from the given renderer; nodes filtered by this are not reported in stats.

type Stats

type Stats struct {
	FilteredNodes int
}

Stats is the type returned by Renderer.Stats

type TopologySelector

type TopologySelector string

TopologySelector selects a single topology from a report. NB it is also a Renderer!

func (TopologySelector) Render

Render implements Renderer

func (TopologySelector) Stats

func (t TopologySelector) Stats(r report.Report) Stats

Stats implements Renderer

Source Files

  • filters.go
  • id.go
  • mapping.go
  • memoise.go
  • render.go
  • selectors.go
  • theinternet.go
  • topologies.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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