monitorapi

package
v0.0.0-...-0f64c49 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PodIPReused means the same pod IP is in use by two pods at the same time.
	PodIPReused = "ReusedPodIP"

	ContainerErrImagePull                = "ErrImagePull"
	ContainerUnrecognizedSignatureFormat = "UnrecognizedSignatureFormat"
)
View Source
const (
	// ObservedUpdateCountAnnotation is an annotation added locally (in the monitor only), that tracks how many updates
	// we've seen to this resource.  This is useful during post-processing for determining if we have a hot resource.
	ObservedUpdateCountAnnotation = "monitor.openshift.io/observed-update-count"

	// ObservedRecreationCountAnnotation is an annotation added locally (in the monitor only), that tracks how many
	// time a resource has been recreated.  The internal cache doesn't remove an entry on delete.
	// This is useful during post-processing for determining if we have a hot resource.
	ObservedRecreationCountAnnotation = "monitor.openshift.io/observed-recreation-count"
)
View Source
const (
	ConstructionOwnerNodeLifecycle    = "node-lifecycle-constructor"
	ConstructionOwnerPodLifecycle     = "pod-lifecycle-constructor"
	ConstructionOwnerEtcdLifecycle    = "etcd-lifecycle-constructor"
	ConstructionOwnerMachineLifecycle = "machine-lifecycle-constructor"
	ConstructionOwnerLeaseChecker     = "lease-checker"
	ConstructionOwnerOnPremHaproxy    = "on-prem-haproxy-constructor"
	ConstructionOwnerOnPremKeepalived = "on-prem-keepalived-constructor"
)
View Source
const (
	SourceAlert                     IntervalSource = "Alert"
	SourceAPIServerShutdown         IntervalSource = "APIServerShutdown"
	SourceDisruption                IntervalSource = "Disruption"
	SourceE2ETest                   IntervalSource = "E2ETest"
	SourceKubeEvent                 IntervalSource = "KubeEvent"
	SourceNetworkManagerLog         IntervalSource = "NetworkMangerLog"
	SourceNodeMonitor               IntervalSource = "NodeMonitor"
	SourceHaproxyMonitor            IntervalSource = "OnPremHaproxyMonitor"
	SourceKeepalivedMonitor         IntervalSource = "OnPremKeepalivedMonitor"
	SourceUnexpectedReady           IntervalSource = "NodeUnexpectedNotReady"
	SourceUnreachable               IntervalSource = "NodeUnreachable"
	SourceKubeletLog                IntervalSource = "KubeletLog"
	SourceCrioLog                   IntervalSource = "CrioLog"
	SourceSystemdCoreDumpLog        IntervalSource = "SystemdCoreDumpLog"
	SourcePodLog                    IntervalSource = "PodLog"
	SourceEtcdLog                   IntervalSource = "EtcdLog"
	SourceEtcdLeadership            IntervalSource = "EtcdLeadership"
	SourcePodMonitor                IntervalSource = "PodMonitor"
	SourceMetricsEndpointDown       IntervalSource = "MetricsEndpointDown"
	APIServerGracefulShutdown       IntervalSource = "APIServerGracefulShutdown"
	APIServerClusterOperatorWatcher IntervalSource = "APIServerClusterOperatorWatcher"
	SourceAuditLog                  IntervalSource = "AuditLog"

	SourceTestData                IntervalSource = "TestData" // some tests have no real source to assign
	SourceOVSVswitchdLog          IntervalSource = "OVSVswitchdLog"
	SourcePathologicalEventMarker IntervalSource = "PathologicalEventMarker" // not sure if this is really helpful since the events all have a different origin
	SourceClusterOperatorMonitor  IntervalSource = "ClusterOperatorMonitor"
	SourceOperatorState           IntervalSource = "OperatorState"
	SourceVersionState            IntervalSource = "VersionState"
	SourceNodeState                              = "NodeState"
	SourcePodState                               = "PodState"
	SourceCloudMetrics                           = "CloudMetrics"

	SourceAPIUnreachableFromClient IntervalSource = "APIUnreachableFromClient"
	SourceMachine                  IntervalSource = "MachineMonitor"

	SourceGenerationMonitor IntervalSource = "GenerationMonitor"

	SourceStaticPodInstallMonitor  IntervalSource = "StaticPodInstallMonitor"
	SourceCPUMonitor               IntervalSource = "CPUMonitor"
	SourceEtcdDiskCommitDuration   IntervalSource = "EtcdDiskCommitDuration"
	SourceEtcdDiskWalFsyncDuration IntervalSource = "EtcdDiskWalFsyncDuration"
	SourceTestBucket               IntervalSource = "TestBucket"
	KubeletPanic                   IntervalReason = "KubeletPanic"
	CrioPanic                      IntervalReason = "CrioPanic"
)
View Source
const EventDir = "monitor-events"
View Source
const TimeFormat = "Jan 02 15:04:05"

Variables

