Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions cmd/fabric-api/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,13 @@ func runGateway(parent context.Context, o *gatewayOptions) error {
if err != nil {
return fmt.Errorf("--aggregate-budgets: %w", err)
}
admission.Metrics = metrics
metrics.RegisterAdmission(admission, limit.KernelClock)
executor.PrincipalSlots, executor.PrincipalQueue = o.limits.PrincipalSlots, o.limits.PrincipalQueue
go admission.Authority.Watch(ctx, limit.WatchInterval)
}
serviceSwitch := &gateway.ServiceSwitch{}
metrics.RegisterService(serviceSwitch)
if o.serviceConfigMap != "" {
go serviceSwitch.Watch(ctx, mgr.GetAPIReader(), o.namespace, o.serviceConfigMap, gateway.ServiceSwitchInterval)
}
Expand Down Expand Up @@ -360,6 +363,7 @@ func runGateway(parent context.Context, o *gatewayOptions) error {
service := &gateway.Service{
Cell: o.cell,
Switch: serviceSwitch,
Metrics: metrics,
Allowlist: allowlist,
Elected: debug.Elected,
Leader: debug,
Expand Down
9 changes: 5 additions & 4 deletions cmd/fabric-api/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func runNode(parent context.Context, o *nodeOptions) error {
return fmt.Errorf("--search-source must be index or frr, not %q", o.searchSource)
}

permits, err := nodePermits(o, creds)
permits, err := nodePermits(o, creds, metrics)
if err != nil {
return err
}
Expand Down Expand Up @@ -275,8 +275,8 @@ func runNode(parent context.Context, o *nodeOptions) error {

// nodePermits returns the probe permit checker the flags select, or nil
// without --probe-permits. Its permits are refused while the kernel clock
// is unsynchronised.
func nodePermits(o *nodeOptions, creds *identity.Credentials) (*node.Permits, error) {
// is unsynchronised, which metrics reports.
func nodePermits(o *nodeOptions, creds *identity.Credentials, metrics *node.Metrics) (*node.Permits, error) {
switch {
case !o.probePermits && (o.requirePermits || o.gatewayAddress != ""):
return nil, errors.New("--require-probe-permits and --gateway-address need --probe-permits")
Expand All @@ -295,8 +295,9 @@ func nodePermits(o *nodeOptions, creds *identity.Credentials) (*node.Permits, er
}
p := &node.Permits{
Reader: reader, Namespace: o.namespace, LeaseName: o.gatewayLease, Require: o.requirePermits,
Started: time.Now(), Clock: limit.KernelClock,
Started: time.Now(), Clock: limit.KernelClock, Metrics: metrics,
}
metrics.RegisterClock(limit.KernelClock)
if o.gatewayAddress != "" {
conn, err := grpc.NewClient(o.gatewayAddress,
grpc.WithTransportCredentials(credentials.NewTLS(creds.ClientConfig(identity.Gateway(o.cell)))),
Expand Down
93 changes: 93 additions & 0 deletions config/monitoring/prometheusrule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,99 @@ spec:
description: >-
Prometheus cannot scrape {{ $labels.job }} on {{ $labels.pod }}, so the other fabric-api alerts cannot
fire for it.
# The leader's aggregate limiter admits nothing during its 125 s
# recovery hold after a start, failover or failed Lease read; ten
# minutes without a ready replica is no ordinary hold. The series
# exist only on gateways run with --aggregate-budgets, and the max
# over replicas keeps a leader change from resetting the alert.
- alert: FabricAPILimiterUnavailable
expr: >-
max without (pod, instance, state) (fabric_api_gateway_limiter_state{job="fabric-api-gateway",state="ready"}) == 0
for: 10m
labels:
severity: warning
service: galactic
team: connect
annotations:
summary: "fabric-api's aggregate limiter in {{ $labels.namespace }} has admitted nothing for 10 minutes"
runbook_url: "https://github.com/datum-cloud/infra/blob/main/docs/runbooks/galactic/README.md#fabricapilimiterunavailable"
description: >-
No fabric-api gateway replica in {{ $labels.namespace }} has had a ready aggregate limiter for 10
minutes, so every probe in the cell, operator, FabricQuery and Looking Glass alike, is refused with
LimiterUnavailable; route lookups and BGP summaries are unaffected. The leader cannot read its
election Lease, keeps losing the election, or its clock is unsynchronised
(fabric_api_gateway_clock_synchronized). Check the leader's logs and Lease.
# The limiter and each node's permit check trust the clock only while
# the kernel reports it synchronised within 500 ms. The gauges exist
# only where that trust is in use: a gateway with --aggregate-budgets
# and a node with --probe-permits.
- alert: FabricAPIClockUnsynchronized
expr: >-
fabric_api_gateway_clock_synchronized{job="fabric-api-gateway"} == 0
or
fabric_api_node_clock_synchronized{job="fabric-api-node"} == 0
for: 10m
labels:
severity: warning
service: galactic
team: connect
annotations:
summary: "fabric-api on {{ $labels.pod }} runs on an unsynchronised clock"
runbook_url: "https://github.com/datum-cloud/infra/blob/main/docs/runbooks/galactic/README.md#fabricapiclockunsynchronized"
description: >-
The kernel clock under {{ $labels.pod }} has not been synchronised within 500 ms for 10 minutes. A
gateway on it admits no probe and no Looking Glass request; a node on it refuses every probe permit.
Check the host's time daemon (chrony, ntpd, systemd-timesyncd or Talos timed).
# More than half of at least 20 Looking Glass requests in 30 minutes
# were refused by a budget, a queue or the limiter. Throttling is the
# limits working; sustained throttling means the cell's limits or the
# service's own admission need attention. Disabled or idle cells never
# fire.
- alert: FabricAPIServiceThrottled
expr: >-
(
sum without (pod, instance, operation, reason) (increase(fabric_api_gateway_service_requests_total{job="fabric-api-gateway",reason=~"Throttled|QueueFull|LimiterUnavailable"}[30m]))
/
sum without (pod, instance, operation, reason) (increase(fabric_api_gateway_service_requests_total{job="fabric-api-gateway"}[30m]))
) > 0.5
and
sum without (pod, instance, operation, reason) (increase(fabric_api_gateway_service_requests_total{job="fabric-api-gateway"}[30m])) >= 20
for: 15m
labels:
severity: warning
service: galactic
team: connect
annotations:
summary: "Most Looking Glass requests in {{ $labels.namespace }} are refused by the cell's limits"
runbook_url: "https://github.com/datum-cloud/infra/blob/main/docs/runbooks/galactic/README.md#fabricapiservicethrottled"
description: >-
{{ $value | humanizePercentage }} of Looking Glass requests in {{ $labels.namespace }} in the last 30
minutes were refused with Throttled, QueueFull or LimiterUnavailable. fabric_api_gateway_admission_refusals_total
names the scope (cell, project, destination or queue) that refused them.
# More than half of at least 10 Looking Glass requests that reached
# execution in 30 minutes produced no router result: every selected
# router failed, none was selectable, or the leader lost the election.
- alert: FabricAPIServiceExecutionFailing
expr: >-
(
sum without (pod, instance, operation, reason) (increase(fabric_api_gateway_service_requests_total{job="fabric-api-gateway",reason=~"ExecutionFailed|NoNodesAvailable|OwnershipLost|Internal"}[30m]))
/
sum without (pod, instance, operation, reason) (increase(fabric_api_gateway_service_requests_total{job="fabric-api-gateway",reason=~"Succeeded|PartialResults|ExecutionFailed|NoNodesAvailable|OwnershipLost|Internal"}[30m]))
) > 0.5
and
sum without (pod, instance, operation, reason) (increase(fabric_api_gateway_service_requests_total{job="fabric-api-gateway",reason=~"Succeeded|PartialResults|ExecutionFailed|NoNodesAvailable|OwnershipLost|Internal"}[30m])) >= 10
for: 15m
labels:
severity: warning
service: galactic
team: connect
annotations:
summary: "Most Looking Glass requests in {{ $labels.namespace }} return no router result"
runbook_url: "https://github.com/datum-cloud/infra/blob/main/docs/runbooks/galactic/README.md#fabricapiserviceexecutionfailing"
description: >-
{{ $value | humanizePercentage }} of the Looking Glass requests {{ $labels.namespace }} executed in the
last 30 minutes ended ExecutionFailed, NoNodesAvailable, OwnershipLost or Internal.
fabric_api_gateway_service_router_outcomes_total gives each router's failure or omission reason.
# The Galactic Edge foundation: galactic-controller --edge (job
# galactic-controller, port 9184) exports attachment, route and service
# state from every replica's cache, so the state rules take the max over
Expand Down
128 changes: 128 additions & 0 deletions config/monitoring/tests/rules-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2459,3 +2459,131 @@ tests:
description: >-
Prometheus cannot scrape galactic-edge on galactic-edge-abcde, so the other Galactic Edge alerts
cannot fire for it.

# No ready limiter in a cell for 10m fires; a cell whose leader serves an
# ordinary 2-minute recovery hold after a failover, across two replicas,
# does not.
- interval: 30s
input_series:
- series: 'fabric_api_gateway_limiter_state{job="fabric-api-gateway",namespace="galactic-system",pod="gw-a",state="ready"}'
values: "0x40"
- series: 'fabric_api_gateway_limiter_state{job="fabric-api-gateway",namespace="galactic-system",pod="gw-a",state="recovering"}'
values: "1x40"
- series: 'fabric_api_gateway_limiter_state{job="fabric-api-gateway",namespace="galactic-system",pod="gw-b",state="ready"}'
values: "0x40"
- series: 'fabric_api_gateway_limiter_state{job="fabric-api-gateway",namespace="fabric-lab",pod="gw-c",state="ready"}'
values: "1x10 0x30"
- series: 'fabric_api_gateway_limiter_state{job="fabric-api-gateway",namespace="fabric-lab",pod="gw-d",state="ready"}'
values: "0x14 1x26"
alert_rule_test:
- eval_time: 9m
alertname: FabricAPILimiterUnavailable
exp_alerts: []
- eval_time: 11m
alertname: FabricAPILimiterUnavailable
exp_alerts:
- exp_labels:
severity: warning
service: galactic
team: connect
job: fabric-api-gateway
namespace: galactic-system
exp_annotations:
summary: "fabric-api's aggregate limiter in galactic-system has admitted nothing for 10 minutes"
runbook_url: "https://github.com/datum-cloud/infra/blob/main/docs/runbooks/galactic/README.md#fabricapilimiterunavailable"
description: >-
No fabric-api gateway replica in galactic-system has had a ready aggregate limiter for 10
minutes, so every probe in the cell, operator, FabricQuery and Looking Glass alike, is refused with
LimiterUnavailable; route lookups and BGP summaries are unaffected. The leader cannot read its
election Lease, keeps losing the election, or its clock is unsynchronised
(fabric_api_gateway_clock_synchronized). Check the leader's logs and Lease.

# An unsynchronised gateway clock for 10m fires; a node whose clock lost
# sync for 2 minutes does not.
- interval: 30s
input_series:
- series: 'fabric_api_gateway_clock_synchronized{job="fabric-api-gateway",namespace="galactic-system",pod="gw-a"}'
values: "0x30"
- series: 'fabric_api_node_clock_synchronized{job="fabric-api-node",node="dfw-worker",pod="fabric-router-a"}'
values: "1x10 0x4 1x16"
alert_rule_test:
- eval_time: 11m
alertname: FabricAPIClockUnsynchronized
exp_alerts:
- exp_labels:
severity: warning
service: galactic
team: connect
job: fabric-api-gateway
namespace: galactic-system
pod: gw-a
exp_annotations:
summary: "fabric-api on gw-a runs on an unsynchronised clock"
runbook_url: "https://github.com/datum-cloud/infra/blob/main/docs/runbooks/galactic/README.md#fabricapiclockunsynchronized"
description: >-
The kernel clock under gw-a has not been synchronised within 500 ms for 10 minutes. A
gateway on it admits no probe and no Looking Glass request; a node on it refuses every probe permit.
Check the host's time daemon (chrony, ntpd, systemd-timesyncd or Talos timed).

# Two thirds of a busy cell's Looking Glass requests throttled fires; a
# cell refusing as large a share of too few requests does not.
- interval: 30s
input_series:
- series: 'fabric_api_gateway_service_requests_total{job="fabric-api-gateway",namespace="galactic-system",pod="gw-a",operation="Ping",reason="Throttled"}'
values: "0+2x60"
- series: 'fabric_api_gateway_service_requests_total{job="fabric-api-gateway",namespace="galactic-system",pod="gw-a",operation="Ping",reason="Succeeded"}'
values: "0+1x60"
- series: 'fabric_api_gateway_service_requests_total{job="fabric-api-gateway",namespace="fabric-lab",pod="gw-c",operation="Ping",reason="QueueFull"}'
values: "0 1 2 3 4 5 6 7 8 9 10x50"
alert_rule_test:
- eval_time: 15m
alertname: FabricAPIServiceThrottled
exp_alerts: []
- eval_time: 25m
alertname: FabricAPIServiceThrottled
exp_alerts:
- exp_labels:
severity: warning
service: galactic
team: connect
job: fabric-api-gateway
namespace: galactic-system
exp_annotations:
summary: "Most Looking Glass requests in galactic-system are refused by the cell's limits"
runbook_url: "https://github.com/datum-cloud/infra/blob/main/docs/runbooks/galactic/README.md#fabricapiservicethrottled"
description: >-
66.67% of Looking Glass requests in galactic-system in the last 30
minutes were refused with Throttled, QueueFull or LimiterUnavailable. fabric_api_gateway_admission_refusals_total
names the scope (cell, project, destination or queue) that refused them.

# Every executed request failing fires; a cell where a quarter fail, and
# one whose requests were all refused before execution, do not.
- interval: 30s
input_series:
- series: 'fabric_api_gateway_service_requests_total{job="fabric-api-gateway",namespace="galactic-system",pod="gw-a",operation="Ping",reason="ExecutionFailed"}'
values: "0+1x60"
- series: 'fabric_api_gateway_service_requests_total{job="fabric-api-gateway",namespace="galactic-system",pod="gw-a",operation="Ping",reason="Succeeded"}'
values: "0x60"
- series: 'fabric_api_gateway_service_requests_total{job="fabric-api-gateway",namespace="fabric-lab",pod="gw-c",operation="Ping",reason="PartialResults"}'
values: "0+3x60"
- series: 'fabric_api_gateway_service_requests_total{job="fabric-api-gateway",namespace="fabric-lab",pod="gw-c",operation="Ping",reason="ExecutionFailed"}'
values: "0+1x60"
- series: 'fabric_api_gateway_service_requests_total{job="fabric-api-gateway",namespace="fabric-edge",pod="gw-e",operation="Ping",reason="Throttled"}'
values: "0+5x60"
alert_rule_test:
- eval_time: 25m
alertname: FabricAPIServiceExecutionFailing
exp_alerts:
- exp_labels:
severity: warning
service: galactic
team: connect
job: fabric-api-gateway
namespace: galactic-system
exp_annotations:
summary: "Most Looking Glass requests in galactic-system return no router result"
runbook_url: "https://github.com/datum-cloud/infra/blob/main/docs/runbooks/galactic/README.md#fabricapiserviceexecutionfailing"
description: >-
100% of the Looking Glass requests galactic-system executed in the
last 30 minutes ended ExecutionFailed, NoNodesAvailable, OwnershipLost or Internal.
fabric_api_gateway_service_router_outcomes_total gives each router's failure or omission reason.
26 changes: 22 additions & 4 deletions internal/fabric/gateway/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Admission struct {
Buckets *limit.Buckets
Attempts *limit.Attempts
Authority *limit.Authority
// Metrics, when set, counts refusals and charged packets.
Metrics *Metrics
// Now returns the current time; nil selects time.Now.
Now func() time.Time

Expand Down Expand Up @@ -80,8 +82,10 @@ func (a *Admission) openStream(project string) (func(), error) {
a.projectStreams = map[string]int{}
}
if a.streams >= a.Limits.Streams || a.projectStreams[project] >= a.Limits.ProjectStreams {
return nil, errcode.Retry(errcode.QueueFull, "the live stream limit is reached", string(limit.ScopeQueue),
err := errcode.Retry(errcode.QueueFull, "the live stream limit is reached", string(limit.ScopeQueue),
time.Second)
a.Metrics.refused(project, err)
return nil, err
}
a.streams++
a.projectStreams[project]++
Expand All @@ -95,6 +99,13 @@ func (a *Admission) openStream(project string) (func(), error) {
}, nil
}

// liveStreams returns the live service streams.
func (a *Admission) liveStreams() int {
a.mu.Lock()
defer a.mu.Unlock()
return a.streams
}

// admit admits a service request before its discovery: it confirms the
// election, charges the cell's and the project's request tokens, registers
// the attempt key and opens a live stream. It returns the epoch's context
Expand All @@ -103,16 +114,20 @@ func (a *Admission) admit(
ctx context.Context, caller identity.ID, req *servicev1.RunDiagnosticRequest,
) (context.Context, func(), error) {
project := req.GetProjectId()
refuse := func(err error) (context.Context, func(), error) {
a.Metrics.refused(project, err)
return nil, nil, err
}
_, epochCtx, err := a.Authority.Check(ctx)
if err != nil {
return nil, nil, err
return refuse(err)
}
if err := a.Buckets.ChargeRequest(project, a.now()); err != nil {
return nil, nil, err
return refuse(err)
}
if err := a.Attempts.Register(attemptKey(caller, req), requestDigest(req), req.GetExpiresAt().AsTime(),
a.now()); err != nil {
return nil, nil, err
return refuse(err)
}
closeStream, err := a.openStream(project)
if err != nil {
Expand All @@ -137,6 +152,7 @@ func (a *Admission) permit(
) (*fabricv1.ProbePermit, error) {
epoch, _, err := a.Authority.Check(ctx)
if err != nil {
a.Metrics.refused(principal, err)
return nil, err
}
dst, err := query.ResolvedProbe(q)
Expand All @@ -145,8 +161,10 @@ func (a *Admission) permit(
}
cost := probeCost(q.Type)
if err := a.Buckets.ChargePackets(principal, dst, cost, a.now()); err != nil {
a.Metrics.refused(principal, err)
return nil, err
}
a.Metrics.charged(principal, cost)
return &fabricv1.ProbePermit{
Id: newPermitID(),
Epoch: epoch.String(),
Expand Down
Loading
Loading