Safe HaskellNone



Filtering of jobs for the Ganeti job queue.



accessOpCodeField :: OpCode -> String -> ErrorResult JSValue Source #

Accesses a field of the JSON representation of an OpCode using a dotted accessor (like "a.b.c").

opCodesOf :: QueuedJob -> [OpCode] Source #

All OpCodes of a job.

evaluateFilterComparator :: Ord field => Filter field -> (Comparator -> field -> FilterValue -> Maybe Bool) -> Bool Source #

Like evaluateFilterM, but allowing only Comparator operations; all other filter language operations are evaluated as False.

The passed function is supposed to return `Just True/False` depending on whether the comparing operation succeeds or not, and Nothing if the comparison itself is invalid (e.g. comparing to a field that doesn't exist).

matchPredicate Source #


:: QueuedJob 
-> JobId

the watermark to compare against if the predicate references it

-> FilterPredicate 
-> Bool 

Whether a FilterPredicate is true for a job.

matches :: QueuedJob -> FilterRule -> Bool Source #

Whether all predicates of the filter rule are true for the job.

orderFilters :: Set FilterRule -> [FilterRule] Source #

Filters need to be processed in the order as given by the spec; see filterRuleOrder.

applyingFilter :: Set FilterRule -> QueuedJob -> Maybe FilterRule Source #

Finds the first filter whose predicates all match the job and whose action is not Continue. This is the applying filter.

type RateLimitSlotMap = SlotMap ByteString Source #

SlotMap for filter rule rate limiting, having FilterRule UUIDs as keys.

data FilterChainState Source #

State to be accumulated while traversing filters.

tryFitSlots :: FilterChainState -> CountMap ByteString -> Maybe FilterChainState Source #

Update a FilterChainState if the given CountMap fits into its filtering SlotsMap.

queueRateLimitSlotMap :: Queue -> Set FilterRule -> RateLimitSlotMap Source #

For a given job queue and set of filters, calculates how many rate limiting filter slots are available and how many are taken by running jobs in the queue.

jobFiltering :: Queue -> Set FilterRule -> [JobWithStat] -> [JobWithStat] Source #

Implements job filtering as specified in `doc/design-optables.rst`.

Importantly, the filter that *applies* is the first one of which all predicates match; this is implemented in applyingFilter.

The initial FilterChainState is currently not cached across selectJobsToRun invocations because the number of running jobs is typically small (< 100).