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
- func AddRequestTask(requestKey, suiteName, hwTarget, pool string, taskBBID int64) error
- func CancelTasks(ctx context.Context, requestKey, taskName string, ...) error
- func CloseMetricChan()
- func ExceededLimit(requestKey, taskName string) (bool, error)
- func ExtractTarget(shardName string) (string, error)
- func GetIncrementalLogs() map[string][][]string
- func GetTotalDUTHours(requestKey, taskName string) (time.Duration, error)
- func GetTotalsLogs() [][]string
- func HasExemption(requestKey, taskName string) (bool, error)
- func IsExempt(entry *suiteLimitEntry) bool
- func LogMetrics(ctx context.Context)
- func UpdateTotalTime(requestKey, suiteName, taskName string, taskBBID int64) (bool, error)
- type HWTarget
- type RequestKey
Constants ¶
const (
DutHourMaximumSeconds = 3 * hour
)
Variables ¶
This section is empty.
Functions ¶
func AddRequestTask ¶
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 ¶
ExceededLimit returns if the provided request has exceeded the DUT hour limit.
func ExtractTarget ¶
ExtractTarget extracts the target key from the shard name so that we can use it to fetch from requestToTargetChainMap.
func GetIncrementalLogs ¶
func GetTotalDUTHours ¶
GetTotalDUTHours returns the total DUT hour usage for the given request.
func GetTotalsLogs ¶
func GetTotalsLogs() [][]string
func HasExemption ¶
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:
- Request is running in a private pool
- Explicit exemption granted in the config file
NOTE: must only be called within a mutex locked outer function.
func LogMetrics ¶
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.
Types ¶
type RequestKey ¶
type RequestKey string