cluster

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 37 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cluster contains the Raft consensus layer: the FSM that materializes data class A into state.db and the node that runs Raft (ADR 0005, 0012).

Index

Constants

View Source
const (
	// APITokenScopeTenant is the only scope of an API token; other scopes need a later ADR.
	APITokenScopeTenant = "tenant"
	// MinAPITokenLifetime and MaxAPITokenLifetime bound expires_at_ms minus issued_at_ms.
	MinAPITokenLifetime = time.Hour
	MaxAPITokenLifetime = 366 * 24 * time.Hour
	// MaxAPITokensPerTenant is the fixed limit of tokens per tenant (not a plan limit).
	MaxAPITokensPerTenant = 50
	// APITokenRetentionAfterExpiry is how long expired tokens stay listed before PruneAudit removes them.
	APITokenRetentionAfterExpiry = 30 * 24 * time.Hour
)

API token rules (ADR 0031, section 1). The API and the auth middleware use these constants; the FSM enforces them when it applies a token.

View Source
const (
	CodeConflict    = "conflict"
	CodeNotFound    = "not_found"
	CodeInvalid     = "invalid"
	CodeUnsupported = "unsupported"
	// CodeNotEnabled rejects a command before it is proposed because not all
	// voters support its version yet (ADR 0018). It is never stored.
	CodeNotEnabled = "not_enabled"
)

Stable codes of deterministic command errors. They are stored in the dedup table, so a retry returns the same error.

View Source
const (
	DefaultSnapshotThreshold = 8192
	DefaultTrailingLogs      = 20000
	DefaultSnapshotInterval  = 2 * time.Minute
)

Defaults from ADR 0005 point 5.

View Source
const (
	ConnectivityReasonReference = "reference"
	ConnectivityReasonDeviation = "deviation"
)

Reasons of an impaired connectivity (ADR 0022).

View Source
const (
	SessionRotated = "rotated"
	SessionReused  = "reused"
	SessionRevoked = "revoked"
	SessionExpired = "expired"
)

Session command results.

View Source
const AuditCommandLevel = 9

AuditCommandLevel is the command level of API tokens, the audit log, the PruneAudit command and Batch (ADR 0031). Below it those commands are rejected and the FSM writes no audit entries, so that voters of different versions do not diverge (ADR 0018).

View Source
const BaseCommandLevel = 2

BaseCommandLevel is the command level of a cluster that never stored one: the first release with the feature gate (ADR 0018). Commands up to this version are always allowed.

View Source
const CodeLimitExceeded = "limit_exceeded"

CodeLimitExceeded rejects a command that would exceed a tenant limit (FA-TEN-04). The API answers 403.

View Source
const CommandVersion = 10

CommandVersion is the highest Command.version this binary can apply. It is raised together with a feature gate (FA-CLU-12). Version 2 adds RegisterNode and SetNodeHealth (ADR 0017), version 3 SetNodeConnectivity (ADR 0022), version 4 ClearMonitorFlapping and the flapping and channel-failed alerts (ADR 0023), version 5 the degraded-mode commands and the sender view of alerts (ADR 0024), version 6 the system alerts, incarnation records and checkpoints (ADR 0025), version 7 BindTenantOrg (ADR 0027), version 8 the tenant and plan commands and limit enforcement (ADR 0029), version 9 API tokens, the audit log and Batch (ADR 0031), version 10 RegisterProbe and the probe registry columns (ADR 0034, 0035).

View Source
const DefaultKeyRotation = 365 * 24 * time.Hour

DefaultKeyRotation is the automatic data key rotation period (ADR 0011).

View Source
const DefaultTenantID = "default"

DefaultTenantID is the only tenant in local auth mode (E13, FA-AUTH-01).

View Source
const (
	// DegradedCommandLevel is the command level that enables the degraded-mode
	// commands and the stored command time (ADR 0024).
	DegradedCommandLevel = 5
)

The degraded mode (FA-ALR-10, FA-ALR-11, FA-UPT-07, ADR 0024) is FSM behavior of command level 5 and up. Below that level the commands are rejected and no command time is stored, so mixed-version clusters keep identical fingerprints.

View Source
const (
	// FlappingCommandLevel is the command level that enables the rules of this
	// file and the events flapping and channel_failed (ADR 0023).
	FlappingCommandLevel = 4
)

Flapping (FA-ALR-06, ADR 0023) and the alert of a failed channel (FA-ALR-05) are FSM behavior of command level 4 and up. Below that level the FSM behaves exactly as before, so every voter computes the same state.

View Source
const MaxBatchOps = 500

MaxBatchOps is the largest number of operations of one Batch (ADR 0031, section 3).

View Source
const MinCommandLevel = 2

MinCommandLevel is the oldest cluster command level whose log entries this binary can still apply (ADR 0018). A cluster below it must first be updated through the previous minor version.

View Source
const OIDCCommandLevel = 7

OIDCCommandLevel is the command level of BindTenantOrg (ADR 0027). Below that level the command is rejected and nothing is written, so that a cluster with voters of different versions does not diverge (ADR 0018).

View Source
const ProbeCommandLevel = 10

ProbeCommandLevel is the command level of RegisterProbe and the probe registry columns (ADR 0034, ADR 0035).

View Source
const RecoveryRevokeFile = "recovery-revoke.json"

RecoveryRevokeFile is written by "admin recover" into the data directory. It lists the members the recovery dropped; the recovered node revokes them once it leads again, so they cannot rejoin with stale state (ADR 0019).

View Source
const SystemAlertCommandLevel = 6

SystemAlertCommandLevel is the command level of system alerts, the incarnation record and the FSM checkpoint (FA-OBS-01, FA-REP-06, FA-CLU-07, ADR 0025). Below that level the commands are rejected and nothing is written, so mixed-version clusters do not diverge.

View Source
const SystemTenantRequestID = "bootstrap:tenant:" + store.SystemTenantID

SystemTenantRequestID makes the creation of the system tenant idempotent: a retry or a second leader is deduplicated by the FSM.

View Source
const TenantAdminCommandLevel = 8

TenantAdminCommandLevel is the command level of the tenant and plan commands and of limit enforcement (ADR 0029). Below it the commands are rejected and PutEntity does not check limits, so that voters of different versions apply the same log the same way (ADR 0018).

Variables