View Source
var (
	// PodLifecycleTransitionReasons are the reasons associated with non-overlapping pod lifecycle states.
	// A pod is logically identified by UID (I bet it's a name right now).
	// Pods don't exist before create and don't exist after delete.
	// Between those two states, each of these reasons can be ordered by time and used to create a contiguous view
	// into the lifecycle of a pod.
	PodLifecycleTransitionReasons = sets.New[IntervalReason](
		PodReasonCreated,
		PodReasonScheduled,
		PodReasonGracefulDeleteStarted,
		PodReasonDeleted,
	)

	// ContainerLifecycleTransitionReasons are the reasons associated with non-overlapping container lifecycle states.
	// The logical beginning and end are based on ContainerWait and ContainerExit.
	// A container is logically identified by a Pod plus a container name.
	ContainerLifecycleTransitionReasons = sets.New[IntervalReason](
		ContainerReasonContainerWait,
		ContainerReasonContainerStart,
		ContainerReasonContainerExit,
	)

	// ContainerReadinessTransitionReasons are the reasons associated with non-overlapping container readiness states.
	// A container is logically identified by a Pod plus a container name.
	// The logical beginning and end are based on ContainerStart and ContainerExit, with initial state of ready=false and final state of ready=false.
	// Each of these reasons can be ordered by time and used to create a contiguous view into the lifecycle of a pod.
	ContainerReadinessTransitionReasons = sets.New[IntervalReason](
		ContainerReasonReady,
		ContainerReasonNotReady,
	)

	KubeletReadinessCheckReasons = sets.New[IntervalReason](
		ContainerReasonReadinessFailed,
		ContainerReasonReadinessErrored,
		ContainerReasonStartupProbeFailed,
	)
)

Functions

func AlertFrom

func AlertFrom(locatorParts map[string]string) string

func AnnotationsFromMessage

func AnnotationsFromMessage(message string) map[AnnotationKey]string

func BackendDisruptionNameFromLocator

func BackendDisruptionNameFromLocator(locator Locator) string

func BackendDisruptionSeconds

func BackendDisruptionSeconds(backendDisruptionName string, events Intervals) (time.Duration, []string)

BackendDisruptionSeconds return duration of disruption observed (rounded to nearest second), disruptionMessages, and New or Reused connection type.

func E2ETestFromLocator

func E2ETestFromLocator(l Locator) (string, bool)

func GetNodeRoles

func GetNodeRoles(event Interval) string

GetNodeRoles extract the node roles from the event message.

func GetOperatorConditionHumanMessage

func GetOperatorConditionHumanMessage(s *configv1.ClusterOperatorStatusCondition, prefix string) string

GetOperatorConditionHumanMessage constructs a human-readable message from a given ClusterOperatorStatusCondition with a given prefix

func GetOperatorConditionStatus

func GetOperatorConditionStatus(interval Interval) *configv1.ClusterOperatorStatusCondition

GetOperatorConditionStatus reconstructs a ClusterOperatorStatusCondition from an interval.

func HasRealLoadBalancer

func HasRealLoadBalancer(eventInterval Interval) bool

func IsDisruptionEvent

func IsDisruptionEvent(eventInterval Interval) bool

func IsE2ETest

func IsE2ETest(l Locator) bool

func IsErrorEvent

func IsErrorEvent(eventInterval Interval) bool

IsErrorEvent returns true if the eventInterval is an Error

func IsInE2ENamespace

func IsInE2ENamespace(eventInterval Interval) bool

IsInE2ENamespace returns true if the eventInterval is in an e2e namespace

func IsInfoEvent

func IsInfoEvent(eventInterval Interval) bool

IsInfoEvent returns true if the eventInterval is an Info

func IsNode

func IsNode(locator Locator) bool

func IsWarningEvent

func IsWarningEvent(eventInterval Interval) bool

IsWarningEvent returns true if the eventInterval is an Warning

func LocatorParts

func LocatorParts(locator string) map[string]string

TODO: remove all uses

func NamespaceFrom

func NamespaceFrom(locatorParts map[string]string) string

func NamespaceFromLocator

func NamespaceFromLocator(locator Locator) string

func NodeFrom

func NodeFrom(locatorParts map[string]string) string

func NodeFromLocator

func NodeFromLocator(locator string) (string, bool)

func NodeLeaseBackoff

func NodeLeaseBackoff(eventInterval Interval) bool

func NodeUpdate

func NodeUpdate(eventInterval Interval) bool

func NonAnnotationMessage

func NonAnnotationMessage(message string) string

func NonUniquePodLocatorFrom

func NonUniquePodLocatorFrom(locator Locator) string

NonUniquePodLocatorFrom produces an inexact locator based on namespace and name. This is useful when dealing with events that are produced that do not contain UIDs. Ultimately, we should use UIDs everywhere, but this is will keep some our matching working until then.

func OperatorFrom

func OperatorFrom(locatorParts map[string]string) string

func PhaseFrom

func PhaseFrom(message string) string

func ThisDisruptionInstanceFrom

func ThisDisruptionInstanceFrom(locatorParts map[string]string) string

Types

type AnnotationKey

