aggregation

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Overview

Package aggregation is responsible for hosting an HTTP server which aggregates results from all of the nodes that are running sonobuoy agent. It is not responsible for dispatching the nodes (see pkg/dispatch), only expecting their results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup(client kubernetes.Interface, plugins []plugin.Interface)

func Run

func Run(client kubernetes.Interface, plugins []plugin.Interface, cfg plugin.AggregationConfig, outdir string) error

Run runs an aggregation server and gathers results, in accordance with the given sonobuoy configuration.

Basic workflow:

  1. Create the aggregator object (`aggr`) to keep track of results
  2. Launch the HTTP server with the aggr's HandleHTTPResult function as the callback
  3. Run all the aggregation plugins, monitoring each one in a goroutine, configuring them to send failure results through a shared channel
  4. Hook the shared monitoring channel up to aggr's IngestResults() function
  5. Block until aggr shows all results accounted for (results come in through the HTTP callback), stopping the HTTP server on completion

Types

type Aggregator

type Aggregator struct {
	// OutputDir is the directory to write the node results
	OutputDir string
	// Results stores a map of check-in results the server has seen
	Results map[string]*plugin.Result
	// ExpectedResults stores a map of results the server should expect
	ExpectedResults map[string]*plugin.ExpectedResult
	// contains filtered or unexported fields
}

Aggregator is responsible for taking results from an HTTP server (configured elsewhere), saving them to the filesystem, and keeping track of what has been seen so far, so that we can return when all expected results are present and accounted for.

func NewAggregator

func NewAggregator(outputDir string, expected []plugin.ExpectedResult) *Aggregator

NewAggregator constructs a new Aggregator object to write the given result set out to the given output directory.

func (*Aggregator) HandleHTTPResult

func (a *Aggregator) HandleHTTPResult(result *plugin.Result, w http.ResponseWriter)

HandleHTTPResult is called every time the HTTP server gets a well-formed request with results. This method is responsible for returning with things like a 409 conflict if a node has checked in twice (or a 403 forbidden if a node isn't expected), as well as actually calling handleResult to write the results to OutputDir.

func (*Aggregator) IngestResults

func (a *Aggregator) IngestResults(resultsCh <-chan *plugin.Result)

IngestResults takes a channel of results and handles them as they come in. Since most plugins submit over HTTP, this method is currently only used to consume an error stream from each plugin's Monitor() function.

If we support plugins that are just simple commands that the sonobuoy master runs, those plugins can submit results through the same channel.

func (*Aggregator) Wait

func (a *Aggregator) Wait(stop chan bool)

Wait blocks until all expected results have come in.

type Server

type Server struct {
	// BindAddr is the address for the HTTP server to listen on, eg. 0.0.0.0:8080
	BindAddr string
	// ResultsCallback is the function that is called when a result is checked in.
	ResultsCallback func(*plugin.Result, http.ResponseWriter)
	// contains filtered or unexported fields
}

Server is a net/http server that can handle API requests for aggregation of results from nodes, sending them back over the Results channel

func NewServer

func NewServer(bindAddr string, resultsCallback func(*plugin.Result, http.ResponseWriter)) *Server

NewServer constructs a new aggregation server which will listen for results on `bindAddr` and pass them to the given results callback.

func (*Server) Start

func (s *Server) Start() error

Start starts this HTTP server, binding it to s.BindAddr and sending results over the s.Results channel. The first argument is the stop channel, which when written to will stop the server and close the HTTP socket. The second argument is the "ready" channel, which this function will write to once the HTTP server is ready for connections.

func (*Server) Stop

func (s *Server) Stop()

Stop stops a running Server

func (*Server) WaitUntilReady

func (s *Server) WaitUntilReady()

WaitUntilReady blocks until the server is listening on its configured address. This must only be called once for each time Start() is called, or it will block indefinitely.

Jump to

Keyboard shortcuts

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