View Source
var (
	// ErrNotApplied means the command is certainly not in the log (e.g. this
	// node is not the leader); retrying is safe.
	ErrNotApplied = errors.New("command not applied")
	// ErrUnknownOutcome means the command may or may not have been committed;
	// a retry with the same request ID is safe thanks to deduplication.
	ErrUnknownOutcome = errors.New("command outcome unknown")
)

Errors returned by Node.Apply (ADR 0012 A8).

View Source
var ErrFSMHalted = errors.New("state machine halted")

ErrFSMHalted is returned for every command after the FSM stopped because of an infrastructure error (ADR 0012 A7, FA-CLU-13).

View Source
var ErrIncompatibleVersion = errors.New("incompatible command version")

ErrIncompatibleVersion means this binary cannot run the cluster state: its command version is older than the cluster's command level, or the level is older than MinCommandLevel (ADR 0018).

View Source
var ErrInvalidCommand = errors.New("invalid command")

ErrInvalidCommand is matched by CommandErrors with the codes invalid and unsupported.

View Source
var ErrMembershipChanged = errors.New("cluster membership changed concurrently")

ErrMembershipChanged means the configuration changed since prevIndex.

View Source
var ErrNodeRunning = errors.New("the node is still running: stop it first (the Raft log is locked)")

ErrNodeRunning means that a running node holds the Raft log (ADR 0019).

Functions

func EffectiveCommandLevel

func EffectiveCommandLevel(stored uint32) uint32

EffectiveCommandLevel returns the command level the cluster may use, given the level stored in state.db (0 if unset).

func EnsureDefaultTenant

func EnsureDefaultTenant(ctx context.Context, n *Node, state store.State) error

EnsureDefaultTenant waits for a leader and, if this node leads and the default tenant does not exist yet, creates it through Raft.

func EnsureSecretKey

func EnsureSecretKey(ctx context.Context, n *Node, state store.State, kek *secrets.KEK) error

EnsureSecretKey creates the first data key if none is active. Only the leader proposes it; followers receive it through Raft.

func ErrorClassFromProto

func ErrorClassFromProto(c pb.ErrorClass) string

ErrorClassFromProto is the inverse of ErrorClassToProto; UNSPECIFIED maps to "".

func ErrorClassToProto

func ErrorClassToProto(class string) pb.ErrorClass

ErrorClassToProto maps a checker error class ("dns", "http_status", …) to the protobuf enum; unknown classes map to UNSPECIFIED.

func HasState

func HasState(dataDir string) (bool, error)

HasState reports whether dataDir holds Raft state (log or snapshot), so the node belongs to a cluster already (FA-CLU-02). Call it before Start.

func LimitViolation

func LimitViolation(lim tenant.Limits, planID string, usage store.TenantUsage, kind pb.EntityKind, create bool, interval, oldInterval int) error

LimitViolation returns a CodeLimitExceeded error if creating or changing an object of the kind would break the limits; nil otherwise. The API calls it before proposing, the FSM again when applying (ADR 0029).

func NewAckAlertDelivery

func NewAckAlertDelivery(a store.AlertDelivery, attempt uint32, o DeliveryOutcome) *pb.Command

NewAckAlertDelivery builds the command that records a delivery attempt.

func NewBatch

func NewBatch(requestID, tenantID string, actor *pb.Actor, ops []*pb.BatchOp) *pb.Command

NewBatch builds the command that applies ops atomically to the monitors of tenantID (ADR 0031, section 3). The operations carry their expected revisions and optional audit hints.

func NewBindTenantOrg

func NewBindTenantOrg(tenantID, orgID string) *pb.Command

NewBindTenantOrg builds the command that binds a tenant to an identity-provider organization (ADR 0027). The request ID is derived from the binding, so a retry of the same binding is deduplicated by the FSM.

func NewCheckpoint

func NewCheckpoint() *pb.Command

NewCheckpoint builds the command that asks every replica for the fingerprint of its state at this log index (ADR 0025). It changes no replicated data.

func NewClearMonitorFlapping

func NewClearMonitorFlapping(tenantID, monitorID string, expectedSinceMs int64) *pb.Command

NewClearMonitorFlapping builds the command that ends the flapping period started at expectedSinceMs (ADR 0023). The request ID is derived from the period, so a retry of the same period is deduplicated, and a later period gets its own ID.

func NewCreateAPIToken

func NewCreateAPIToken(requestID, tenantID string, actor *pb.Actor, t *pb.CreateAPIToken) *pb.Command

NewCreateAPIToken builds the command that stores an API token of tenantID (ADR 0031). The caller passes the actor, a signed-in user, and the request ID of the API request, so that retries are deduplicated.

func NewCreateSession

func NewCreateSession(requestID, tenantID, userID, tokenHash, familyID string, expiresMs int64) *pb.Command

NewCreateSession builds the command that starts a token family.

func NewDeleteChannel

func NewDeleteChannel(requestID, tenantID, channelID string) *pb.Command

NewDeleteChannel builds a command that deletes a channel.

func NewDeleteJoinToken

func NewDeleteJoinToken(requestID, tokenID string) *pb.Command

NewDeleteJoinToken builds a platform-level command that deletes a join token.

func NewDeleteMaintenanceWindow

func NewDeleteMaintenanceWindow(requestID, tenantID, id string) *pb.Command

NewDeleteMaintenanceWindow builds a command that deletes a maintenance window.

func NewDeleteMonitor

func NewDeleteMonitor(requestID, tenantID, monitorID string) *pb.Command

NewDeleteMonitor builds a command that deletes a monitor.

func NewDeleteUser

func NewDeleteUser(requestID, tenantID, userID string) *pb.Command

NewDeleteUser builds a command that deletes a user and its sessions.

func NewEnqueueReminder

func NewEnqueueReminder(tenantID, monitorID string, downSinceMs int64, n uint32) *pb.Command

NewEnqueueReminder builds the command for the n-th repeated DOWN alert.

func NewProvisionTenant

func NewProvisionTenant(tenantID, name, planID, orgID string, maxTenants int) *pb.Command

NewProvisionTenant builds the command that creates the tenant of an organization on its first login (ADR 0029). The request ID is unique per attempt: the FSM, not the dedup table, makes parallel first logins end at one tenant, and a rejection is not cached for later attempts.

func NewPruneAudit