type AnnotationKey string
const (
	AnnotationAlertState         AnnotationKey = "alertstate"
	AnnotationState              AnnotationKey = "state"
	AnnotationSeverity           AnnotationKey = "severity"
	AnnotationReason             AnnotationKey = "reason"
	AnnotationContainerExitCode  AnnotationKey = "code"
	AnnotationCause              AnnotationKey = "cause"
	AnnotationConfig             AnnotationKey = "config"
	AnnotationContainer          AnnotationKey = "container"
	AnnotationImage              AnnotationKey = "image"
	AnnotationInteresting        AnnotationKey = "interesting"
	AnnotationCount              AnnotationKey = "count"
	AnnotationNode               AnnotationKey = "node"
	AnnotationEtcdLocalMember    AnnotationKey = "local-member-id"
	AnnotationEtcdTerm           AnnotationKey = "term"
	AnnotationEtcdLeader         AnnotationKey = "leader"
	AnnotationPreviousEtcdLeader AnnotationKey = "prev-leader"
	AnnotationPathological       AnnotationKey = "pathological"
	AnnotationConstructed        AnnotationKey = "constructed"
	AnnotationPhase              AnnotationKey = "phase"
	AnnotationPreviousPhase      AnnotationKey = "previousPhase"
	AnnotationIsStaticPod        AnnotationKey = "mirrored"
	// TODO this looks wrong. seems like it ought to be set in the to/from
	AnnotationDuration         AnnotationKey = "duration"
	AnnotationRequestAuditID   AnnotationKey = "request-audit-id"
	AnnotationRoles            AnnotationKey = "roles"
	AnnotationStatus           AnnotationKey = "status"
	AnnotationCondition        AnnotationKey = "condition"
	AnnotationPercentage       AnnotationKey = "percentage"
	AnnotationPriority         AnnotationKey = "priority"
	AnnotationPreviousPriority AnnotationKey = "prev-priority"
	AnnotationVIP              AnnotationKey = "vip"
)

type BackendConnectionType

type BackendConnectionType string
const (
	NewConnectionType    BackendConnectionType = "new"
	ReusedConnectionType BackendConnectionType = "reused"
)

func DisruptionConnectionTypeFrom

func DisruptionConnectionTypeFrom(locatorParts map[string]string) BackendConnectionType

type ByTimeWithNamespacedPods

type ByTimeWithNamespacedPods []Interval

func (ByTimeWithNamespacedPods) Len

func (intervals ByTimeWithNamespacedPods) Len() int

func (ByTimeWithNamespacedPods) Less

func (intervals ByTimeWithNamespacedPods) Less(i, j int) bool

func (ByTimeWithNamespacedPods) Swap

func (intervals ByTimeWithNamespacedPods) Swap(i, j int)

type Condition

type Condition struct {
	Level IntervalLevel

	Locator Locator
	Message Message
}

func (*Condition) DeepCopy

func (o *Condition) DeepCopy() *Condition

type ConstructionOwner

type ConstructionOwner string

ConstructionOwner was originally meant to signify that an interval was derived from other intervals. This allowed for the possibility of testing interval generation by feeding in only source intervals, and checking what was generated. TODO: likely want to drop this concept in favor of Source, plus a flag automatically applied to any intervals coming back from the monitor test call to generate calculated intervals. Source will replace the use of what constructed the interval, and the flag will allow us to see what is derived and what isn't.

type ContainerReference

type ContainerReference struct {
	Pod           PodReference
	ContainerName string
}

func ContainerFrom

func ContainerFrom(locator Locator) ContainerReference

func (ContainerReference) ToLocator

func (r ContainerReference) ToLocator() Locator

type EventIntervalMatchesFunc

type EventIntervalMatchesFunc func(eventInterval Interval) bool

EventIntervalMatchesFunc is a function for matching eventIntervales

func AlertFiring

func AlertFiring() EventIntervalMatchesFunc

func AlertPending

func AlertPending() EventIntervalMatchesFunc

func ContainsAllParts

func ContainsAllParts(matchers map[string][]*regexp.Regexp) EventIntervalMatchesFunc

ContainsAllParts ensures that all listed key match at least one of the values.

func EndedAfter

func EndedAfter(limit time.Time) EventIntervalMatchesFunc

func IsEventForBackendDisruptionName

func IsEventForBackendDisruptionName(backendDisruptionName string) EventIntervalMatchesFunc

func IsEventForLocator

func IsEventForLocator(locator Locator) EventIntervalMatchesFunc

func IsForDisruptionBackend

func IsForDisruptionBackend(backend string) EventIntervalMatchesFunc

func IsInNamespaces

func IsInNamespaces(namespaces sets.String) EventIntervalMatchesFunc

func NotContainsAllParts

func NotContainsAllParts(matchers map[string][]*regexp.Regexp) EventIntervalMatchesFunc

NotContainsAllParts returns a function that returns false if any key matches.

func StartedBefore

func StartedBefore(limit time.Time) EventIntervalMatchesFunc

type InstanceKey

type InstanceKey struct {
	Namespace string
	Name      string
	UID       string
}

type InstanceMap

type InstanceMap map[InstanceKey]runtime.Object

type Interval

type Interval struct {
	// Deprecated: We hope to fold this into Interval itself.
	Condition
	Source IntervalSource

	// Display is a very coarse hint to any UI that this event was considered important enough to *possibly* be displayed by the source that produced it.
	// UI may apply further filtering.
	Display bool

	From time.Time
	To   time.Time
}

