backenddisruption

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const OpenshiftTestsSource = "openshift-tests"

Variables

View Source
var DnsLookupRegex = regexp.MustCompile(`dial tcp: lookup.*: i/o timeout`)

DnsLookupRegex is a specific error we often see when sampling for disruption, which indicates a DNS problem in the cluster running openshift-tests, not real disruption in the cluster under test. Used to downgrade to a warning instead of an error, and omitted from final disruption numbers and testing.

Functions

func DisruptionBegan

DisruptionBegan examines the error received, attempts to determine if it looks like real disruption to the cluster under test, or other problems possibly on the system running the tests/monitor, and returns an appropriate user message, event reason, and monitoring level.

func DisruptionEndedMessage

func DisruptionEndedMessage(locator string, connectionType monitorapi.BackendConnectionType) *monitorapi.MessageBuilder

Types

type BackendSampler

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

BackendSampler is used to monitor an HTTP endpoint and ensure that it is always accessible. It records results into the monitorRecorder that is passed to the StartEndpointMonitoring call.

func NewAPIServerBackend

func NewAPIServerBackend(clientConfig *rest.Config, disruptionBackendName, path string, connectionType monitorapi.BackendConnectionType) (*BackendSampler, error)

NewAPIServerBackend constructs a BackendSampler suitable for use against a kube-like API server

func NewRouteBackend

func NewRouteBackend(clientConfig *rest.Config, namespace, name, disruptionBackendName, path string, connectionType monitorapi.BackendConnectionType) *BackendSampler

NewRouteBackend constructs a BackendSampler suitable for use against a routes.route.openshift.io

func NewSimpleBackendFromOpenshiftTests

func NewSimpleBackendFromOpenshiftTests(host, disruptionBackendName, path string, connectionType monitorapi.BackendConnectionType) *BackendSampler

NewSimpleBackendFromOpenshiftTests constructs a BackendSampler suitable for use against a generic server

func NewSimpleBackendWithLocator

func NewSimpleBackendWithLocator(locator monitorapi.Locator, host, path string, connectionType monitorapi.BackendConnectionType) *BackendSampler

NewRouteBackend constructs a BackendSampler suitable for use against a routes.route.openshift.io

func (*BackendSampler) CheckConnection

func (b *BackendSampler) CheckConnection(ctx context.Context) (string, error)

CheckConnnection returns the audit request UID and an error if there was one.

func (*BackendSampler) GetConnectionType

func (b *BackendSampler) GetConnectionType() monitorapi.BackendConnectionType

func (*BackendSampler) GetDisruptionBackendName

func (b *BackendSampler) GetDisruptionBackendName() string

func (*BackendSampler) GetHTTPClient

func (b *BackendSampler) GetHTTPClient() (*http.Client, error)

func (*BackendSampler) GetLocator

func (b *BackendSampler) GetLocator() monitorapi.Locator

func (*BackendSampler) GetURL

func (b *BackendSampler) GetURL() (string, error)

func (*BackendSampler) RunEndpointMonitoring

func (b *BackendSampler) RunEndpointMonitoring(ctx context.Context, monitorRecorder monitorapi.RecorderWriter, eventRecorder events.EventRecorder) error

RunEndpointMonitoring sets up a client for the given BackendSampler, starts checking the endpoint, and recording success/failure edges into the monitorRecorder, and blocks until the context is closed or the sampler is closed.

func (*BackendSampler) StartEndpointMonitoring

func (b *BackendSampler) StartEndpointMonitoring(ctx context.Context, monitorRecorder monitorapi.RecorderWriter, eventRecorder events.EventRecorder) error

StartEndpointMonitoring sets up a client for the given BackendSampler, starts checking the endpoint, and recording success/failure edges into the monitorRecorder

func (*BackendSampler) Stop

func (b *BackendSampler) Stop()

Stop stops the produce and consumer and blocks until the consumer is finished consuming.

func (*BackendSampler) WithBearerTokenAuth

func (b *BackendSampler) WithBearerTokenAuth(token, tokenFile string) *BackendSampler

WithBearerTokenAuth sets bearer tokens to use

func (*BackendSampler) WithExpectedBody

func (b *BackendSampler) WithExpectedBody(expectedBody string) *BackendSampler

WithExpectedBody allows a specification of specific body to be returned. This useful when passing through proxies and the like since a connection may not be the one you expect. If not specified, then the default behavior is that any 2xx or 3xx response is acceptable.

func (*BackendSampler) WithExpectedBodyRegex

func (b *BackendSampler) WithExpectedBodyRegex(expectedBodyRegex string) *BackendSampler

WithExpectedBodyRegex allows a specification of specific body to be returned. This useful when passing through proxies and the like since a connection may not be the one you expect. If not specified, then the default behavior is that any 2xx or 3xx response is acceptable.

func (*BackendSampler) WithExpectedStatusCode

func (b *BackendSampler) WithExpectedStatusCode(statusCode int) *BackendSampler

WithExpectedStatusCode sets the expected http status

func (*BackendSampler) WithSamplerHooks

func (b *BackendSampler) WithSamplerHooks(samplerHooks []SamplerHook) *BackendSampler

WithSamplerHooks adds a list of hooks for the sampler to call at different stages of disruption detection

func (*BackendSampler) WithTLSConfig

func (b *BackendSampler) WithTLSConfig(tlsConfig *tls.Config) *BackendSampler

WithTLSConfig sets both the CA bundle for trusting the server and the client cert/key pair for identifying to the server

func (*BackendSampler) WithUserAgent

func (b *BackendSampler) WithUserAgent(userAgent string) *BackendSampler

WithUserAgent sets the User-Agent HTTP Header for all requests that are sent by this sampler

type HostGetter

type HostGetter interface {
	GetHost() (string, error)
}

func NewKubeAPIHostGetter

func NewKubeAPIHostGetter(clientConfig *rest.Config) HostGetter

func NewRouteHostGetter

func NewRouteHostGetter(clientConfig *rest.Config, routeNamespace string, routeName string) HostGetter

type SamplerHook

type SamplerHook interface {
	DisruptionStarted(ctx context.Context)
}

SamplerHook defines some hook functions for the sampler to call. This will give caller an opportunity to perform some tasks during different stages of disruption detection. DisruptionStarted is called whenever a new disruption is detected by this sampler. Other functions can be added as we need.

type SimpleHostGetter

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

func NewSimpleHostGetter

func NewSimpleHostGetter(host string) *SimpleHostGetter

func (*SimpleHostGetter) GetHost

func (g *SimpleHostGetter) GetHost() (string, error)

func (*SimpleHostGetter) SetHost

func (g *SimpleHostGetter) SetHost(host string)

type TcpdumpSamplerHook

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

func NewTcpdumpSamplerHook

func NewTcpdumpSamplerHook() *TcpdumpSamplerHook

func (*TcpdumpSamplerHook) DisruptionStarted

func (h *TcpdumpSamplerHook) DisruptionStarted(ctx context.Context)

func (*TcpdumpSamplerHook) MoveToStorage

func (h *TcpdumpSamplerHook) MoveToStorage(storageDir string) error

MoveToStorage moves all captured pcap files and log files to the specified storage directory under a "tcpdump" subfolder. This function is idempotent and thread-safe - it can be called multiple times safely. This should be called by monitor tests in their WriteContentToStorage function to archive the network capture data.

func (*TcpdumpSamplerHook) StopCollection

func (h *TcpdumpSamplerHook) StopCollection()

StopCollection stops any running tcpdump process. This should be called by monitor tests in their CollectData function to ensure proper cleanup when the test is terminating.

Jump to

Keyboard shortcuts

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