Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fairness #3134

Merged
merged 9 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/aperture/policy/language/v1/flowcontrol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ message Scheduler {
// Key for a flow label that can be used to provide workloads for this request.
// If this parameter is not provided, the workloads for the flow will be determined by the matched workload's name in the policy.
string workload_label_key = 10;

// Key for a flow label that is used to enforce fairness amongst requests in a workload. If not specified, requests within a workload of the same priority are admitted in a FIFO manner.
string fairness_label_key = 11;
}

// _AIMD Load Scheduler_ uses a Gradient Controller to throttle the token rate based on the deviation of the signal from the setpoint.
Expand Down
4 changes: 2 additions & 2 deletions api/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ deps:
- remote: buf.build
owner: envoyproxy
repository: envoy
commit: 39f01805b8754956a78bc77bda4c3761
digest: shake256:a7e7c7675618056879597d6205e394e85b63b71fd1766818042e6fd9b5c4fd623bede2784a9c635dced61fb40a22610812f164ed40c7a0cecbe50c0ecc76952d
commit: 10791366aeb94287b5f8b62d1be8ec2e
digest: shake256:193299dfe4b65518327fccde2953e05969f23919eaabd68e8ad73bf3a88465620749671b1db7f76de02d38cba6d9a4b19ad947f7ab987de353c3333e683452ca
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
Expand Down
1,146 changes: 579 additions & 567 deletions api/gen/proto/go/aperture/policy/language/v1/flowcontrol.pb.go

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions blueprints/gen/jsonschema/_definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3595,6 +3595,10 @@
"description": "This field allows you to override the default HTTP status code (`503 Service Unavailable`) that is returned when a request is denied.\n\n",
"x-go-tag-default": "ServiceUnavailable"
},
"fairness_label_key": {
"description": "Key for a flow label that is used to enforce fairness amongst requests in a workload. If not specified, requests within a workload of the same priority are admitted in a FIFO manner.",
"type": "string"
},
"priority_label_key": {
"description": "Key for a flow label that can be used to override the default priority for this flow.\nThe value associated with this key must be a valid number. Higher numbers means higher priority.\nIf this parameter is not provided, the priority for the flow will be determined by the matched workload's priority.",
"type": "string"
Expand Down
6 changes: 6 additions & 0 deletions blueprints/gen/v1/scheduler.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
withDeniedResponseStatusCodeMixin(denied_response_status_code):: {
denied_response_status_code+: denied_response_status_code,
},
withFairnessLabelKey(fairness_label_key):: {
fairness_label_key: fairness_label_key,
},
withFairnessLabelKeyMixin(fairness_label_key):: {
fairness_label_key+: fairness_label_key,
},
withPriorityLabelKey(priority_label_key):: {
priority_label_key: priority_label_key,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,26 +193,4 @@ function(datasourceName, policyName, componentID, extraFilters={})
),
];

local legendFormat = '{{ instance }} - {{ policy_name }}';
local row10 = [
barGaugePanel(
'WFQ Scheduler Flows',
datasourceName,
'avg(wfq_flows_total{%(filters)s})' % { filters: stringFilters },
x=0,
h=6,
w=12,
legendFormat=legendFormat
),
barGaugePanel(
'WFQ Scheduler Heap Requests',
datasourceName,
'avg(wfq_requests_total{%(filters)s})' % { filters: stringFilters },
x=12,
h=6,
w=12,
legendFormat=legendFormat
),
];

[row1, row2, row3, row4, row5, row6, row7, row8, row9, row10]
[row1, row2, row3, row4, row5, row6, row7, row8, row9]
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,9 @@ definitions:
This field allows you to override the default HTTP status code (`503 Service Unavailable`) that is returned when a request is denied.

x-go-tag-default: ServiceUnavailable
fairness_label_key:
description: Key for a flow label that is used to enforce fairness amongst requests in a workload. If not specified, requests within a workload of the same priority are admitted in a FIFO manner.
type: string
priority_label_key:
description: |-
Key for a flow label that can be used to override the default priority for this flow.
Expand Down
3 changes: 3 additions & 0 deletions docs/content/assets/openapiv2/aperture.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4728,6 +4728,9 @@ definitions:
This field allows you to override the default HTTP status code (`503 Service Unavailable`) that is returned when a request is denied.