func (*Interval) DeepCopy

func (o *Interval) DeepCopy() *Interval

func (Interval) String

func (i Interval) String() string

type IntervalBuilder

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

func NewInterval

func NewInterval(source IntervalSource, level IntervalLevel) *IntervalBuilder

NewInterval creates a new interval builder. Source is an indicator of what created this interval, used for safely identifying intervals we're looking for, and for grouping in charts.

func (*IntervalBuilder) Build

func (b *IntervalBuilder) Build(from, to time.Time) Interval

Build creates the final interval with a mandatory from/to timestamp. Zero value times are allowed to indicate cases when the from or to is not known. This situation happens when the monitor doesn't observe a state change: imagine intervals for tracking graceful shutdown. If the monitor is stopped before the shutdown completes, it is incorrect to indicate a To time of "now". It is accurate to indicate "open" by using a zero value time.

func (*IntervalBuilder) BuildCondition deprecated

func (b *IntervalBuilder) BuildCondition() Condition

Deprecated: Use Build for a full Interval, we hope to remove Condition entirely and bubble it up into Interval directly.

func (*IntervalBuilder) BuildNow

func (b *IntervalBuilder) BuildNow() Interval

BuildNow creates the final interval with a from/to timestamp of now.

func (*IntervalBuilder) Display

func (b *IntervalBuilder) Display() *IntervalBuilder

Display is a coarse grained hint that any UI should display this interval to a user.

func (*IntervalBuilder) Locator

func (b *IntervalBuilder) Locator(locator Locator) *IntervalBuilder

func (*IntervalBuilder) Message

type IntervalFilter

type IntervalFilter func(i Interval) bool

type IntervalFilters

type IntervalFilters []IntervalFilter

func (IntervalFilters) All

func (filters IntervalFilters) All(i Interval) bool

func (IntervalFilters) Any

func (filters IntervalFilters) Any(i Interval) bool

type IntervalLevel

type IntervalLevel int
const (
	Info IntervalLevel = iota
	Warning
	Error
)

func ConditionLevelFromString

func ConditionLevelFromString(s string) (IntervalLevel, error)

func (IntervalLevel) String

func (e IntervalLevel) String() string

type IntervalReason