func NewPruneAudit(auditBeforeMs, tokensExpiredBeforeMs int64) *pb.Command

NewPruneAudit builds the system command that removes audit entries older than auditBeforeMs and API tokens that expired before tokensExpiredBeforeMs (ADR 0031). The request ID is derived from the audit cut-off, so a retry of the same run is deduplicated.

func NewPutChannel

func NewPutChannel(requestID, tenantID, channelID string, doc ChannelDocument, expectedRevision uint64) (*pb.Command, error)

NewPutChannel builds a command that creates (expectedRevision 0) or replaces a channel.

func NewPutClusterCA

func NewPutClusterCA(requestID, fingerprint string, doc CADocument) (*pb.Command, error)

NewPutClusterCA builds a platform-level command that stores the cluster CA. The ID is the CA fingerprint (pki.Fingerprint).

func NewPutJoinToken

func NewPutJoinToken(requestID, tokenID string, doc JoinTokenDocument) (*pb.Command, error)

NewPutJoinToken builds a command that creates a join token. Tenant-bound probe tokens carry the tenant ID on the command envelope for audit scoping.

func NewPutMaintenanceWindow

func NewPutMaintenanceWindow(requestID, tenantID, id string, doc MaintenanceDocument, expectedRevision uint64) (*pb.Command, error)

NewPutMaintenanceWindow builds a command that creates (expectedRevision 0) or replaces a maintenance window.

func NewPutMonitor

func NewPutMonitor(requestID, tenantID, monitorID string, doc MonitorDocument, expectedRevision uint64) (*pb.Command, error)

NewPutMonitor builds a command that creates (expectedRevision 0) or replaces a monitor.

func NewPutSecretKey

func NewPutSecretKey(requestID, keyID string, doc SecretKeyDocument) (*pb.Command, error)

NewPutSecretKey builds a platform-level command that stores a data key.

func NewPutSigningKey

func NewPutSigningKey(requestID, kid string, doc SigningKeyDocument) (*pb.Command, error)

NewPutSigningKey builds a platform-level command that stores or retires a signing key.

func NewPutSystemTenant

func NewPutSystemTenant(requestID string) (*pb.Command, error)

NewPutSystemTenant builds the command that creates the system tenant (ADR 0025). The FSM accepts the reserved ID only from the system actor, so the command carries it.

func NewPutTenant

func NewPutTenant(requestID, tenantID string, doc TenantDocument) (*pb.Command, error)

NewPutTenant builds the system command that creates a tenant at bootstrap. From command level 8 the FSM accepts PutEntity for tenants only from the system actor (ADR 0029); the admin API uses CreateTenant and UpdateTenant.

func NewPutUser

func NewPutUser(requestID, tenantID, userID string, doc UserDocument, expectedRevision uint64) (*pb.Command, error)

NewPutUser builds a command that creates (expectedRevision 0) or replaces a user.

func NewRecordIncarnation

func NewRecordIncarnation(nodeID, incarnation string) *pb.Command

NewRecordIncarnation builds the command that stores the incarnation a node reported (FA-REP-06, ADR 0025). The request ID is random for the same reason as in NewSetSystemAlert: a node may return to an older incarnation.

func NewRecordMonitorHistory

func NewRecordMonitorHistory(tenantID, monitorID string, expected store.MonitorStatus, fromMs, toMs int64, changes []HistoryChange) *pb.Command

NewRecordMonitorHistory builds the command that replaces the history of monitorID in [fromMs, toMs) with the re-evaluated changes (FA-UPT-07, ADR 0024). The request ID is derived from the gap, so a retry is deduplicated.

func NewRedeemJoinToken

func NewRedeemJoinToken(requestID, tokenID, secretHash, nodeID string) *pb.Command

NewRedeemJoinToken builds the command that uses up a join token for a node.

func NewRegisterNode

func NewRegisterNode(requestID string, n store.Node) *pb.Command

NewRegisterNode builds the command that registers a node or updates its registry entry (ADR 0017). The node proposes it itself.

func NewRegisterProbe added in v0.0.4

func NewRegisterProbe(requestID string, n store.Node) *pb.Command

NewRegisterProbe builds the command that registers a probe or updates its metadata in the registry (ADR 0034, ADR 0035). Only a voter proposes it.

func NewReportDegradedAlerts

func NewReportDegradedAlerts(nodeID string, alerts []store.DegradedAlert) *pb.Command

NewReportDegradedAlerts builds the command that stores the alerts a node sent while it was degraded (FA-ALR-10, ADR 0024). The request ID is derived from the first and last local ID of the block, so a retry of the same block is deduplicated. The FSM stores entries idempotently, so a different block with the same IDs cannot change state either.

func NewResolveUnconfirmedAlerts

func NewResolveUnconfirmedAlerts(verdicts []AlertVerdict) *pb.Command

NewResolveUnconfirmedAlerts builds the command that stores the verdicts on unconfirmed alerts (FA-ALR-10, ADR 0024). The request ID is random, as the verdicts of a batch are judged once: a repeated verdict is skipped by the FSM.

func NewRevokeAPIToken

func NewRevokeAPIToken(requestID, tenantID string, actor *pb.Actor, id string) *pb.Command

NewRevokeAPIToken builds the command that deletes the API token id of tenantID (ADR 0031).

func NewRevokeCertificate

func NewRevokeCertificate(requestID, serial, nodeID string, notAfterMs int64) *pb.Command

NewRevokeCertificate builds the command that adds a node certificate to the revocation list. The serial is pki.SerialString of the certificate.

func NewRevokeFamily

func NewRevokeFamily(requestID, familyID string) *pb.Command

NewRevokeFamily builds the logout command.

func NewRevokeNode

func NewRevokeNode(requestID, nodeID string) *pb.Command

NewRevokeNode builds the platform-level command that revokes all certificates of a node issued so far (FA-PKI-04). The command time is the revocation time.

func NewRevokeTenantProbe added in v0.0.4

func NewRevokeTenantProbe(requestID, tenantID, nodeID string) *pb.Command

NewRevokeTenantProbe builds a tenant-scoped command that revokes a private probe owned by tenantID (ADR 0035). The FSM verifies ownership and USER actor.

func NewRevokeUserSessions

func NewRevokeUserSessions(requestID, tenantID, userID string) *pb.Command

NewRevokeUserSessions builds the command that ends all sessions of a user.

