Documentation ¶
Index ¶
- Constants
- func ComputePercentiles(timeSeries []ResourceUsagePerContainer, percentilesToCompute []int) map[int]ResourceUsagePerContainer
- func ConvertSampleToBucket(sample *model.Sample, h *HistogramVec)
- func ConvertSampleToHistogram(sample *model.Sample, h *Histogram)
- func ExtractMetricSamples(metricsBlob string) ([]*model.Sample, error)
- func ExtractMetricSamples2(response []byte) ([]*model.Sample, error)
- func GetApiserverLatency(clusterVersion version.Info) string
- func GetApiserverSLI(clusterVersion version.Info) string
- func GetMasterHost(host string) (string, error)
- func LeftMergeData(left, right map[int]ResourceUsagePerContainer) map[int]ResourceUsagePerContainer
- func MatchAll(_ string) bool
- func ToPrometheusTime(t time.Duration) string
- func WaitForGenericK8sObjects(ctx context.Context, dynamicClient dynamic.Interface, ...) error
- func WaitForNodes(clientSet clientset.Interface, stopCh <-chan struct{}, ...) error
- func WaitForPVCs(clientSet clientset.Interface, stopCh <-chan struct{}, ...) error
- func WaitForPVs(clientSet clientset.Interface, stopCh <-chan struct{}, ...) error
- type ContainerResourceUsage
- type ControlledPodsIndexer
- type DataItem
- type DynamicObjectStore
- type Histogram
- type HistogramVec
- type KeyFilterFunc
- type LatencyData
- type LatencyMetric
- type LatencySlice
- type NamespacesRange
- type NodeStore
- type ObjectSimplification
- type ObjectStore
- type ObjectTransitionTimes
- func (o *ObjectTransitionTimes) CalculateTransitionsLatency(t map[string]Transition, filter KeyFilterFunc) map[string]*LatencyMetric
- func (o *ObjectTransitionTimes) Count(phase string) int
- func (o *ObjectTransitionTimes) Get(key, phase string) (time.Time, bool)
- func (o *ObjectTransitionTimes) Set(key, phase string, t time.Time)
- type OwnerReferenceBasedPodStore
- type PVCDiff
- type PVCStore
- type PVCsStartupStatus
- type PVDiff
- type PVStore
- type PVsStartupStatus
- type PerfData
- type PodDiff
- type PodInfo
- type PodLister
- type PodStore
- type PodsMetadata
- type PodsStartupStatus
- type PodsStatus
- type PrometheusQueryExecutor
- type ReplicaSetState
- type ResourceConstraint
- type ResourceUsagePerContainer
- type SSHResult
- type SingleContainerSummary
- type Status
- type StatusWithConditions
- type Transition
- type UIDSet
- type UsageDataPerContainer
- type WaitForGenericK8sObjectsOptions
- type WaitForNodeOptions
- type WaitForPVCOptions
- type WaitForPVOptions
- type WaitForPodOptions
Constants ¶
const PerfResultEnd = "[Finish:Performance]"
PerfResultEnd is the end of generated perfdata. Analyzing tools can find the end of the perf result with this tag.
const PerfResultTag = "[Result:Performance]"
PerfResultTag is the prefix of generated perfdata. Analyzing tools can find the perf result with this tag.
Variables ¶
This section is empty.
Functions ¶
func ComputePercentiles ¶
func ComputePercentiles(timeSeries []ResourceUsagePerContainer, percentilesToCompute []int) map[int]ResourceUsagePerContainer
ComputePercentiles calculates percentiles for given data series.
func ConvertSampleToBucket ¶
func ConvertSampleToBucket(sample *model.Sample, h *HistogramVec)
ConvertSampleToBucket converts prometheus sample into HistogramVec bucket.
func ConvertSampleToHistogram ¶
ConvertSampleToHistogram converts prometheus sample into Histogram.
func ExtractMetricSamples ¶
ExtractMetricSamples unpacks metric blob into prometheus model structures.
func ExtractMetricSamples2 ¶
ExtractMetricSamples2 unpacks metric blob into prometheus model structures.
func GetApiserverLatency ¶
func GetApiserverSLI ¶
func GetMasterHost ¶
GetMasterHost turns host name (without prefix and port).
func LeftMergeData ¶
func LeftMergeData(left, right map[int]ResourceUsagePerContainer) map[int]ResourceUsagePerContainer
LeftMergeData merges two data structures.
func ToPrometheusTime ¶
ToPrometheusTime returns prometheus string representation of given time.
func WaitForGenericK8sObjects ¶
func WaitForGenericK8sObjects(ctx context.Context, dynamicClient dynamic.Interface, options *WaitForGenericK8sObjectsOptions) error
WaitForGenericK8sObjects waits till the desired number of k8s objects fulfills given conditions requirements, ctx.Done() channel is used to wait for timeout.
func WaitForNodes ¶
func WaitForNodes(clientSet clientset.Interface, stopCh <-chan struct{}, options *WaitForNodeOptions) error
WaitForNodes waits till the desired number of nodes is ready. If stopCh is closed before all nodes are ready, the error will be returned.
func WaitForPVCs ¶
func WaitForPVCs(clientSet clientset.Interface, stopCh <-chan struct{}, options *WaitForPVCOptions) error
WaitForPVCs waits till desired number of PVCs is running. PVCs are be specified by namespace, field and/or label selectors. If stopCh is closed before all PVCs are running, the error will be returned.
func WaitForPVs ¶
func WaitForPVs(clientSet clientset.Interface, stopCh <-chan struct{}, options *WaitForPVOptions) error
WaitForPVs waits till desired number of PVs is running. PVs are be specified by field and/or label selectors. If stopCh is closed before all PVs are running, the error will be returned.
Types ¶
type ContainerResourceUsage ¶
type ContainerResourceUsage struct { Name string Timestamp time.Time CPUUsageInCores float64 MemoryUsageInBytes uint64 MemoryWorkingSetInBytes uint64 MemoryRSSInBytes uint64 // The interval used to calculate CPUUsageInCores. CPUInterval time.Duration }
ContainerResourceUsage represents resource usage by a single container.
type ControlledPodsIndexer ¶
type ControlledPodsIndexer struct {
// contains filtered or unexported fields
}
ControlledPodsIndexer is able to efficiently find pods with ownerReference pointing a given controller object. For Deployments, it performs indirect lookup with ReplicaSets in the middle.
func NewControlledPodsIndexer ¶
func NewControlledPodsIndexer(podsInformer coreinformers.PodInformer, rsInformer appsinformers.ReplicaSetInformer) (*ControlledPodsIndexer, error)
NewControlledPodsIndexer creates a new ControlledPodsIndexer instance.
func (*ControlledPodsIndexer) PodsControlledBy ¶
func (p *ControlledPodsIndexer) PodsControlledBy(obj interface{}) ([]*corev1.Pod, error)
PodsControlledBy returns pods controlled by a given controller object.
func (*ControlledPodsIndexer) WaitForCacheSync ¶
func (p *ControlledPodsIndexer) WaitForCacheSync(ctx context.Context) bool
WaitForCacheSync waits for all required informers to be initialized.
type DataItem ¶
type DataItem struct { // Data is a map from bucket to real data point (e.g. "Perc90" -> 23.5). Notice // that all data items with the same label combination should have the same buckets. Data map[string]float64 `json:"data"` // Unit is the data unit. Notice that all data items with the same label combination // should have the same unit. Unit string `json:"unit"` // Labels is the labels of the data item. Labels map[string]string `json:"labels,omitempty"` }
DataItem is the data point.
type DynamicObjectStore ¶
type DynamicObjectStore struct { cache.GenericLister // contains filtered or unexported fields }
DynamicObjectStore is a convenient wrapper around cache.GenericLister.
func NewDynamicObjectStore ¶
func NewDynamicObjectStore(ctx context.Context, dynamicClient dynamic.Interface, gvr schema.GroupVersionResource, namespaces map[string]bool) (*DynamicObjectStore, error)
NewDynamicObjectStore creates DynamicObjectStore based on given object version resource and selector.
func (*DynamicObjectStore) ListObjectSimplifications ¶
func (s *DynamicObjectStore) ListObjectSimplifications() ([]ObjectSimplification, error)
ListObjectSimplifications returns list of objects with conditions for each object that was returned by lister.
type Histogram ¶
type Histogram struct { Labels map[string]string `json:"labels"` // Buckets maps value to cumulative sample count: // * key: float64 converted to string // * value: cumulative count of all samples less or equal to the key. Buckets map[string]int `json:"buckets"` }
Histogram is a structure that represents distribution of data.
func NewHistogram ¶
NewHistogram creates new Histogram instance.
type KeyFilterFunc ¶
KeyFilterFunc is a function that for a given key returns whether its corresponding entry should be included in the metric.
type LatencyData ¶
LatencyData is an interface for latance data structure.
type LatencyMetric ¶
type LatencyMetric struct { Perc50 time.Duration `json:"Perc50"` Perc90 time.Duration `json:"Perc90"` Perc99 time.Duration `json:"Perc99"` }
LatencyMetric represent 50th, 90th and 99th duration quantiles.
func NewLatencyMetric ¶
func NewLatencyMetric(latencies []LatencyData) LatencyMetric
NewLatencyMetric converts latency data array to latency metric.
func NewLatencyMetricPrometheus ¶
func NewLatencyMetricPrometheus(samples []*model.Sample) (*LatencyMetric, error)
NewLatencyMetricPrometheus tries to parse latency data from results of Prometheus query.
func (*LatencyMetric) SetQuantile ¶
func (metric *LatencyMetric) SetQuantile(quantile float64, latency time.Duration)
SetQuantile set quantile value. Only 0.5, 0.9 and 0.99 quantiles are supported.
func (LatencyMetric) String ¶
func (metric LatencyMetric) String() string
func (*LatencyMetric) ToPerfData ¶
func (metric *LatencyMetric) ToPerfData(name string) DataItem
ToPerfData converts latency metric to PerfData.
func (*LatencyMetric) VerifyThreshold ¶
func (metric *LatencyMetric) VerifyThreshold(threshold time.Duration) error
VerifyThreshold verifies latency metric against given percentile thresholds.
type LatencySlice ¶
type LatencySlice []LatencyData
LatencySlice is a sortable latency array.
func (LatencySlice) Len ¶
func (l LatencySlice) Len() int
func (LatencySlice) Less ¶
func (l LatencySlice) Less(i, j int) bool
func (LatencySlice) Swap ¶
func (l LatencySlice) Swap(i, j int)
type NamespacesRange ¶
NamespacesRange represents namespace range which will be queried.
func (*NamespacesRange) String ¶
func (nr *NamespacesRange) String() string
String returns printable representation of the namespaces range.
type NodeStore ¶
type NodeStore struct {
*ObjectStore
}
NodeStore is a convenient wrapper around cache.Store.
func NewNodeStore ¶
NewNodeStore creates NodeStore based on a given object selector.
type ObjectSimplification ¶
type ObjectSimplification struct { Metadata metav1.ObjectMeta `json:"metadata"` Status StatusWithConditions `json:"status"` }
ObjectSimplification represents the content of the object that is needed to be handled by this measurement.
func (ObjectSimplification) String ¶
func (o ObjectSimplification) String() string
type ObjectStore ¶
type ObjectStore struct { cache.Store Reflector *cache.Reflector // contains filtered or unexported fields }
ObjectStore is a convenient wrapper around cache.Store.
type ObjectTransitionTimes ¶
type ObjectTransitionTimes struct {
// contains filtered or unexported fields
}
ObjectTransitionTimes stores beginning time of each phase. It can calculate transition latency between phases. ObjectTransitionTimes is thread-safe.
func NewObjectTransitionTimes ¶
func NewObjectTransitionTimes(name string) *ObjectTransitionTimes
NewObjectTransitionTimes creates new ObjectTransitionTimes instance.
func (*ObjectTransitionTimes) CalculateTransitionsLatency ¶
func (o *ObjectTransitionTimes) CalculateTransitionsLatency(t map[string]Transition, filter KeyFilterFunc) map[string]*LatencyMetric
CalculateTransitionsLatency returns a latency map for given transitions.
func (*ObjectTransitionTimes) Count ¶
func (o *ObjectTransitionTimes) Count(phase string) int
Count returns number of key having given phase entry.
type OwnerReferenceBasedPodStore ¶
type OwnerReferenceBasedPodStore struct {
// contains filtered or unexported fields
}
OwnerReferenceBasedPodStore returns pods with ownerReference set to the owner (with exception for Deployment, see ControlledPodsIndexer implementation) and matching given labelSelector.
func NewOwnerReferenceBasedPodStore ¶
func NewOwnerReferenceBasedPodStore(controlledPodsIndexer controlledPodsIndexer, owner interface{}) (*OwnerReferenceBasedPodStore, error)
func (*OwnerReferenceBasedPodStore) List ¶
func (s *OwnerReferenceBasedPodStore) List() ([]*v1.Pod, error)
List returns controlled pods.
func (*OwnerReferenceBasedPodStore) String ¶
func (s *OwnerReferenceBasedPodStore) String() string
String returns human readable identifier of pods kept in the store.
type PVCDiff ¶
type PVCDiff map[string]*pvcInfo
PVCDiff represets diff between old and new group of pvcs.
func DiffPVCs ¶
func DiffPVCs(oldPVCs []*corev1.PersistentVolumeClaim, curPVCs []*corev1.PersistentVolumeClaim) PVCDiff
DiffPVCs computes a PVCDiff given 2 lists of PVCs.
func (PVCDiff) DeletedPVCs ¶
DeletedPVCs returns a slice of PVCs that were present at the beginning and then disappeared.
type PVCStore ¶
type PVCStore struct {
*ObjectStore
}
PVCStore is a convenient wrapper around cache.Store.
func NewPVCStore ¶
NewPVCStore creates PVCStore based on a given object selector.
func (*PVCStore) List ¶
func (s *PVCStore) List() []*v1.PersistentVolumeClaim
List returns list of pvcs (that satisfy conditions provided to NewPVCStore).
type PVCsStartupStatus ¶
PVCsStartupStatus represents phase of a pvc group.
func ComputePVCsStartupStatus ¶
func ComputePVCsStartupStatus(pvcs []*corev1.PersistentVolumeClaim, expected int) PVCsStartupStatus
ComputePVCsStartupStatus computes PVCsStartupStatus for a group of PVCs.
func (*PVCsStartupStatus) String ¶
func (s *PVCsStartupStatus) String() string
String returns string representation for PVCsStartupStatus.
type PVDiff ¶
type PVDiff map[string]*pvInfo
PVDiff represents diff between old and new group of PVs.
func DiffPVs ¶
func DiffPVs(oldPVs []*corev1.PersistentVolume, curPVs []*corev1.PersistentVolume) PVDiff
DiffPVs computes a PVDiff given 2 lists of PVs.
func (PVDiff) DeletedPVs ¶
DeletedPVs returns a slice of PVs that were present at the beginning and then disappeared.
type PVStore ¶
type PVStore struct { *ObjectStore // contains filtered or unexported fields }
PVStore is a convenient wrapper around cache.Store.
func NewPVStore ¶
func NewPVStore(c clientset.Interface, selector *util.ObjectSelector, provisioner string) (*PVStore, error)
NewPVStore creates PVStore based on a given object selector.
func (*PVStore) List ¶
func (s *PVStore) List() []*v1.PersistentVolume
List returns list of pvs (that satisfy conditions provided to NewPVStore).
type PVsStartupStatus ¶
type PVsStartupStatus struct { Pending int Available int Bound int Released int Failed int Expected int Created int }
PVsStartupStatus represents phase of a PV group.
func ComputePVsStartupStatus ¶
func ComputePVsStartupStatus(PVs []*corev1.PersistentVolume, expected int) PVsStartupStatus
ComputePVsStartupStatus computes PVsStartupStatus for a group of PVs.
func (*PVsStartupStatus) String ¶
func (s *PVsStartupStatus) String() string
String returns string representation for PVsStartupStatus.
type PerfData ¶
type PerfData struct { // Version is the version of the metrics. The metrics consumer could use the version // to detect metrics version change and decide what version to support. Version string `json:"version"` DataItems []DataItem `json:"dataItems"` // Labels is the labels of the dataset. Labels map[string]string `json:"labels,omitempty"` }
PerfData contains all data items generated in current test.
func LatencyMapToPerfData ¶
func LatencyMapToPerfData(latency map[string]*LatencyMetric) *PerfData
LatencyMapToPerfData converts latency map into PerfData.
type PodDiff ¶
type PodDiff map[string]*podDiffInfo
PodDiff represets diff between old and new group of pods.
func (PodDiff) DeletedPods ¶
DeletedPods returns a slice of pods that were present at the beginning and then disappeared.
type PodStore ¶
type PodStore struct { *ObjectStore // contains filtered or unexported fields }
PodStore is a convenient wrapper around cache.Store.
func NewPodStore ¶
NewPodStore creates PodStore based on given object selector.
type PodsMetadata ¶
type PodsMetadata struct {
// contains filtered or unexported fields
}
PodsMetadata store metadata about pods.
func NewPodsMetadata ¶
func NewPodsMetadata(name string) *PodsMetadata
NewPodsMetadata created new PodsMetadata instance.
func (*PodsMetadata) FilterStateful ¶
func (o *PodsMetadata) FilterStateful(key string) bool
FilterStateful returns true iff a pod associated with a given key is not marked as stateless.
func (*PodsMetadata) FilterStateless ¶
func (o *PodsMetadata) FilterStateless(key string) bool
FilterStateless returns true iff a pod associated with a given key is marked as stateless.
func (*PodsMetadata) SetStateless ¶
func (o *PodsMetadata) SetStateless(key string, stateless bool)
SetStateless marks a given pod as stateless.
type PodsStartupStatus ¶
type PodsStartupStatus struct { Expected int Terminating int Running int Scheduled int RunningButNotReady int Waiting int Pending int Unknown int Inactive int Created int RunningUpdated int LastIsPodUpdatedError error }
PodsStartupStatus represents status of a pods group.
func ComputePodsStartupStatus ¶
func ComputePodsStartupStatus(pods []*corev1.Pod, expected int, isPodUpdated func(*corev1.Pod) error) PodsStartupStatus
ComputePodsStartupStatus computes PodsStartupStatus for a group of pods. TODO(mborsz): Migrate to podStatus instead of recalculating per pod status here.
func (*PodsStartupStatus) String ¶
func (s *PodsStartupStatus) String() string
String returns string representation for podsStartupStatus.
type PodsStatus ¶
type PodsStatus struct {
Info []*PodInfo
}
PodsStatus is a collection of current pod phases and node assignments data.
func ComputePodsStatus ¶
func ComputePodsStatus(pods []*corev1.Pod) *PodsStatus
ComputePodsStatus computes PodsStatus for a group of pods.
func WaitForPods ¶
func WaitForPods(ctx context.Context, ps PodLister, options *WaitForPodOptions) (*PodsStatus, error)
WaitForPods waits till desired number of pods is running. The current set of pods are fetched by calling List() on the provided PodStore. In the case of failure returns list of pods that were in unexpected state
func (*PodsStatus) NotRunningAndReady ¶
func (ps *PodsStatus) NotRunningAndReady() *PodsStatus
func (*PodsStatus) String ¶
func (ps *PodsStatus) String() string
String returns string representation of a PodsStatus.
type PrometheusQueryExecutor ¶
type PrometheusQueryExecutor struct {
// contains filtered or unexported fields
}
PrometheusQueryExecutor executes queries against Prometheus.
func NewQueryExecutor ¶
func NewQueryExecutor(pc prom.Client) *PrometheusQueryExecutor
NewQueryExecutor creates instance of PrometheusQueryExecutor.
type ReplicaSetState ¶
ReplicaSetState stores information relevant to a specific ReplicaSet object, i.e. how many pods it owns exist, whether the RS object itself exists and its latest known owner's UID.
type ResourceConstraint ¶
type ResourceConstraint struct { CPUConstraint float64 `json:"cpuConstraint"` MemoryConstraint uint64 `json:"memoryConstraint"` }
ResourceConstraint specifies constraint on resources.
type ResourceUsagePerContainer ¶
type ResourceUsagePerContainer map[string]*ContainerResourceUsage
ResourceUsagePerContainer is a map of ContainerResourceUsage for containers.
type SingleContainerSummary ¶
SingleContainerSummary is a resource usage summary for a single container.
type StatusWithConditions ¶
StatusWithConditions represents the content of the status field that is required to be handled by this measurement.
type Transition ¶
Transition describe transition between two phases.
type UsageDataPerContainer ¶
UsageDataPerContainer contains resource usage data series.
type WaitForGenericK8sObjectsOptions ¶
type WaitForGenericK8sObjectsOptions struct { // GroupVersionResource identifies the resource to fetch. GroupVersionResource schema.GroupVersionResource // Namespaces identifies namespaces which should be observed. Namespaces NamespacesRange // SuccessfulConditions lists conditions to look for in the objects denoting good objects. // Formatted as `ConditionType=ConditionStatus`, e.g. `Scheduled=true`. SuccessfulConditions []string // SuccessfulConditions lists conditions to look for in the objects denoting good objects. // Formatted as `ConditionType=ConditionStatus`, e.g. `Scheduled=true`. FailedConditions []string // MinDesiredObjectCount describes minimum number of objects that should contain // successful or failed condition. MinDesiredObjectCount int // MaxFailedObjectCount describes maximum number of objects that could contain failed condition. MaxFailedObjectCount int // CallerName identifies the measurement making the calls. CallerName string // WaitInterval contains interval for which the function waits between refreshes. WaitInterval time.Duration }
WaitForGenericK8sObjectsOptions is an options object used by WaitForGenericK8sObjectsNodes methods.
func (*WaitForGenericK8sObjectsOptions) Summary ¶
func (o *WaitForGenericK8sObjectsOptions) Summary() string
Summary returns summary which should be included in all logs.
type WaitForNodeOptions ¶
type WaitForNodeOptions struct { Selector *util.ObjectSelector MinDesiredNodeCount int MaxDesiredNodeCount int CallerName string WaitForNodesInterval time.Duration }
WaitForNodeOptions is an options object used by WaitForNodes methods.
type WaitForPVCOptions ¶
type WaitForPVCOptions struct { Selector *util.ObjectSelector DesiredPVCCount int CallerName string WaitForPVCsInterval time.Duration }
WaitForPVCOptions is an options used by WaitForPVCs methods.
type WaitForPVOptions ¶
type WaitForPVOptions struct { Selector *util.ObjectSelector DesiredPVCount int Provisioner string CallerName string WaitForPVsInterval time.Duration }
WaitForPVOptions is an options used by WaitForPVs methods.
type WaitForPodOptions ¶
type WaitForPodOptions struct { DesiredPodCount func() int CountErrorMargin int CallerName string WaitForPodsInterval time.Duration // IsPodUpdated can be used to detect which pods have been already updated. // nil value means all pods are updated. IsPodUpdated func(*v1.Pod) error }
WaitForPodOptions is an options used by WaitForPods methods.
Source Files ¶
- controlled_pods_indexer.go
- histogram.go
- latency_metric.go
- metrics.go
- object_store.go
- object_store_dynamic.go
- perftype.go
- phase_latency.go
- pods.go
- pods_metadata.go
- prometheus.go
- pvcs.go
- pvs.go
- resource.go
- ssh.go
- wait_for_conditions.go
- wait_for_nodes.go
- wait_for_pods.go
- wait_for_pvcs.go
- wait_for_pvs.go