type IntervalReason string
const (
	IPTablesNotPermitted IntervalReason = "iptables-operation-not-permitted"

	DisruptionBeganEventReason              IntervalReason = "DisruptionBegan"
	DisruptionEndedEventReason              IntervalReason = "DisruptionEnded"
	DisruptionSamplerOutageBeganEventReason IntervalReason = "DisruptionSamplerOutageBegan"
	GracefulAPIServerShutdown               IntervalReason = "GracefulAPIServerShutdown"
	IncompleteAPIServerShutdown             IntervalReason = "IncompleteAPIServerShutdown"

	HttpClientConnectionLost IntervalReason = "HttpClientConnectionLost"

	PodPendingReason               IntervalReason = "PodIsPending"
	PodNotPendingReason            IntervalReason = "PodIsNotPending"
	PodReasonCreated               IntervalReason = "Created"
	PodReasonGracefulDeleteStarted IntervalReason = "GracefulDelete"
	PodReasonForceDelete           IntervalReason = "ForceDelete"
	PodReasonDeleted               IntervalReason = "Deleted"
	PodReasonScheduled             IntervalReason = "Scheduled"
	PodReasonEvicted               IntervalReason = "Evicted"
	PodReasonPreempted             IntervalReason = "Preempted"
	PodReasonFailed                IntervalReason = "Failed"
	PodReasonReady                 IntervalReason = "PodReady"
	PodReasonNotReady              IntervalReason = "PodNotReady"

	ContainerReasonContainerExit      IntervalReason = "ContainerExit"
	ContainerReasonContainerStart     IntervalReason = "ContainerStart"
	ContainerReasonContainerWait      IntervalReason = "ContainerWait"
	ContainerReasonReadinessFailed    IntervalReason = "ReadinessFailed"
	ContainerReasonReadinessErrored   IntervalReason = "ReadinessErrored"
	ContainerReasonStartupProbeFailed IntervalReason = "StartupProbeFailed"
	ContainerReasonReady              IntervalReason = "Ready"
	ContainerReasonRestarted          IntervalReason = "Restarted"
	ContainerReasonNotReady           IntervalReason = "NotReady"
	TerminationStateCleared           IntervalReason = "TerminationStateCleared"

	PodReasonDeletedBeforeScheduling IntervalReason = "DeletedBeforeScheduling"
	PodReasonDeletedAfterCompletion  IntervalReason = "DeletedAfterCompletion"

	NodeUpdateReason                IntervalReason = "NodeUpdate"
	NodeNotReadyReason              IntervalReason = "NotReady"
	NodeFailedLease                 IntervalReason = "FailedToUpdateLease"
	NodeUnexpectedReadyReason       IntervalReason = "UnexpectedNotReady"
	NodeUnexpectedUnreachableReason IntervalReason = "UnexpectedUnreachable"
	NodeUnreachable                 IntervalReason = "Unreachable"
	// Kubelet tries to get lease five times and then gives up
	NodeFailedLeaseBackoff IntervalReason = "FailedToUpdateLeaseInBackoff"
	NodeDiskPressure       IntervalReason = "NodeDiskPressure"
	NodeNoDiskPressure     IntervalReason = "NodeNoDiskPressure"
	NodeDeleted            IntervalReason = "Deleted"

	MachineConfigChangeReason  IntervalReason = "MachineConfigChange"
	MachineConfigReachedReason IntervalReason = "MachineConfigReached"

	MachineCreated      IntervalReason = "MachineCreated"
	MachineDeletedInAPI IntervalReason = "MachineDeletedInAPI"
	MachinePhaseChanged IntervalReason = "MachinePhaseChange"
	MachinePhase        IntervalReason = "MachinePhase"

	OnPremHaproxyDetectsDown  IntervalReason = "OnPremHaproxyDetectsDown"
	OnPremHaproxyStatusChange IntervalReason = "OnPremHaproxyStatusChange"
	OnPremLBPriorityChange    IntervalReason = "OnPremLBPriorityChange"
	OnPremLBTookVIP           IntervalReason = "OnPremLBTookVIP"
	OnPremLBLostVIP           IntervalReason = "OnPremLBLostVIP"

	Timeout IntervalReason = "Timeout"

	E2ETestStarted  IntervalReason = "E2ETestStarted"
	E2ETestFinished IntervalReason = "E2ETestFinished"

	CloudMetricsExtrenuous                IntervalReason = "CloudMetricsExtrenuous"
	CloudMetricsLBAvailability            IntervalReason = "CloudMetricsLBAvailability"
	CloudMetricsLBHealthEvent             IntervalReason = "CloudMetricsLBHealthEvent"
	FailedToDeleteCGroupsPath             IntervalReason = "FailedToDeleteCGroupsPath"
	FailedToAuthenticateWithOpenShiftUser IntervalReason = "FailedToAuthenticateWithOpenShiftUser"
	FailedContactingAPIReason             IntervalReason = "FailedContactingAPI"

	UnhealthyReason IntervalReason = "Unhealthy"

	UpgradeStartedReason  IntervalReason = "UpgradeStarted"
	UpgradeVersionReason  IntervalReason = "UpgradeVersion"
	UpgradeRollbackReason IntervalReason = "UpgradeRollback"
	UpgradeFailedReason   IntervalReason = "UpgradeFailed"
	UpgradeCompleteReason IntervalReason = "UpgradeComplete"

	NodeInstallerReason IntervalReason = "NodeInstaller"

	// client metrics show error connecting to the kube-apiserver
	APIUnreachableFromClientMetrics IntervalReason = "APIUnreachableFromClientMetrics"

	LeaseAcquiring        IntervalReason = "Acquiring"
	LeaseAcquiringStarted IntervalReason = "StartedAcquiring"
	LeaseAcquired         IntervalReason = "Acquired"

	ReasonBadOperatorApply  IntervalReason = "BadOperatorApply"
	ReasonKubeAPIServer500s IntervalReason = "KubeAPIServer500s"

	ReasonHighGeneration    IntervalReason = "HighGeneration"
	ReasonInvalidGeneration IntervalReason = "GenerationViolation"

	ReasonEtcdBootstrap     IntervalReason = "EtcdBootstrap"
	ReasonProcessDumpedCore IntervalReason = "ProcessDumpedCore"
)

func ConstructionOwnerFrom

func ConstructionOwnerFrom(message string) IntervalReason

func ReasonFrom

func ReasonFrom(message string) IntervalReason

func (IntervalReason) String

func (r IntervalReason) String() string

type IntervalSource

type IntervalSource string

IntervalSource is used to type/categorize all intervals based on what created them. This is intended to be used to group, and when combined with the display flag, signal that they should be visible by default in the UIs that render interval charts.

type Intervals

type Intervals []Interval

func (Intervals) Clamp

func (intervals Intervals) Clamp(from, to time.Time)

Clamp sets all zero value From or To fields to from or to.

func (Intervals) Cut

func (intervals Intervals) Cut(from, to time.Time) Intervals

Cut creates a copy of intervals where all events (empty To) are within [from,to) and all intervals that overlap [from,to) are included, but with their from/to fields limited to that range.

func (Intervals) Duration

func (intervals Intervals) Duration(minCurrentDuration time.Duration) time.Duration

Duration returns the sum of all intervals in the range. If To is less than or equal to From, 0 is used instead (use Clamp() if open intervals should be not considered instant). minDuration is the smallest duration to add. If a duration is less than the minDuration, then the minDuration is used instead. This is useful for measuring samples. For example, consider a case of one second polling for server availability. If a sample fails, you don't definitively know whether it was down just after t-1s or just before t. On average, it would be 500ms, but a useful minimum in this case could be 1s.

func (Intervals) Filter

func (intervals Intervals) Filter(eventFilterMatches EventIntervalMatchesFunc) Intervals

Filter returns a copy of intervals with only intervals that match the provided function.

func (Intervals) Len

func (intervals Intervals) Len() int

func (Intervals) Less

func (intervals Intervals) Less(i, j int) bool