x-go-tag-default: ServiceUnavailable
fairness_label_key:
description: Key for a flow label that is used to enforce fairness amongst requests in a workload. If not specified, requests within a workload of the same priority are admitted in a FIFO manner.
type: string
priority_label_key:
description: |-
Key for a flow label that can be used to override the default priority for this flow.
Expand Down
14 changes: 14 additions & 0 deletions docs/content/reference/configuration/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@

<!-- vale on -->

Desired Load multiplier is the ratio of desired token rate to the incoming token

Check warning on line 198 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L198

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'Desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'Desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 198, "column": 1}}}, "severity": "WARNING"}
rate.

</dd>
Expand Down Expand Up @@ -470,7 +470,7 @@

<!-- vale on -->

Desired Load multiplier is the ratio of desired token rate to the incoming token

Check warning on line 473 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L473

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'Desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'Desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 473, "column": 1}}}, "severity": "WARNING"}

Check warning on line 473 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L473

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 473, "column": 41}}}, "severity": "WARNING"}
rate.

</dd>
Expand Down Expand Up @@ -730,7 +730,7 @@

<!-- vale on -->

Desired Load multiplier is the ratio of desired token rate to the incoming token

Check warning on line 733 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L733

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'Desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'Desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 733, "column": 1}}}, "severity": "WARNING"}

Check warning on line 733 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L733

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 733, "column": 41}}}, "severity": "WARNING"}
rate.

</dd>
Expand Down Expand Up @@ -1042,7 +1042,7 @@
Signals are mapped to Boolean values as follows:

- Zero is treated as false.
- Any non-zero is treated as true.

Check warning on line 1045 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L1045

[RedHat.Hyphens] Use 'nonzero' rather than 'non-zero'.
Raw output
{"message": "[RedHat.Hyphens] Use 'nonzero' rather than 'non-zero'.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 1045, "column": 7}}}, "severity": "WARNING"}
- Invalid inputs are considered unknown.

:::note
Expand Down Expand Up @@ -1717,7 +1717,7 @@

A signal can also have a special **Invalid** value. It's usually used to
communicate that signal does not have a meaningful value at the moment, for
example, [PromQL](#prom-q-l) emits such a value if it cannot execute a query.

Check warning on line 1720 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L1720

[RedHat.TermsWarnings] Consider using 'run', 'issue', 'start', or 'enter' rather than 'execute' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'run', 'issue', 'start', or 'enter' rather than 'execute' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 1720, "column": 62}}}, "severity": "WARNING"}
Components know when their input signals are invalid and can act accordingly.
They can either propagate the invalid signal, by making their output itself
invalid (for example, [ArithmeticCombinator](#arithmetic-combinator)) or use
Expand Down Expand Up @@ -4219,9 +4219,9 @@
$$

Note the additional `optimize` signal, that can be used to "nudge" the
controller into desired idle state.

Check warning on line 4222 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L4222

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 4222, "column": 17}}}, "severity": "WARNING"}

The output can be _optionally_ clamped to desired range using `max` and `min`

Check warning on line 4224 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L4224

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 4224, "column": 43}}}, "severity": "WARNING"}
input.

<dl>
Expand Down Expand Up @@ -4385,7 +4385,7 @@

<!-- vale on -->

Computed desired value of the control variable.

Check warning on line 4388 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L4388

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 4388, "column": 10}}}, "severity": "WARNING"}

</dd>
</dl>
Expand Down Expand Up @@ -4574,7 +4574,7 @@
<!-- vale on -->

Resets the holder output to the current input signal when reset signal is valid
and non-zero.

Check warning on line 4577 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L4577

[RedHat.Hyphens] Use 'nonzero' rather than 'non-zero'.
Raw output
{"message": "[RedHat.Hyphens] Use 'nonzero' rather than 'non-zero'.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 4577, "column": 5}}}, "severity": "WARNING"}

</dd>
</dl>
Expand Down Expand Up @@ -5008,7 +5008,7 @@

<!-- vale on -->

Resets the integrator output to zero when reset signal is valid and non-zero.

Check warning on line 5011 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L5011

[RedHat.Hyphens] Use 'nonzero' rather than 'non-zero'.
Raw output
{"message": "[RedHat.Hyphens] Use 'nonzero' rather than 'non-zero'.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 5011, "column": 69}}}, "severity": "WARNING"}
Reset also resets the max and min constraints.

</dd>
Expand Down Expand Up @@ -6415,7 +6415,7 @@
It takes a signal and a setpoint as inputs and uses the PID algorithm to compute
proportional (proportional to the magnitude of error), integral (proportional to
accumulation of error), and derivative (proportional to how fast the signal is
changing) terms which are summed up to get a desired output.

Check warning on line 6418 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L6418

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 6418, "column": 46}}}, "severity": "WARNING"}