func NewRotateSession

func NewRotateSession(oldHash, newHash string, expiresMs int64) *pb.Command

NewRotateSession builds the refresh command. The request ID covers both hashes: retrying the same refresh is deduplicated, while presenting the old token again (with a new random successor) is applied and detected as reuse.

func NewSetFeatureLevel

func NewSetFeatureLevel(requestID string, level uint32) *pb.Command

NewSetFeatureLevel builds the command that raises the cluster command level to level (ADR 0018). The leader proposes it once all voters support the level.

func NewSetMonitorState

func NewSetMonitorState(c StateChange) *pb.Command

NewSetMonitorState builds the command for a status change. The request ID is derived from the change, so retrying an unknown outcome cannot apply it twice.

func NewSetNodeConnectivity

func NewSetNodeConnectivity(nodeID string, impaired bool, reason string) *pb.Command

NewSetNodeConnectivity builds the command that records a connectivity change of a node (ADR 0022). Only the leader proposes it, and only on a change.

The request ID is random per command, not derived from the change: the FSM deduplicates request IDs for 24 hours, so a repeated flip of the same node would otherwise return the stored result without being applied. A retry of the same command keeps its request ID, because the caller reuses the command.

func NewSetNodeHealth

func NewSetNodeHealth(requestID, nodeID string, healthy bool) *pb.Command

NewSetNodeHealth builds the command that records a health change of a node (ADR 0017). Only the leader proposes it, and only when the value changes.

func NewSetProbeAlert added in v0.0.4

func NewSetProbeAlert(tenantID, probeID string, active bool, senderNodeID string) *pb.Command

NewSetProbeAlert builds the command that records a change of an offline alert for a private probe (FA-PRB-06, ADR 0035). Only the leader proposes it. The request ID is random per command so repeated transitions within the dedup window are still applied.

func NewSetSystemAlert

func NewSetSystemAlert(kind, subject string, active bool, level int, details json.RawMessage) *pb.Command

NewSetSystemAlert builds the command that records a change of a system alert (ADR 0025). Only the leader proposes it, and only on a change. The request ID is random per command: an alert may change back and forth within the dedup retention, and each change must still be applied.

func RemoveRecoveryRevoke

func RemoveRecoveryRevoke(dataDir string) error

RemoveRecoveryRevoke deletes the file; a missing file is no error.

func RotateSecretKey

func RotateSecretKey(ctx context.Context, n *Node, kek *secrets.KEK, requestID string) error

RotateSecretKey generates a new data key on the leader, wraps it with the master key and stores it through Raft. It becomes the active key; older keys stay available for decryption.

func RunAuditPrune

func RunAuditPrune(ctx context.Context, n *Node, state store.State, retention time.Duration, log *slog.Logger)

RunAuditPrune proposes PruneAudit once per hour on the leader, from command level AuditCommandLevel on (ADR 0031, section 2). The cut-offs are computed from the leader clock; the FSM checks them against the command time. It runs until ctx ends.

func RunKeyRotation

func RunKeyRotation(ctx context.Context, n *Node, state store.State, kek *secrets.KEK, maxAge, interval time.Duration, log *slog.Logger)

RunKeyRotation rotates the data key on the leader once the active key is older than maxAge. It checks every interval until ctx ends.

func ValidAPITokenName

func ValidAPITokenName(name string) bool

ValidAPITokenName reports whether name is a valid token name: 1 to 64 runes, no control characters, and not only whitespace.

func ValidAPITokenRole

func ValidAPITokenRole(role string) bool

ValidAPITokenRole reports whether role may be given to an API token. A token never carries platform-admin (ADR 0031, section 1).

func WriteRecoveryRevoke

func WriteRecoveryRevoke(dataDir string, r RecoveryRevoke) error

WriteRecoveryRevoke stores r atomically with mode 0600.

Types

type APITokenResult

type APITokenResult struct {
	ID string `json:"id"`
}

APITokenResult is the result of CreateAPIToken and RevokeAPIToken.

type AlertPayload

type AlertPayload struct {
	// AlertID is stable across retries, so receivers can deduplicate.
	AlertID        string `json:"alertId"`
	TenantID       string `json:"tenantId"`
	MonitorID      string `json:"monitorId"`
	MonitorName    string `json:"monitorName"`
	MonitorType    string `json:"monitorType"`
	Event          string `json:"event"`
	Status         string `json:"status"`
	PreviousStatus string `json:"previousStatus"`
	SinceMs        int64  `json:"sinceMs"`
	Cause          string `json:"cause,omitempty"`
	ErrorClass     string `json:"errorClass,omitempty"`
	IncidentID     string `json:"incidentId,omitempty"`
	// Reminder counts repeated DOWN alerts; 0 for the change itself.
	Reminder  int  `json:"reminder,omitempty"`
	Confirmed bool `json:"confirmed"`
	// Flapping is true when a flapping period starts and false at its end;
	// both use Event "flapping". ChangeCount is the number of status changes
	// in the flapping window (start) or during the period (end) (ADR 0023).
	Flapping    bool `json:"flapping,omitempty"`
	ChangeCount int  `json:"changeCount,omitempty"`
	// ChannelID, ChannelName and ChannelError describe the failed channel of
	// an Event "channel_failed" (FA-ALR-05). ChannelError is masked like the
	// channel's last_error and holds no secrets.
	ChannelID    string `json:"channelId,omitempty"`
	ChannelName  string `json:"channelName,omitempty"`
	ChannelError string `json:"channelError,omitempty"`
	// Sender is the view of the node that sent the alert (FA-ALR-11, ADR 0024).
	// Set from command level 5 on.
	Sender *AlertSender `json:"sender,omitempty"`
	// Verdict is "confirmed" or "false_alarm" for a correction of an alert sent
	// while the cluster was degraded (FA-ALR-10, ADR 0024).
	Verdict string `json:"verdict,omitempty"`
	// System describes a system alert, Event "system" (FA-OBS-01, ADR 0025).
	// Such an alert has no monitor and goes to the system tenant only.
	System *SystemAlertInfo `json:"system,omitempty"`
	// Probe describes a private probe alert, Event "probe_offline" (FA-PRB-06,
	// ADR 0035). Such an alert has no monitor and goes to the owning tenant.
	Probe *ProbeAlertInfo `json:"probe,omitempty"`
}

