suitelimits

package
v0.0.0-...-9febfc8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package suitelimits implements the tooling to limit CTP requests to 3 DUT hours in total. This project was implemented, inline, in CTPv1 but is being generalized here.

Index

Constants

View Source
const (
	DutHourMaximumSeconds = 3 * hour
)

Variables

This section is empty.

Functions

func AddRequestTask

func AddRequestTask(requestKey, suiteName, hwTarget, pool string, taskBBID int64) error

AddRequestTask adds a new tracking bbid for the request set with the start time set to the current time.time value when the addition is made.

func CancelTasks

func CancelTasks(ctx context.Context, requestKey, taskName string, bbClient buildbucket.BuildsClient) error

CancelTasks sends a BuildBucket Cancel request for each bbid being tracked in the entry. This should only be called when the request has gone past the maximum allowed DUT hour time and it does not have an active exemption.

func CloseMetricChan

func CloseMetricChan()

func ExceededLimit

func ExceededLimit(requestKey, taskName string) (bool, error)

ExceededLimit returns if the provided request has exceeded the DUT hour limit.

func ExtractTarget

func ExtractTarget(shardName string) (string, error)

ExtractTarget extracts the target key from the shard name so that we can use it to fetch from requestToTargetChainMap.

func GetIncrementalLogs

func GetIncrementalLogs() map[string][][]string

func GetTotalDUTHours

func GetTotalDUTHours(requestKey, taskName string) (time.Duration, error)

GetTotalDUTHours returns the total DUT hour usage for the given request.

func GetTotalsLogs

func GetTotalsLogs() [][]string

func HasExemption

func HasExemption(requestKey, taskName string) (bool, error)

HasExemption returns if the provided request has an active exemption from the Suite Limits service.

func IsExempt

func IsExempt(entry *suiteLimitEntry) bool

IsExempt determines if the entry is exempt from the SuiteLimits restrictions. Eligible exemptions are:

  1. Request is running in a private pool
  2. Explicit exemption granted in the config file

NOTE: must only be called within a mutex locked outer function.

func LogMetrics

func LogMetrics(ctx context.Context)

LogMetrics captures and filters the logs passed in through the logChannel. Once the channel is closed it writes all the data to individual CSVs per suite.

func UpdateTotalTime

func UpdateTotalTime(requestKey, suiteName, taskName string, taskBBID int64) (bool, error)

UpdateTotalTime updates the total request time of the passed in unique request set by the amount of time it's been since the passed in BBID has been seen.

Types

type HWTarget

type HWTarget string

HWTarget is a string int he form of [<board>([-]?<variant>)]

type RequestKey

type RequestKey string

Jump to

Keyboard shortcuts

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