<!-- vale off -->

Expand Down Expand Up @@ -6502,7 +6502,7 @@

<!-- vale on -->

The desired setpoint for the signal

Check warning on line 6505 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L6505

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 6505, "column": 5}}}, "severity": "WARNING"}

</dd>
<dt>signal</dt>
Expand Down Expand Up @@ -6653,7 +6653,7 @@
- The parameter must cover whole segment.
- Additionally, path template can end with `/*` wildcard to match arbitrary
number of trailing segments (0 or more).
- Multiple consecutive `/` are ignored, as well as trailing `/`.

Check warning on line 6656 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L6656

[RedHat.TermsWarnings] Consider using 'and' rather than 'as well as' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'and' rather than 'as well as' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 6656, "column": 41}}}, "severity": "WARNING"}
- Parametrized path segments must come after static segments.
- `*`, if present, must come last.
- Most specific template "wins" (`/foo` over `/{}` and `/{}` over `/*`).
Expand Down Expand Up @@ -6846,7 +6846,7 @@

<!-- vale on -->

The number of replicas that are desired.

Check warning on line 6849 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L6849

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 6849, "column": 33}}}, "severity": "WARNING"}

</dd>
</dl>
Expand Down Expand Up @@ -7594,7 +7594,7 @@

<!-- vale on -->

Desired Load multiplier is the ratio of desired token rate to the incoming token

Check warning on line 7597 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L7597

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'Desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'Desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 7597, "column": 1}}}, "severity": "WARNING"}

Check warning on line 7597 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L7597

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 7597, "column": 41}}}, "severity": "WARNING"}
rate.

</dd>
Expand Down Expand Up @@ -8805,6 +8805,20 @@
This field allows you to override the default HTTP status code
(`503 Service Unavailable`) that is returned when a request is denied.

</dd>
<dt>fairness_label_key</dt>
<dd>

<!-- vale off -->

(string)

<!-- vale on -->

Key for a flow label that is used to enforce fairness amongst requests in a

Check failure on line 8818 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L8818

[RedHat.TermsErrors] Use 'among' rather than 'amongst'.
Raw output
{"message": "[RedHat.TermsErrors] Use 'among' rather than 'amongst'.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 8818, "column": 55}}}, "severity": "ERROR"}
workload. If not specified, requests within a workload of the same priority are
admitted in a FIFO manner.

</dd>
<dt>priority_label_key</dt>
<dd>
Expand Down Expand Up @@ -8895,7 +8909,7 @@
<!-- vale on -->

Workload defines a class of flows that preferably have similar properties such
as response latency and desired priority.

Check warning on line 8912 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L8912

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 8912, "column": 25}}}, "severity": "WARNING"}

<dl>
<dt>label_matcher</dt>
Expand Down Expand Up @@ -9137,7 +9151,7 @@
The _Signal Generator_ component generates a smooth and continuous signal by
following a sequence of specified steps. Each step has two parameters:

- `target_output`: The desired output value at the end of the step.

Check warning on line 9154 in docs/content/reference/configuration/spec.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content/reference/configuration/spec.md#L9154