AlertPayload is the content of an alert, built by the FSM from replicated data and stored with every outbox entry (ADR 0014).

type AlertSender

type AlertSender struct {
	NodeID          string   `json:"nodeId"`
	ReachableVoters int      `json:"reachableVoters"`
	TotalVoters     int      `json:"totalVoters"`
	Reporters       []string `json:"reporters,omitempty"`
	Confirmed       bool     `json:"confirmed"`
}

AlertSender describes which part of the cluster the sending node saw when it decided the alert (FA-ALR-11, ADR 0024).

type AlertVerdict

type AlertVerdict struct {
	NodeID  string
	LocalID int64
	Verdict string
	Notify  bool
}

AlertVerdict is the judgement of the leader on one unconfirmed alert (ADR 0024). Notify tells the FSM whether to send a notification for it.

type ApplyResult

type ApplyResult struct {
	Index uint64
	// Result is the command-specific result as JSON (e.g. a PutResult).
	Result json.RawMessage
	// Duplicate is true if the request ID had been applied before; Result and
	// Err are then those of the first application.
	Duplicate bool
	// Err is a *CommandError for deterministic rejections, or ErrFSMHalted.
	Err error
}

ApplyResult is what FSM.Apply returns for a log entry.

type BatchResult

type BatchResult struct {
	Results []PutResult `json:"results"`
}

BatchResult is the result of Batch: one PutResult per operation, in the order of the operations.

type BindTenantOrgResult

type BindTenantOrgResult struct {
	TenantID string `json:"tenant_id"`
	OrgID    string `json:"org_id"`
}

BindTenantOrgResult is the result of BindTenantOrg (ADR 0027).

type CADocument

type CADocument struct {
	ClusterID string `json:"clusterId"`
	CertDER   []byte `json:"certDer"`
	KeyEnc    string `json:"keyEnc"`
}

CADocument is the JSON document of the cluster CA inside PutEntity. CertDER is the DER certificate, KeyEnc the encrypted PKCS#8 key (ADR 0011).

type ChannelDocument

type ChannelDocument struct {
	Name            string            `json:"name"`
	Kind            string            `json:"kind"`
	URLEnc          string            `json:"urlEnc"`
	WebhookMethod   string            `json:"webhookMethod,omitempty"`
	WebhookHeaders  map[string]string `json:"webhookHeaders,omitempty"`
	WebhookTemplate string            `json:"webhookTemplate,omitempty"`
	Events          []string          `json:"events"`
	IsDefault       bool              `json:"isDefault,omitempty"`
}

ChannelDocument is the JSON document of a notification channel. The leader encrypts URLEnc and the header values before proposing (ADR 0011, 0014); the FSM rejects plaintext.

type CommandError

type CommandError struct {
	Code    string
	Message string
}

CommandError is a deterministic rejection of a command: every replica rejects it the same way, so it is a result, not a failure of the node.

func (*CommandError) Error

func (e *CommandError) Error() string

func (*CommandError) Is

func (e *CommandError) Is(target error) bool

Is lets callers use errors.Is with the store and cluster sentinel errors.

type Config

type Config struct {
	NodeID string
	// Advertise is the stable host:port of this node and its Raft server address.
	Advertise string
	DataDir   string
	// Timeout is HeartbeatTimeout and ElectionTimeout (ADR 0012 A6).
	Timeout time.Duration

	SnapshotThreshold uint64
	TrailingLogs      uint64
	SnapshotInterval  time.Duration

	// Transport defaults to an in-memory transport on Advertise, which is all a
	// single-member cluster in tests needs; voters use the mTLS cluster port.
	Transport raft.Transport

	// Join marks a node that joins an existing cluster: without Raft state it
	// waits to be added instead of bootstrapping (FA-CLU-02/03, ADR 0005 6).
	Join bool

	// MaxCommandVersion overrides CommandVersion; for tests only (ADR 0018).
	// 0 means CommandVersion.
	MaxCommandVersion uint32

	// Clock is the wall clock of this node: it stamps IssuedAtMs and the time
	// of heartbeat observations. Nil means time.Now. Tests give each node its
	// own skewed clock (ADR 0020). Raft's own timing stays on the monotonic clock.
	Clock func() time.Time

	// Forwarder sends commands of followers to the leader. Nil means that a
	// follower does not forward and returns ErrNotApplied (FA-CLU-05).
	Forwarder Forwarder

	Logger *slog.Logger
	// RaftLogLevel and RaftLogJSON configure the library logger.
	RaftLogLevel string
	RaftLogJSON  bool
}

Config configures a Raft node.

type DegradedReportResult

type DegradedReportResult struct {
	Count int `json:"count"`
}

DegradedReportResult is the result of ReportDegradedAlerts.

type DeliveryOutcome

type DeliveryOutcome struct {
	Delivered bool
	Permanent bool
	GiveUp    bool
	// Error must already be cleaned of secrets.
	Error         string
	NextAttemptMs int64
}

DeliveryOutcome is the result of one delivery attempt, decided by the leader.

type FSM

type FSM struct {
	// contains filtered or unexported fields
}

FSM applies Raft log entries to state.db. Apply is deterministic: it reads neither the clock nor a random source; time and IDs come with the command.

func NewFSM

func NewFSM(ctx context.Context, state StateStore, log *slog.Logger, onFatal func(error)) (*FSM, error)

NewFSM creates the FSM. onFatal is called once when the FSM halts; the caller is expected to stop the node (FA-CLU-13).

func (*FSM) AppliedIndex

func (f *FSM) AppliedIndex() uint64

AppliedIndex returns the last log index reflected in state.db.

func (*FSM) Apply

func (f *FSM) Apply(l *raft.Log) any

Apply implements raft.FSM.

func (*FSM) Changes

func (f *FSM) Changes() <-chan struct{}

Changes returns a channel that receives a value after state.db changed. Several changes may be coalesced into one signal.

func (*FSM) Healthy

func (f *FSM) Healthy() error

Healthy returns the halt reason, or nil while the FSM works.

func (*FSM) LastCheckpoint

func (f *FSM) LastCheckpoint() (index uint64, fingerprint string)

LastCheckpoint returns the log index and the fingerprint of the last checkpoint this FSM applied since it started, or 0 and "" if none (ADR 0025).

func (*FSM) OnStateChange