func (Intervals) Slice

func (intervals Intervals) Slice(from, to time.Time) Intervals

Slice works on a sorted Intervals list and returns the set of intervals The intervals start from the first Interval that ends AFTER the argument.From. The last interval is one before the first Interval that starts before the argument.To The zero value will return all elements. If intervals is unsorted the result is undefined. This runs in O(n).

func (Intervals) Strings

func (intervals Intervals) Strings() []string

Strings returns the result of String() on each included interval.

func (Intervals) Swap

func (intervals Intervals) Swap(i, j int)

type Locator

type Locator struct {
	Type LocatorType `json:"type"`

	// annotations will include the Reason and Cause under their respective keys
	Keys map[LocatorKey]string `json:"keys"`
}

func LocatePod

func LocatePod(pod *corev1.Pod) Locator

func (*Locator) DeepCopy

func (o *Locator) DeepCopy() *Locator

func (Locator) HasKey

func (i Locator) HasKey(k LocatorKey) bool

func (Locator) OldLocator

func (i Locator) OldLocator() string

type LocatorBuilder

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

LocatorBuilder is used to create locators. We do not want to allow chaining of locators however as this has led to illegal definitions of locators in the past. (such as node + namespace) Instead the builder serves primarily as a place to store the builder functions.

func NewLocator

func NewLocator() *LocatorBuilder

func (*LocatorBuilder) AlertFromPromSampleStream

func (b *LocatorBuilder) AlertFromPromSampleStream(alert *model.SampleStream) Locator

func (*LocatorBuilder) Build

func (b *LocatorBuilder) Build() Locator

func (*LocatorBuilder) CloudNodeMetric

func (b *LocatorBuilder) CloudNodeMetric(nodeName string, metric string) Locator

func (*LocatorBuilder) ClusterOperator

func (b *LocatorBuilder) ClusterOperator(name string) Locator

func (*LocatorBuilder) ClusterVersion

func (b *LocatorBuilder) ClusterVersion(cv *v1.ClusterVersion) Locator

func (*LocatorBuilder) ContainerFromNames

func (b *LocatorBuilder) ContainerFromNames(namespace, podName, uid, containerName string) Locator

func (*LocatorBuilder) ContainerFromPod

func (b *LocatorBuilder) ContainerFromPod(pod *corev1.Pod, containerName string) Locator

func (*LocatorBuilder) DaemonSetFromName

func (b *LocatorBuilder) DaemonSetFromName(namespace, daemonSetName string) Locator

func (*LocatorBuilder) DeploymentFromName

func (b *LocatorBuilder) DeploymentFromName(namespace, deploymentName string) Locator

func (*LocatorBuilder) Disruption

func (b *LocatorBuilder) Disruption(backendDisruptionName, thisInstanceName, loadBalancer, protocol, target string, connectionType BackendConnectionType) Locator

func (*LocatorBuilder) DisruptionRequiredOnly

func (b *LocatorBuilder) DisruptionRequiredOnly(backendDisruptionName, thisInstanceName string) Locator

DisruptionRequiredOnly takes only the logically required data for backend-disruption.json and codifies it. backendDisruptionName is the value used to store and locate historical data related to the amount of disruption. thisInstanceName is used to show on a timeline which connection failed. For instance, the backendDisruptionName may be internal-load-balancer and the thisInstanceName may include, 1. from worker-a 2. new connections 3. to IP 4. this protocol

func (*LocatorBuilder) E2ETest

func (b *LocatorBuilder) E2ETest(testName string) Locator

func (*LocatorBuilder) EtcdMemberFromNames

func (b *LocatorBuilder) EtcdMemberFromNames(nodeName, memberName string) Locator

func (*LocatorBuilder) KubeAPIServerWithLB

func (b *LocatorBuilder) KubeAPIServerWithLB(loadBalancer string) Locator

func (*LocatorBuilder) KubeEvent

func (b *LocatorBuilder) KubeEvent(event *corev1.Event) Locator

TODO decide whether we want to allow "random" locator keys. deads2k is -1 on random locator keys and thinks we should enumerate every possible key we special case.

func (*LocatorBuilder) KubeletSyncLoopPLEG

func (b *LocatorBuilder) KubeletSyncLoopPLEG(node, ns, podName, eventType string) Locator

func (*LocatorBuilder) KubeletSyncLoopProbe

func (b *LocatorBuilder) KubeletSyncLoopProbe(node, ns, podName, probeType string) Locator

KubeletSyncLoopProbe constructs a locator from a Kubelet SyncLoop probe event, typically kubelet log prints the events as follows: "SyncLoop (probe)" probe="readiness" status="ready" pod="openshift-etcd/etcd-ci-op-bzbjn2bk-206af-gfdsw-master-2"

func (*LocatorBuilder) LocateDisruptionCheck

func (b *LocatorBuilder) LocateDisruptionCheck(backendDisruptionName, thisInstanceName string, connectionType BackendConnectionType) Locator

func (*LocatorBuilder) LocateNamespace

func (b *LocatorBuilder) LocateNamespace(namespaceName string) Locator

func (*LocatorBuilder) LocateRouteForDisruptionCheck

