Documentation
¶
Overview ¶
Package predastore is an S3-compatible object store: a Raft-replicated metadata plane, erasure-coded shard storage, and an S3 gate in front of both. It is the module's whole public surface — Config and LoadConfig for the on-disk configuration, Options and Run to serve a host until the context is cancelled.
One process runs one host: the cluster nodes pinned to it in the configuration, the S3 gate among them. Those nodes talk over an in-process pipe; nodes on other hosts are reached over QUIC. A cluster whose nodes all sit on one host is therefore a single-process deployment, with no code path of its own.
Index ¶
- Constants
- func HostBindAddr(h HostConfig) string
- func NodeBindAddr(h HostConfig, n NodeConfig) string
- func Run(ctx context.Context, opts Options) error
- type AuthEntry
- type Bucket
- type Compaction
- type Config
- type HostConfig
- type HostID
- type IAMConfig
- type NodeConfig
- type NodeID
- type NodeShardCounts
- type NonFullObject
- type Options
- type PolicyRule
- type RS
- type Reaper
- type Repair
- type Role
- type S3
- type ShardPosition
- type ShardReport
- type Status
- type VerifyOptions
Constants ¶
const ( // RoleGate serves the S3 API in front of the cluster. RoleGate = config.RoleGate // RoleBlob stores erasure-coded object shards. RoleBlob = config.RoleBlob // RoleMeta participates in Raft consensus over global state. RoleMeta = config.RoleMeta )
const ( ShardMatch = "match" ShardOlder = "older" ShardNewer = "newer" ShardMissing = "missing" ShardError = "error" )
What a shard position holds, measured against its placement record's epoch.
Variables ¶
This section is empty.
Functions ¶
func HostBindAddr ¶
func HostBindAddr(h HostConfig) string
HostBindAddr is where a host's cluster traffic listens, and NodeBindAddr where a gate serves S3. Both are re-exported because an embedder settling host-local fields has to know which plane it is settling: the S3 address belongs to the gate, and putting it on the host would move raft and blob traffic onto the public interface with it.
func NodeBindAddr ¶
func NodeBindAddr(h HostConfig, n NodeConfig) string
NodeBindAddr resolves a gate's S3 listen address against its host.
Types ¶
type Compaction ¶
type Compaction = config.Compaction
The remaining tables of the configuration file.
type Config ¶
Config is predastore's on-disk configuration.
func LoadConfig ¶
LoadConfig reads and validates a TOML configuration file.
type HostConfig ¶
HostConfig is one machine, as written under [[host]]: a data directory, an address, a TLS identity and the nodes it runs in one process.
type HostID ¶
NodeID and HostID identify the two levels of the cluster. They are distinct types so that a host id cannot be passed where a node id belongs.
type NodeConfig ¶
NodeConfig is a logical role pinned to a host, as written under [[host.node]].
type NodeID ¶
NodeID and HostID identify the two levels of the cluster. They are distinct types so that a host id cannot be passed where a node id belongs.
func MetaNodesOnHost ¶ added in v1.17.0
MetaNodesOnHost returns the meta node ids pinned to host, in id order. A host running no meta node, or an id naming no host, returns nil: neither is an error, since a host is free to run no consensus replica of its own.
type NodeShardCounts ¶ added in v1.20.0
type NodeShardCounts struct {
Node NodeID `json:"node"`
Owned int `json:"owned"`
Match int `json:"match"`
Older int `json:"older"`
Newer int `json:"newer"`
Missing int `json:"missing"`
Error int `json:"error"`
}
NodeShardCounts is one blob node's share of the checked positions.
type NonFullObject ¶ added in v1.20.0
type NonFullObject struct {
Hash string `json:"hash"`
Name string `json:"name,omitempty"`
Size int64 `json:"size"`
WriteEpoch uint64 `json:"write_epoch"`
Match int `json:"match"`
Shards []ShardPosition `json:"shards"`
}
NonFullObject is an object with at least one position not at its epoch.
type Options ¶
type Options struct {
// Config is the parsed configuration file. Required.
Config *Config
// HostID is the [[host]] this process runs. It selects the nodes pinned to
// that host and the addresses they are reached on. Required.
HostID HostID
// MasterKey is the AES-256 key shards are encrypted with at rest.
// Required: predastore never writes plaintext shards.
MasterKey *masterkey.Key
}
Options is everything a predastore process needs that does not come from the configuration file: which host to run and the key that protects data at rest.
type PolicyRule ¶
type PolicyRule = config.PolicyRule
The remaining tables of the configuration file.
type ShardPosition ¶ added in v1.20.0
type ShardPosition struct {
Index int `json:"index"`
Node NodeID `json:"node"`
State string `json:"state"`
HeldEpoch uint64 `json:"held_epoch,omitempty"`
Error string `json:"error,omitempty"`
}
ShardPosition is what one node holds at one shard position of an object.
type ShardReport ¶ added in v1.20.0
type ShardReport struct {
Rows int `json:"rows"`
Records int `json:"placement_records"`
Empty int `json:"empty"`
Undecodable int `json:"undecodable"`
// Vanished counts records deleted or emptied between the scan and the recheck.
Vanished int `json:"vanished"`
Checked int `json:"checked"`
Full int `json:"full"`
// ByMatch maps a count of positions at the record's epoch to how many
// objects have exactly that many.
ByMatch map[int]int `json:"by_match"`
Nodes []NodeShardCounts `json:"nodes"`
NonFull []NonFullObject `json:"non_full"`
DurationMs int64 `json:"duration_ms"`
}
ShardReport is the outcome of one VerifyShards run.
func VerifyShards ¶ added in v1.20.0
func VerifyShards(ctx context.Context, cfg *Config, rootCAs *x509.CertPool, opts VerifyOptions) (ShardReport, error)
VerifyShards audits every placement record against the blob nodes, read only: it reads records through the meta leader and Stats each shard position, issuing no write of any kind. rootCAs is as for NodeStatus.
type Status ¶ added in v1.17.0
type Status = meta.MetaStatus
Status is one meta replica's raft state: its own node id, its raft.State, the leader it currently observes (empty when the cluster has none), and the raft term and log positions behind that view. It is a type alias because this is exactly the response OpMetaStatus answers with, and a consumer outside this module already decodes its JSON shape.
func NodeStatus ¶ added in v1.17.0
func NodeStatus(ctx context.Context, cfg *Config, node NodeID, rootCAs *x509.CertPool) (Status, error)
NodeStatus dials the meta replica named by node directly, over the network, and returns its raft status. It queries that one replica only: unlike a data read it never falls back to another replica or follows a leader redirect, because the caller is asking what this specific process observes, which is exactly what a health probe needs.
The caller supplies rootCAs: the cluster's certificate authority, or any pool naming exactly the certificates it should accept. cfg's per-host tls_cert/tls_key name files on that host's own filesystem — a different file under the same path on every host — so a caller reaching a node on another machine cannot read them and must not guess at them. rootCAs is how it verifies every node's identity instead. No local TLS identity of the caller's own is required: nothing on this wire ever asks a dialer to present one back, so NodeStatus asks for none either.
type VerifyOptions ¶ added in v1.20.0
type VerifyOptions struct {
// Workers is how many objects are Stat'd at once. Default 4.
Workers int
// Recheck is how long to wait before re-reading and re-checking the
// objects short of full, so a write landing mid-scan is not called damage.
Recheck time.Duration
// PageSize is how many records each scan page reads. Default 512.
PageSize int
}
VerifyOptions tunes VerifyShards. A zero value takes each default.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
s3d
command
Command s3d runs one host of a predastore cluster: the nodes the config pins to the host named by -host, and the S3 gate in front of them.
|
Command s3d runs one host of a predastore cluster: the nodes the config pins to the host named by -host, and the S3 gate in front of them. |
|
Package endpointproxy is the contract between a node's VPC endpoint proxy and the gate's endpoint listener: a PROXY protocol v2 header naming the guest, the address it dialled and the endpoint it came through, sent inside the node-to-node mTLS session ahead of the guest's own TLS bytes.
|
Package endpointproxy is the contract between a node's VPC endpoint proxy and the gate's endpoint listener: a PROXY protocol v2 header naming the guest, the address it dialled and the endpoint it came through, sent inside the node-to-node mTLS session ahead of the guest's own TLS bytes. |
|
internal
|
|
|
admin
Package admin serves a process's liveness and readiness over plain HTTP on the host's cluster plane.
|
Package admin serves a process's liveness and readiness over plain HTTP on the host's cluster plane. |
|
blob
Package blob serves and consumes opaque value operations over rpc streams.
|
Package blob serves and consumes opaque value operations over rpc streams. |
|
blob/engine
Package engine implements segment-based large-value storage with authenticated at-rest encryption.
|
Package engine implements segment-based large-value storage with authenticated at-rest encryption. |
|
blob/hostile
Package hostile runs a blob node that misbehaves on purpose.
|
Package hostile runs a blob node that misbehaves on purpose. |
|
config
Package config parses and validates predastore's on-disk TOML file and holds the vocabulary the rest of the tree is written in: node and host ids, roles, and the [[host]] and [[host.node]] tables themselves.
|
Package config parses and validates predastore's on-disk TOML file and holds the vocabulary the rest of the tree is written in: node and host ids, roles, and the [[host]] and [[host.node]] tables themselves. |
|
gate
Package gate is predastore's S3 frontend: the HTTPS listener, the SigV4 + IAM middleware chain and the route table.
|
Package gate is predastore's S3 frontend: the HTTPS listener, the SigV4 + IAM middleware chain and the route table. |
|
gate/auth
Package auth resolves S3 access keys to credentials and the IAM policies attached to them.
|
Package auth resolves S3 access keys to credentials and the IAM policies attached to them. |
|
gate/chunked
Package chunked decodes aws-chunked upload bodies, verifying per-chunk signatures and trailing checksums while streaming out the object bytes.
|
Package chunked decodes aws-chunked upload bodies, verifying per-chunk signatures and trailing checksums while streaming out the object bytes. |
|
gate/handlers
Package handlers implements the S3 REST operations.
|
Package handlers implements the S3 REST operations. |
|
gate/model
Package model holds the S3 semantics the gate speaks: the stored metadata records, the error taxonomy, name validation, the multipart helpers, object hashing and the global-state table names.
|
Package model holds the S3 semantics the gate speaks: the stored metadata records, the error taxonomy, name validation, the multipart helpers, object hashing and the global-state table names. |
|
gate/placement
Package placement decides which blob nodes hold an object's shards.
|
Package placement decides which blob nodes hold an object's shards. |
|
gate/reaper
Package reaper reclaims the shards a delete leaves behind.
|
Package reaper reclaims the shards a delete leaves behind. |
|
gate/repair
Package repair restores shards a blob node owns but does not hold at the generation its object's placement record names.
|
Package repair restores shards a blob node owns but does not hold at the generation its object's placement record names. |
|
meta
Package meta serves and consumes global-state operations over rpc streams.
|
Package meta serves and consumes global-state operations over rpc streams. |
|
profiling
Package profiling turns Go's runtime profiles on for one s3d process from the environment, and off again when it stops.
|
Package profiling turns Go's runtime profiles on for one s3d process from the environment, and off again when it stops. |
|
rpc
Package rpc carries predastore's intra-cluster requests: a framed header per stream, a client and server keyed by opcode, and a pool holding one connection per peer node.
|
Package rpc carries predastore's intra-cluster requests: a framed header per stream, a client and server keyed by opcode, and a pool holding one connection per peer node. |
|
storetest
Package storetest provides test fixtures for the blob engine: an in-memory reference store to check the real store against, and a fixed master key.
|
Package storetest provides test fixtures for the blob engine: an in-memory reference store to check the real store against, and a fixed master key. |
|
telemetry
Package telemetry holds predastore's own OpenTelemetry instruments: meta raft consensus state, multipart upload counters, shard and object outcomes, and the gate's in-flight memory.
|
Package telemetry holds predastore's own OpenTelemetry instruments: meta raft consensus state, multipart upload counters, shard and object outcomes, and the gate's in-flight memory. |
|
testcerts
Package testcerts generates ephemeral self-signed TLS certificates for tests that exercise verify-on TLS code paths.
|
Package testcerts generates ephemeral self-signed TLS certificates for tests that exercise verify-on TLS code paths. |
|
transport
Package transport abstracts the streams predastore nodes exchange, with a QUIC transport between nodes and an in-process pipe transport within one.
|
Package transport abstracts the streams predastore nodes exchange, with a QUIC transport between nodes and an in-process pipe transport within one. |
|
Package s3api names the S3 REST operations predastore serves, and the request shape that selects each one.
|
Package s3api names the S3 REST operations predastore serves, and the request shape that selects each one. |
|
scripts
|
|
|
bench/badgerdump
command
Command badgerdump prints the contents of one of predastore's two Badger stores, for reading what a cluster actually recorded rather than inferring it from the write path.
|
Command badgerdump prints the contents of one of predastore's two Badger stores, for reading what a cluster actually recorded rather than inferring it from the write path. |
|
bench/metastatus
command
Command metastatus prints one meta replica's own view of raft, for shell harnesses that need to see a replica rejoin rather than infer it from the data path.
|
Command metastatus prints one meta replica's own view of raft, for shell harnesses that need to see a replica rejoin rather than infer it from the data path. |
|
bench/partialput
command
Command partialput opens a PUT that declares a body length and then stops sending part-way through, which is the shape of a client that dies mid-upload: a killed guest, a dropped NAT entry, a half-open connection.
|
Command partialput opens a PUT that declares a body length and then stops sending part-way through, which is the shape of a client that dies mid-upload: a killed guest, a dropped NAT entry, a half-open connection. |
|
bench/racedput
command
Command racedput writes one key from several clients at once and reports what each was told, so a caller can then read the key back and hold the cluster to the answer it gave.
|
Command racedput writes one key from several clients at once and reports what each was told, so a caller can then read the key back and hold the cluster to the answer it gave. |
|
bench/shardplace
command
Command shardplace prints where one object's shards land, so a harness can aim a fault at a named shard instead of at a host it hopes is involved.
|
Command shardplace prints where one object's shards land, so a harness can aim a fault at a named shard instead of at a host it hopes is involved. |