func (f *FSM) OnStateChange(fn func(StateEvent))

OnStateChange registers fn to receive StateEvents. A later call replaces the previous observer; nil removes it.

Events are only delivered for entries applied after registration. Entries applied before fn is registered (for example during Start, while Raft replays its log) are not delivered, so a listener must read the current state from the store when it connects. fn is called synchronously from Apply after the commit and must not block.

func (*FSM) Restore

func (f *FSM) Restore(rc io.ReadCloser) error

Restore implements raft.FSM: it replaces state.db with the snapshot.

func (*FSM) Snapshot

func (f *FSM) Snapshot() (raft.FSMSnapshot, error)

Snapshot implements raft.FSM. The copy is taken in Persist, concurrently with further Apply calls; that "fuzzy" snapshot is safe because the applied index is part of the copy (ADR 0012 A1).

func (*FSM) SubscribeChanges added in v0.0.4

func (f *FSM) SubscribeChanges() (<-chan struct{}, func())

SubscribeChanges returns a dedicated coalesced change channel and an unsubscribe function, so multiple consumers (scheduler, probe gateway) do not steal signals from each other.

type FeatureLevelResult

type FeatureLevelResult struct {
	Level uint32 `json:"level"`
}

FeatureLevelResult is the result of SetFeatureLevel: the command level of the cluster after the command (ADR 0018).

type Forwarder

type Forwarder interface {
	Forward(ctx context.Context, leaderAddress string, cmd *pb.Command) (ApplyResult, error)
}

Forwarder delivers a command to the leader at leaderAddress and returns the leader's result. Error contract, which Node.Apply relies on:

  • ErrNotApplied: the leader certainly did not append the command; the caller may retry at once or later.
  • ErrUnknownOutcome: the command may or may not be committed; retrying with the same request ID is safe thanks to deduplication.
  • a *CommandError: the leader rejected the command deterministically. It is returned both in ApplyResult.Err and as the error.

type HistoryChange

type HistoryChange struct {
	SinceMs    int64
	Status     store.MonitorStatus
	IncidentID string
	Cause      string
	ErrorClass string
}

HistoryChange is one status change of a re-evaluated gap (FA-UPT-07, ADR 0024). IncidentID, Cause and ErrorClass are required or used for DOWN changes only.

type JoinTokenDocument

type JoinTokenDocument struct {
	SecretHash string `json:"secretHash"`
	Role       string `json:"role"`
	TenantID   string `json:"tenantId,omitempty"`
	ExpiresMs  int64  `json:"expiresMs"`
}

JoinTokenDocument is the JSON document of a join token inside PutEntity. SecretHash is pki.HashSecret of the secret; the secret itself never arrives.

type JoinTokenResult

type JoinTokenResult struct {
	Role     string `json:"role"`
	TenantID string `json:"tenantId"`
}

JoinTokenResult is the result of RedeemJoinToken: the role and tenant the joining node is granted.

type MaintenanceDocument

type MaintenanceDocument struct {
	Name        string                    `json:"name"`
	Description string                    `json:"description,omitempty"`
	MonitorIDs  []string                  `json:"monitorIds,omitempty"`
	Schedule    store.MaintenanceSchedule `json:"schedule"`
	Active      bool                      `json:"active"`
}

MaintenanceDocument is the JSON document of a maintenance window inside PutEntity (FA-MNT-01). Monitor IDs are normalized by the store; the FSM checks only the structure of the schedule, time zones and cron expressions are checked by the API before the command is proposed.

type Member

type Member struct {
	ID      string
	Address string
	Voter   bool
}

Member is a server of the Raft configuration.

type MonitorDocument

type MonitorDocument struct {
	Name                  string           `json:"name"`
	Description           string           `json:"description,omitempty"`
	Type                  string           `json:"type"`
	Config                json.RawMessage  `json:"config,omitempty"`
	IntervalSeconds       int              `json:"intervalSeconds"`
	TimeoutSeconds        int              `json:"timeoutSeconds"`
	Retries               int              `json:"retries"`
	RecoveryThreshold     int              `json:"recoveryThreshold"`
	ResendIntervalMinutes int              `json:"resendIntervalMinutes"`
	Assignment            store.Assignment `json:"assignment"`
	ConsensusPolicy       string           `json:"consensusPolicy"`
	Tags                  []string         `json:"tags,omitempty"`
	Paused                bool             `json:"paused,omitempty"`
	// NotificationChannelIDs must name channels of the same tenant (FA-ALR-01).
	NotificationChannelIDs []string `json:"notificationChannelIds,omitempty"`
	// Secrets are ciphertexts by JSON pointer into Config (ADR 0015); the API
	// encrypts them before proposing, the FSM rejects plaintext.
	Secrets map[string]string `json:"secrets,omitempty"`
}

MonitorDocument is the JSON document of a monitor inside PutEntity. It is part of the Raft log, so fields may only be added, never renamed (NFA-MNT-04).

func MonitorDocumentFrom

func MonitorDocumentFrom(m store.Monitor) MonitorDocument

MonitorDocumentFrom returns the document that recreates a stored monitor, e.g. to pause it or to rewrite its secrets. Secrets stay encrypted.

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node runs Raft with the FSM on top of state.db.

func Start

func Start(ctx context.Context, cfg Config, state StateStore, onFatal func(error)) (*Node, error)

Start opens the Raft stores and starts Raft. A node without existing Raft state bootstraps a single-member cluster; a node with state never bootstraps again, whatever its configuration says (FA-CLU-01/02, PF-01).

func (*Node) AddNonvoter

func (n *Node) AddNonvoter(id, address string, prevIndex uint64, timeout time.Duration) (uint64, error)

AddNonvoter adds a server that receives the log but does not vote (or updates its address) and returns the index of the configuration entry.

func (*Node) AddVoter

func (n *Node) AddVoter(id, address string, prevIndex uint64, timeout time.Duration) (uint64, error)

AddVoter promotes a server to voter (or updates the address of a voter).

func (*Node) Apply

func (n *Node) Apply(ctx context.Context, cmd *pb.Command) (ApplyResult, error)

Apply proposes a command and waits until it is applied on this node. On the leader the command is appended directly (ApplyLocal). On a follower it is forwarded to the leader, and the follower waits until its own FSM has applied the result, so a read after a successful Apply sees the command. The caller notices nothing; a retry keeps the request ID, and the FSM deduplicates it (ADR 0012 A8).