func (b *LocatorBuilder) LocateRouteForDisruptionCheck(backendDisruptionName, thisInstanceName, ns, name string, connectionType BackendConnectionType) Locator

func (*LocatorBuilder) LocateServer

func (b *LocatorBuilder) LocateServer(serverName, nodeName, namespace, podName string) Locator

func (*LocatorBuilder) MachineFromName

func (b *LocatorBuilder) MachineFromName(machineName string) Locator

func (*LocatorBuilder) NodeFromName

func (b *LocatorBuilder) NodeFromName(nodeName string) Locator

func (*LocatorBuilder) NodeFromNameWithRole

func (b *LocatorBuilder) NodeFromNameWithRole(nodeName, nodeRole string) Locator

func (*LocatorBuilder) NodeFromNameWithRow

func (b *LocatorBuilder) NodeFromNameWithRow(nodeName, row string) Locator

func (*LocatorBuilder) PodFromNames

func (b *LocatorBuilder) PodFromNames(namespace, podName, uid string) Locator

func (*LocatorBuilder) PodFromPod

func (b *LocatorBuilder) PodFromPod(pod *corev1.Pod) Locator

func (*LocatorBuilder) PrometheusTargetDownFromPromSampleStream

func (b *LocatorBuilder) PrometheusTargetDownFromPromSampleStream(sample *model.SampleStream) Locator

func (*LocatorBuilder) StatefulSetFromName

func (b *LocatorBuilder) StatefulSetFromName(namespace, statefulSetName string) Locator

func (*LocatorBuilder) StaticPodInstall

func (b *LocatorBuilder) StaticPodInstall(node, podType string) Locator

func (*LocatorBuilder) TestBucket

func (b *LocatorBuilder) TestBucket(bucketName string) Locator

func (*LocatorBuilder) WithAPIUnreachableFromClient

func (b *LocatorBuilder) WithAPIUnreachableFromClient(metric model.Metric, serviceNetworkIP, nodeName, nodeRole string) Locator

type LocatorKey

type LocatorKey string
const (
	LocatorClusterOperatorKey LocatorKey = "clusteroperator"
	LocatorClusterVersionKey  LocatorKey = "clusterversion"
	LocatorNamespaceKey       LocatorKey = "namespace"
	LocatorDeploymentKey      LocatorKey = "deployment"
	LocatorDaemonSetKey       LocatorKey = "daemonset"
	LocatorStatefulSetKey     LocatorKey = "statefulset"
	LocatorNodeKey            LocatorKey = "node"
	LocatorMachineKey         LocatorKey = "machine"
	LocatorNodeRoleKey        LocatorKey = "node-role"
	LocatorEtcdMemberKey      LocatorKey = "etcd-member"
	LocatorNameKey            LocatorKey = "name"
	LocatorHmsgKey            LocatorKey = "hmsg"
	LocatorInstanceKey        LocatorKey = "instance"
	LocatorPodKey             LocatorKey = "pod"
	LocatorUIDKey             LocatorKey = "uid"
	LocatorMirrorUIDKey       LocatorKey = "mirror-uid"
	LocatorMetricsPathKey     LocatorKey = "metrics-path"
	LocatorServiceKey         LocatorKey = "service"
	LocatorContainerKey       LocatorKey = "container"
	LocatorAlertKey           LocatorKey = "alert"
	LocatorRouteKey           LocatorKey = "route"
	// LocatorBackendDisruptionNameKey holds the value used to store and locate historical data related to the amount of disruption.
	LocatorBackendDisruptionNameKey LocatorKey = "backend-disruption-name"
	LocatorDisruptionKey            LocatorKey = "disruption"
	LocatorE2ETestKey               LocatorKey = "e2e-test"
	LocatorLoadBalancerKey          LocatorKey = "load-balancer"
	LocatorConnectionKey            LocatorKey = "connection"
	LocatorProtocolKey              LocatorKey = "protocol"
	LocatorTargetKey                LocatorKey = "target"
	LocatorRowKey                   LocatorKey = "row"
	LocatorServerKey                LocatorKey = "server"
	LocatorMetricKey                LocatorKey = "metric"

	LocatorAPIUnreachableHostKey                  LocatorKey = "host"
	LocatorAPIUnreachableComponentKey             LocatorKey = "component"
	LocatorOnPremKubeapiUnreachableFromHaproxyKey LocatorKey = "onprem-haproxy"
	LocatorOnPremVIPMonitorKey                    LocatorKey = "onprem-keepalived"

	LocatorTypeKubeletSyncLoopProbeType LocatorKey = "probe"
	LocatorTypeKubeletSyncLoopPLEGType  LocatorKey = "plegType"
	LocatorStaticPodInstallType         LocatorKey = "podType"
	LocatorTestBucketKey                LocatorKey = "test-bucket"
)

type LocatorType