[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.
Raw output
{"message": "[RedHat.TermsWarnings] Consider using 'needed' or 'required' rather than 'desired' unless updating existing content that uses the term.", "location": {"path": "docs/content/reference/configuration/spec.md", "range": {"start": {"line": 9154, "column": 24}}}, "severity": "WARNING"}
- `duration`: The time it takes for the signal to change linearly from the
previous step's `target_output` to the current step's `target_output`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ This document describes the Prometheus metrics generated by Aperture Agents.

| Name | Type | Labels | Unit | Description |
| ----------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------- | --------------------------------------------------------------------------------- |
| wfq_flows_total | Gauge | agent_group, instance, job, process_uuid, policy_name, policy_hash, component_id | count (no unit) | A gauge that tracks the number of flows in the WFQScheduler |
| wfq_requests_total | Gauge | agent_group, instance, job, process_uuid, policy_name, policy_hash, component_id | count (no unit) | A gauge that tracks the number of queued requests in the WFQScheduler |
| token_bucket_lm_ratio | Gauge | agent_group, instance, job, process_uuid, policy_name, policy_hash, component_id | percentage | A gauge that tracks the load multiplier |
| token_bucket_fill_rate | Gauge | agent_group, instance, job, process_uuid, policy_name, policy_hash, component_id | tokens/s | A gauge that tracks the fill rate of token bucket |
| token_bucket_capacity_total | Gauge | agent_group, instance, job, process_uuid, policy_name, policy_hash, component_id | count (no unit) | A gauge that tracks the capacity of token bucket |
Expand Down
3 changes: 3 additions & 0 deletions docs/gen/policy/policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3804,6 +3804,9 @@ definitions:
This field allows you to override the default HTTP status code (`503 Service Unavailable`) that is returned when a request is denied.

x-go-tag-default: ServiceUnavailable
fairness_label_key:
description: Key for a flow label that is used to enforce fairness amongst requests in a workload. If not specified, requests within a workload of the same priority are admitted in a FIFO manner.
type: string
priority_label_key:
description: |-
Key for a flow label that can be used to override the default priority for this flow.
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/buger/jsonparser v1.1.1
github.com/buraksezer/olric v0.0.0-00010101000000-000000000000
github.com/cenkalti/backoff/v4 v4.2.1
github.com/cespare/xxhash v1.1.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/clarketm/json v1.17.1
github.com/containerd/cgroups v1.1.0
Expand Down
4 changes: 0 additions & 4 deletions pkg/metrics/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ const (
// RejectedTokensMetricName - total work measured in tokens of all rejected requests.
RejectedTokensMetricName = "rejected_tokens_total"

// WFQFlowsMetricName - weighted fair queuing number of flows gauge.
WFQFlowsMetricName = "wfq_flows_total"
// WFQRequestsMetricName - weighted fair queuing number of requests gauge.
WFQRequestsMetricName = "wfq_requests_total"
// TokenBucketLMMetricName - a gauge that tracks the load multiplier.
TokenBucketLMMetricName = "token_bucket_lm_ratio"
// TokenBucketFillRateMetricName - a gauge that tracks the fill rate of token bucket.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ type Factory struct {
registry status.Registry

// WFQ Metrics.
wfqFlowsGaugeVec *prometheus.GaugeVec
wfqRequestsGaugeVec *prometheus.GaugeVec

incomingTokensCounterVec *prometheus.CounterVec
acceptedTokensCounterVec *prometheus.CounterVec
rejectedTokensCounterVec *prometheus.CounterVec
Expand All @@ -69,20 +66,6 @@ func newFactory(
registry: reg,
}

wsFactory.wfqFlowsGaugeVec = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: metrics.WFQFlowsMetricName,
Help: "A gauge that tracks the number of flows in the WFQScheduler",
},
MetricLabelKeys,
)
wsFactory.wfqRequestsGaugeVec = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: metrics.WFQRequestsMetricName,
Help: "A gauge that tracks the number of queued requests in the WFQScheduler",
},
MetricLabelKeys,
)
wsFactory.incomingTokensCounterVec = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: metrics.IncomingTokensMetricName,
Expand Down Expand Up @@ -170,15 +153,7 @@ func newFactory(
OnStart: func(_ context.Context) error {
var merr error

err := prometheusRegistry.Register(wsFactory.wfqFlowsGaugeVec)
if err != nil {
merr = multierr.Append(merr, err)
}
err = prometheusRegistry.Register(wsFactory.wfqRequestsGaugeVec)
if err != nil {
merr = multierr.Append(merr, err)
}
err = prometheusRegistry.Register(wsFactory.incomingTokensCounterVec)
err := prometheusRegistry.Register(wsFactory.incomingTokensCounterVec)
if err != nil {
merr = multierr.Append(merr, err)
}
Expand Down Expand Up @@ -220,14 +195,6 @@ func newFactory(
OnStop: func(_ context.Context) error {
var merr error

if !prometheusRegistry.Unregister(wsFactory.wfqFlowsGaugeVec) {
err := fmt.Errorf("failed to unregister wfq_flows metric")
merr = multierr.Append(merr, err)
}
if !prometheusRegistry.Unregister(wsFactory.wfqRequestsGaugeVec) {
err := fmt.Errorf("failed to unregister wfq_requests metric")
merr = multierr.Append(merr, err)
}
if !prometheusRegistry.Unregister(wsFactory.incomingTokensCounterVec) {
err := fmt.Errorf("failed to unregister incoming_tokens_total metric")
merr = multierr.Append(merr, err)
Expand Down Expand Up @@ -303,16 +270,6 @@ type SchedulerMetrics struct {

// NewSchedulerMetrics creates a new SchedulerMetrics instance.
func (wsFactory *Factory) NewSchedulerMetrics(metricLabels prometheus.Labels) (*SchedulerMetrics, error) {
wfqFlowsGauge, err := wsFactory.wfqFlowsGaugeVec.GetMetricWith(metricLabels)
if err != nil {
return nil, fmt.Errorf("%w: failed to get wfq flows gauge", err)
}

wfqRequestsGauge, err := wsFactory.wfqRequestsGaugeVec.GetMetricWith(metricLabels)
if err != nil {
return nil, fmt.Errorf("%w: failed to get wfq requests gauge", err)
}

incomingTokensCounter, err := wsFactory.incomingTokensCounterVec.GetMetricWith(metricLabels)
if err != nil {
return nil, err
Expand All @@ -329,8 +286,6 @@ func (wsFactory *Factory) NewSchedulerMetrics(metricLabels prometheus.Labels) (*
}

wfqMetrics := &scheduler.WFQMetrics{
FlowsGauge: wfqFlowsGauge,
HeapRequestsGauge: wfqRequestsGauge,
IncomingTokensCounter: incomingTokensCounter,
AcceptedTokensCounter: acceptedTokensCounter,
RejectedTokensCounter: rejectedTokensCounter,
Expand All @@ -351,16 +306,7 @@ func (wsFactory *Factory) NewSchedulerMetrics(metricLabels prometheus.Labels) (*
func (sm *SchedulerMetrics) Delete() error {
var merr error

// Remove metrics from metric vectors
deleted := sm.wsFactory.wfqFlowsGaugeVec.Delete(sm.metricLabels)
if !deleted {
merr = multierr.Append(merr, errors.New("failed to delete wfq_flows gauge from its metric vector"))
}
deleted = sm.wsFactory.wfqRequestsGaugeVec.Delete(sm.metricLabels)
if !deleted {
merr = multierr.Append(merr, errors.New("failed to delete wfq_requests gauge from its metric vector"))
}
deleted = sm.wsFactory.incomingTokensCounterVec.Delete(sm.metricLabels)
deleted := sm.wsFactory.incomingTokensCounterVec.Delete(sm.metricLabels)
if !deleted {
merr = multierr.Append(merr, errors.New("failed to delete incoming_tokens_total counter from its metric vector"))
}
Expand Down Expand Up @@ -615,7 +561,14 @@ func (s *Scheduler) Decide(ctx context.Context, labels labels.Labels) (*flowcont
reqCtx = timeoutCtx
}

req := scheduler.NewRequest(matchedWorkloadLabel, tokens, invPriority)
var fairnessLabel string
if s.proto.FairnessLabelKey != "" {
if val, ok := labels.Get(s.proto.FairnessLabelKey); ok {
fairnessLabel = val
}
}

req := scheduler.NewRequest(matchedWorkloadLabel, fairnessLabel, tokens, invPriority)

accepted, remaining, current, reqID := s.scheduler.Schedule(reqCtx, req)

Expand Down
4 changes: 3 additions & 1 deletion pkg/scheduler/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package scheduler

// Request is metadata for request in a flow that is to be allowed or dropped based on controlled delay and queue limits.
type Request struct {
WorkloadLabel string // for identifying workload
FairnessLabel string // for enforcing fairness
Tokens float64 // tokens (e.g. expected latency or complexity) for this request
InvPriority float64 // larger values represent higher priority
}

// NewRequest calculates the inverse priority and returns a new Request.
func NewRequest(fairnessLabel string, tokens float64, invPriority float64) *Request {
func NewRequest(workloadLabel, fairnessLabel string, tokens float64, invPriority float64) *Request {
return &Request{
WorkloadLabel: workloadLabel,
FairnessLabel: fairnessLabel,
Tokens: tokens,
InvPriority: invPriority,
Expand Down
Loading
Loading