Errors: ErrNotApplied if the command certainly did not commit, ErrUnknownOutcome if it may have committed, and a *CommandError if it was rejected.

func (*Node) ApplyLocal

func (n *Node) ApplyLocal(ctx context.Context, cmd *pb.Command) (ApplyResult, error)

ApplyLocal proposes a command on this node, which must be the leader; it never forwards. The leader stamps issued_at_ms, so the FSM never reads the clock (FA-CLU-07). The ClusterService uses it for forwarded commands, so that a forwarded command is not forwarded again.

func (*Node) CommandLevel

func (n *Node) CommandLevel(ctx context.Context) (uint32, error)

CommandLevel returns the command level of the locally applied state (ADR 0018).

func (*Node) FSM

func (n *Node) FSM() *FSM

FSM returns the state machine.

func (*Node) ID

func (n *Node) ID() string

ID returns this node's ID.

func (*Node) IsLeader

func (n *Node) IsLeader() bool

IsLeader reports whether this node currently leads.

func (*Node) LastCheckpoint

func (n *Node) LastCheckpoint() (index uint64, fingerprint string)

LastCheckpoint returns the log index and fingerprint of the last checkpoint this node applied since it started, or 0 and "" if none (ADR 0025).

func (*Node) Leader

func (n *Node) Leader() (address, id string)

Leader returns the address and ID of the current leader ("" if unknown).

func (*Node) MaxCommandVersion

func (n *Node) MaxCommandVersion() uint32

MaxCommandVersion returns the highest Command.version this node applies (ADR 0018): CommandVersion, unless a test overrides it.

func (*Node) Members

func (n *Node) Members() ([]Member, uint64, error)

Members returns the current Raft configuration and its index, which membership changes pass as prevIndex so that a concurrent change makes them fail instead of overwriting it (ADR 0012 A4).

func (*Node) OnHeartbeat

func (n *Node) OnHeartbeat(fn func(peerID string, ok bool, at time.Time))

OnHeartbeat calls fn with the ID of a peer whose heartbeat from the leader failed (ok false) or resumed after failures (ok true), with the time of the observation, until the node shuts down. fn must not block for long; it runs on its own goroutine. Raft emits these observations on the leader only (ADR 0017).

func (*Node) OnPeerResumed

func (n *Node) OnPeerResumed(fn func(peerID string))

OnPeerResumed calls fn with the ID of a peer whose heartbeats resumed after a failure and with the ID of every peer added to the configuration, until the node shuts down. fn must not block for long; it runs on its own goroutine. Raft emits these observations on the leader only, so followers rely on the reconnect of their push streams (ADR 0012 B6).

func (*Node) Ready

func (n *Node) Ready() error

Ready reports whether the node can serve: the FSM works and a leader is known.

func (*Node) RemoveServer

func (n *Node) RemoveServer(id string, prevIndex uint64, timeout time.Duration) (uint64, error)

RemoveServer removes a server from the configuration.

func (*Node) Shutdown

func (n *Node) Shutdown() error

Shutdown hands over leadership if there are other voters, stops Raft and closes the log store (FA-NODE-04).

func (*Node) Snapshot

func (n *Node) Snapshot() error

Snapshot forces a Raft snapshot (used by tests and admin tooling).

func (*Node) Status

func (n *Node) Status() Status

Status returns the current status of this node.

func (*Node) WaitLeader

func (n *Node) WaitLeader(ctx context.Context) error

WaitLeader blocks until the cluster has a leader or ctx ends.

type NodeResult

type NodeResult struct {
	ID                    string `json:"id"`
	Role                  string `json:"role"`
	Healthy               bool   `json:"healthy"`
	HealthChangedMs       int64  `json:"healthChangedMs"`
	ConnectivityImpaired  bool   `json:"connectivityImpaired"`
	ConnectivityReason    string `json:"connectivityReason"`
	ConnectivityChangedMs int64  `json:"connectivityChangedMs"`
	RegisteredMs          int64  `json:"registeredMs"`
	UpdatedMs             int64  `json:"updatedMs"`
}

NodeResult is the result of RegisterNode, SetNodeHealth and SetNodeConnectivity: the registry entry after the command.

type PlanResult

type PlanResult struct {
	PlanID string `json:"plan_id"`
}

PlanResult is the result of the plan commands.

type ProbeAlertInfo added in v0.0.4

type ProbeAlertInfo struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Active bool   `json:"active"`
}

ProbeAlertInfo is the probe part of an AlertPayload (FA-PRB-06, ADR 0035).

type ProbeAlertResult added in v0.0.4

type ProbeAlertResult struct {
	Changed bool `json:"changed"`
}

ProbeAlertResult is the result of SetProbeAlert. Changed is false if the alert already had the active state of the command (or the tenant is suspended).

type PutResult

type PutResult struct {
	ID       string `json:"id"`
	Revision uint64 `json:"revision,omitempty"`
}

PutResult is the result of a PutEntity command.

type RaftInfo

type RaftInfo struct {
	NodeID       string       `json:"nodeId"`
	LastIndex    uint64       `json:"lastIndex"`
	LastTerm     uint64       `json:"lastTerm"`
	AppliedIndex uint64       `json:"appliedIndex"`
	CommandLevel uint32       `json:"commandLevel"`
	Servers      []RaftServer `json:"servers"`
}

RaftInfo is the offline view of a node's Raft state (ADR 0019).

func InspectRaft

func InspectRaft(ctx context.Context, dataDir, nodeID string, state StateStore) (RaftInfo, error)

InspectRaft reads the Raft state of a stopped node without changing it. The latest configuration is read with raft.GetConfiguration, which does not apply log entries: the snapshot is not restored, so the FSM is never called. A running node holds the log lock, which yields ErrNodeRunning.

type RaftServer

type RaftServer struct {
	ID      string `json:"id"`
	Address string `json:"address"`
	Voter   bool   `json:"voter"`
}

RaftServer is a server of the last Raft configuration.

type RecoveryPlan

type RecoveryPlan struct {
	Old []RaftServer `json:"old"`
	New []RaftServer `json:"new"`
	// Removed holds the IDs of all other former members, sorted.
	Removed []string `json:"removed"`
	// Self is this node as listed in Old; New holds it as the only voter.
	Self RaftServer `json:"self"`
}