type LocatorType string
const (
	LocatorTypePod             LocatorType = "Pod"
	LocatorTypeContainer       LocatorType = "Container"
	LocatorTypeNode            LocatorType = "Node"
	LocatorTypeMachine         LocatorType = "Machine"
	LocatorTypeAlert           LocatorType = "Alert"
	LocatorTypeMetricsEndpoint LocatorType = "MetricsEndpoint"
	LocatorTypeClusterOperator LocatorType = "ClusterOperator"
	LocatorTypeDisruption      LocatorType = "Disruption"
	LocatorTypeKubeEvent       LocatorType = "KubeEvent"
	LocatorTypeE2ETest         LocatorType = "E2ETest"
	LocatorTypeAPIServer       LocatorType = "APIServer"
	LocatorTypeClusterVersion  LocatorType = "ClusterVersion"
	LocatorTypeKind            LocatorType = "Kind"
	LocatorTypeCloudMetrics    LocatorType = "CloudMetrics"
	LocatorTypeDeployment      LocatorType = "Deployment"
	LocatorTypeDaemonSet       LocatorType = "DaemonSet"
	LocatorTypeStatefulSet     LocatorType = "StatefulSet"

	LocatorTypeAPIUnreachableFromClient LocatorType = "APIUnreachableFromClient"

	LocatorTypeKubeletSyncLoopProbe LocatorType = "KubeletSyncLoopProbe"
	LocatorTypeKubeletSyncLoopPLEG  LocatorType = "KubeletSyncLoopPLEG"
	LocatorTypeStaticPodInstall     LocatorType = "StaticPodInstall"
	LocatorTypeTestBucket           LocatorType = "TestBucket"
)

type Message

type Message struct {
	// TODO: reason/cause both fields and annotations...
	Reason       IntervalReason `json:"reason"`
	Cause        string         `json:"cause"`
	HumanMessage string         `json:"humanMessage"`

	// annotations will include the Reason and Cause under their respective keys
	Annotations map[AnnotationKey]string `json:"annotations"`
}

func (*Message) DeepCopy

func (o *Message) DeepCopy() *Message

func (Message) OldMessage

func (i Message) OldMessage() string

type MessageBuilder

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

func ExpandMessage

func ExpandMessage(prevMessage Message) *MessageBuilder

ExpandMessage parses a message that was collapsed into a string to extract each annotation and the original message.

func NewMessage

func NewMessage() *MessageBuilder

func (*MessageBuilder) Build

func (m *MessageBuilder) Build() Message

Build creates the final Message with all data assembled by this builder.

func (*MessageBuilder) BuildString

func (m *MessageBuilder) BuildString() string

BuildString creates the final message as a flat single string. Each annotation is prepended in the form name/value, followed by the human message, if any.

func (*MessageBuilder) Cause

func (m *MessageBuilder) Cause(cause string) *MessageBuilder

func (*MessageBuilder) Constructed

func (m *MessageBuilder) Constructed(constructedBy ConstructionOwner) *MessageBuilder

func (*MessageBuilder) HumanMessage

func (m *MessageBuilder) HumanMessage(message string) *MessageBuilder

HumanMessage adds the human readable message. If called multiple times, the message is appended.

func (*MessageBuilder) HumanMessagef

func (m *MessageBuilder) HumanMessagef(messageFormat string, args ...interface{}) *MessageBuilder

HumanMessagef adds a formatted string to the human readable message. If called multiple times, the message is appended.

func (*MessageBuilder) Node

func (m *MessageBuilder) Node(node string) *MessageBuilder

func (*MessageBuilder) Reason

func (m *MessageBuilder) Reason(reason IntervalReason) *MessageBuilder

func (*MessageBuilder) WithAnnotation

func (m *MessageBuilder) WithAnnotation(name AnnotationKey, value string) *MessageBuilder

func (*MessageBuilder) WithAnnotations

func (m *MessageBuilder) WithAnnotations(annotations map[AnnotationKey]string) *MessageBuilder

type NamespacedReference

type NamespacedReference struct {
	Namespace string
	Name      string
	UID       string
}

type PodReference

type PodReference struct {
	NamespacedReference
}

TODO: delete all these

func PodFrom

func PodFrom(locator Locator) PodReference

PodFrom is used to strip down a locator to just a pod. (as it may contain additional keys like container or node) that we do not want for some uses.

func (PodReference) ToLocator

func (r PodReference) ToLocator() Locator

type Recorder

type Recorder interface {
	RecorderReader
	RecorderWriter
}

TODO most consumers only need writers or readers. switch.

type RecorderReader

type RecorderReader interface {
	// Intervals returns a sorted snapshot of intervals in the selected timeframe
	Intervals(from, to time.Time) Intervals
	// CurrentResourceState returns a list of all known resources of a given type at the instant called.
	CurrentResourceState() ResourcesMap
}

type RecorderWriter

type RecorderWriter interface {
	// RecordResource stores a resource for later serialization.  Deletion is not tracked, so this can be used
	// to determine the final state of resource that are deleted in a namespace.
	// Annotations are added to indicate number of updates and the number of recreates.
	RecordResource(resourceType string, obj runtime.Object)

	Record(conditions ...Condition)
	RecordAt(t time.Time, conditions ...Condition)

	AddIntervals(eventIntervals ...Interval)
	StartInterval(interval Interval) int
	EndInterval(startedInterval int, t time.Time) *Interval
}

type ResourcesMap

type ResourcesMap map[string]InstanceMap

Jump to

Keyboard shortcuts

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