RecoveryPlan describes a recovery: the configuration before, the one that replaces it, and the members that are dropped (ADR 0019).

func PlanRecovery

func PlanRecovery(info RaftInfo) (RecoveryPlan, error)

PlanRecovery computes the configuration that makes this node the only voter. It fails if this node is not in the last configuration: such a node cannot take over the cluster, and another survivor must be recovered.

func Recover

func Recover(ctx context.Context, dataDir, nodeID string, state StateStore, log *slog.Logger, now time.Time) (RecoveryPlan, string, error)

Recover makes this stopped node the only voter of a new configuration (ADR 0019). It backs up raft/ and state.db into DATA_DIR/recovery-backup-<time>/ before it changes anything, and then runs raft.RecoverCluster. The FSM applies the log entries past the snapshot to state.db. It returns the plan and the backup directory; the backup directory is set even if the recovery fails afterwards.

type RecoveryRevoke

type RecoveryRevoke struct {
	NodeIDs     []string  `json:"nodeIds"`
	RecoveredAt time.Time `json:"recoveredAt"`
}

RecoveryRevoke is the content of RecoveryRevokeFile.

func ReadRecoveryRevoke

func ReadRecoveryRevoke(dataDir string) (RecoveryRevoke, bool, error)

ReadRecoveryRevoke returns the stored list and whether the file exists.

type RevokeNodeResult

type RevokeNodeResult struct {
	RevokedMs int64 `json:"revokedMs"`
}

RevokeNodeResult is the result of a node revocation: the revocation time.

type SecretKeyDocument

type SecretKeyDocument struct {
	WrappedDEK     []byte `json:"wrappedDek"`
	KEKFingerprint string `json:"kekFingerprint"`
	RetiredMs      int64  `json:"retiredMs,omitempty"`
}

SecretKeyDocument is a data encryption key wrapped with the master key (ADR 0011). The leader generates and wraps it; the FSM only stores it.

type SessionResult

type SessionResult struct {
	Status   string `json:"status"`
	UserID   string `json:"userId,omitempty"`
	TenantID string `json:"tenantId,omitempty"`
}

SessionResult is the result of RotateSession. Only SessionRotated means the new token is valid.

type SigningKeyDocument

type SigningKeyDocument struct {
	Alg           string `json:"alg"`
	PublicKey     []byte `json:"publicKey"`
	PrivateKeyEnc string `json:"privateKeyEnc"`
	RetiredMs     int64  `json:"retiredMs,omitempty"`
}

SigningKeyDocument is an access token signing key (FA-AUTH-02).

type StateChange

type StateChange struct {
	TenantID  string
	MonitorID string
	From      store.MonitorStatus
	To        store.MonitorStatus
	SinceMs   int64
	// Incident is required for a change to DOWN.
	Incident *store.Incident
	// Reporters are the nodes of the deciding slot and SenderNodeID the node
	// that proposed the change (ADR 0024). The FSM reads them from level 5 on.
	Reporters    []string
	SenderNodeID string
}

StateChange is a consensus status change decided by the leader.

type StateEvent

type StateEvent struct {
	TenantID  string
	MonitorID string
	Status    store.MonitorStatus
	Confirmed bool
	SinceMs   int64
	// IncidentOpened is the ID of the incident opened with this change (status DOWN), or "".
	IncidentOpened string
	// IncidentResolved is true if an open incident of the monitor was resolved with this change.
	IncidentResolved bool
}

StateEvent describes a committed change of a monitor's consensus status. It is delivered after the transaction committed; it is a notification for local listeners (live stream) and never influences the replicated state.

type StateResult

type StateResult struct {
	Status store.MonitorStatus `json:"status"`
}

StateResult is the result of a SetMonitorState command.

type StateStore

type StateStore interface {
	store.State
	WriteSnapshot(ctx context.Context, w io.Writer) error
	RestoreSnapshot(ctx context.Context, r io.Reader) error
}

StateStore is the storage the FSM materializes into.

type Status

type Status struct {
	NodeID        string
	RaftState     string
	AppliedIndex  uint64
	CommitIndex   uint64
	LastLogIndex  uint64
	LastContactMs int64
	LeaderID      string
	LeaderAddress string
}

Status reports the Raft and replication state (proto GetStatusResponse, ADR 0012 A9).

type SystemAlertInfo

type SystemAlertInfo struct {
	Kind    string          `json:"kind"`
	Subject string          `json:"subject"`
	Active  bool            `json:"active"`
	Level   int             `json:"level"`
	Details json.RawMessage `json:"details"`
}

SystemAlertInfo is the system part of an AlertPayload (ADR 0025).

type SystemAlertResult

type SystemAlertResult struct {
	Changed bool `json:"changed"`
}

SystemAlertResult is the result of SetSystemAlert. Changed is false if the alert already had the active flag and level of the command (a no-op).

type TenantDocument

type TenantDocument struct {
	Name         string          `json:"name"`
	Plan         string          `json:"plan"`
	ZitadelOrgID string          `json:"zitadelOrgId,omitempty"`
	Limits       json.RawMessage `json:"limits,omitempty"`
	Suspended    bool            `json:"suspended,omitempty"`
}

TenantDocument is the JSON document of a tenant inside PutEntity.

type TenantResult

type TenantResult struct {
	TenantID string `json:"tenant_id"`
	// Existing is set when CreateTenant with source auto found the
	// organization already bound and returned that tenant.
	Existing bool `json:"existing,omitempty"`
}

TenantResult is the result of the tenant commands.

type UnconfirmedResolveResult

type UnconfirmedResolveResult struct {
	Resolved int `json:"resolved"`
}

UnconfirmedResolveResult is the result of ResolveUnconfirmedAlerts: how many verdicts were stored. Already judged alerts are skipped and not counted.

type UserDocument

type UserDocument struct {
	Username     string `json:"username"`
	DisplayName  string `json:"displayName,omitempty"`
	PasswordHash string `json:"passwordHash"`
	Role         string `json:"role"`
	Disabled     bool   `json:"disabled,omitempty"`
	// Setup creates the first user; it is rejected once any user exists.
	Setup bool `json:"setup,omitempty"`
}

UserDocument is the JSON document of a local user inside PutEntity.

Jump to

Keyboard shortcuts

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