Documentation
¶
Overview ¶
Package etcdrecovery implements a provider-neutral, offline etcd snapshot recovery worker. It never connects to a live etcd endpoint. Its only network surface is a bounded, exact-version HTTPS fetch from an S3-compatible object store before all snapshot inspection and restore work proceeds offline.
Index ¶
- Constants
- func CanonicalInputSecretProjection(projection InputSecretProjection) ([]byte, error)
- func CanonicalReceipt(receipt Receipt) ([]byte, error)
- func CanonicalRequest(request Request, now time.Time) ([]byte, error)
- func EndpointSHA256(request Request) string
- func InputSecretProjectionSHA256(projection InputSecretProjection) (string, error)
- func ObjectIdentitySHA256(request Request) string
- func ObjectReferenceSHA256(request Request) string
- func ResolveS3ObjectVersion(ctx context.Context, lookup S3ObjectVersionLookup, sharedCredentials []byte, ...) (string, error)
- func WriteReceipt(path string, receipt Receipt) error
- type InputSecretProjection
- type Paths
- type Receipt
- type Request
- type S3ObjectVersionLookup
- type ToolIdentity
Constants ¶
const ( RequestSchemaVersion = "cloudring.etcd-recovery.request/v1" ReceiptSchemaVersion = "cloudring.etcd-recovery.receipt/v1" InputProjectionSchemaVersion = "cloudring.etcd-recovery.input-secret-projection/v1" ImageIdentitySchemaVersion = "cloudring.etcd-recovery.image-identity/v1" SandboxStateSchemaVersion = "cloudring.etcd-recovery.sandbox-state/v1" ToolName = "etcdutl" ToolVersion = "3.6.14" ToolSHA256 = "2b7fea46e31fda1989168fbd8f7ec73f5839155f4b1af7bab274950e337e996d" DefaultRequestPath = "/run/cloudring/request/request.json" DefaultArchivePath = "/run/cloudring/archive/snapshot.db" DefaultAuthMountRoot = "/run/cloudring/credentials" DefaultToolPath = "/usr/local/bin/etcdutl" DefaultWorkspace = "/work" DefaultReceiptPath = "/work/output/receipt.json" MaxRequestBytes = 64 << 10 MaxArchiveBytes = 2 << 30 MaxRestoredBytes = 2 << 30 MaxRestoredFiles = 1024 MaximumRunTimeout = 30 * time.Minute MaximumCleanupTimeout = 30 * time.Second MaximumReceiptDuration = MaximumRunTimeout + MaximumCleanupTimeout MaximumRequestAge = 30 * time.Minute MaximumFutureSkew = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func CanonicalInputSecretProjection ¶
func CanonicalInputSecretProjection(projection InputSecretProjection) ([]byte, error)
CanonicalInputSecretProjection returns the exact canonical document whose SHA-256 is carried by Request.InputSecretSHA256.
func CanonicalReceipt ¶
func EndpointSHA256 ¶
EndpointSHA256 returns the canonical source-safe binding carried in Receipt.EndpointSHA256. Local-file mode binds the fixed mode literal rather than an external endpoint.
func InputSecretProjectionSHA256 ¶
func InputSecretProjectionSHA256(projection InputSecretProjection) (string, error)
InputSecretProjectionSHA256 returns the binding used by Request.InputSecretSHA256.
func ObjectIdentitySHA256 ¶
func ObjectReferenceSHA256 ¶
ObjectReferenceSHA256 returns the canonical source-safe binding carried in Receipt.ObjectReferenceSHA256.
func ResolveS3ObjectVersion ¶
func ResolveS3ObjectVersion( ctx context.Context, lookup S3ObjectVersionLookup, sharedCredentials []byte, now time.Time, ) (string, error)
ResolveS3ObjectVersion resolves one exact immutable S3-compatible object version by its source-safe SHA-256 binding. Credentials and the raw version remain caller-owned protected data and are never included in returned errors. A truncated or ambiguous listing fails closed.
func WriteReceipt ¶
Types ¶
type InputSecretProjection ¶
type InputSecretProjection struct {
SchemaVersion string `json:"schemaVersion"`
Namespace string `json:"namespace"`
ProjectedObjectName string `json:"secretName"`
SecretKey string `json:"secretKey"`
MountPath string `json:"mountPath"`
DefaultMode int `json:"defaultMode"`
Optional bool `json:"optional"`
ReadOnly bool `json:"readOnly"`
}
InputSecretProjection is the non-self-referential contract hashed into Request.InputSecretSHA256. It identifies the reviewed Secret projection configuration, not request.json bytes and not a Secret data digest. Downstream evidence must bind the actual Secret UID/resourceVersion and Pod volume to this reviewed contract separately.
type Paths ¶
type Paths struct {
RequestPath string
ArchivePath string
ToolPath string
WorkspaceRoot string
CredentialRoot string
}
func DefaultPaths ¶
func DefaultPaths() Paths
type Receipt ¶
type Receipt struct {
SchemaVersion string `json:"schemaVersion"`
Status string `json:"status"`
ReasonCode string `json:"reasonCode"`
Stage string `json:"stage"`
SnapshotIDSHA256 string `json:"snapshotIdSha256,omitempty"`
SnapshotChecksumSHA256 string `json:"snapshotChecksumSha256,omitempty"`
SnapshotBytes int64 `json:"snapshotBytes,omitempty"`
SourceMode string `json:"sourceMode,omitempty"`
EndpointSHA256 string `json:"endpointSha256,omitempty"`
ObjectReferenceSHA256 string `json:"objectReferenceSha256,omitempty"`
ObjectIdentitySHA256 string `json:"objectIdentitySha256,omitempty"`
ClusterIdentitySHA256 string `json:"clusterIdentitySha256,omitempty"`
JobTemplateSHA256 string `json:"jobTemplateSha256,omitempty"`
ExecutionProfileSHA256 string `json:"executionProfileSha256,omitempty"`
InputSecretSHA256 string `json:"inputSecretSha256,omitempty"`
RequestSHA256 string `json:"requestSha256,omitempty"`
WorkerExecutableSHA256 string `json:"workerExecutableSha256,omitempty"`
WorkerImageDigest string `json:"workerImageDigest,omitempty"`
Tool *ToolIdentity `json:"tool,omitempty"`
SourceStatusSHA256 string `json:"sourceStatusSha256,omitempty"`
SourceKVHashSHA256 string `json:"sourceKvHashSha256,omitempty"`
RestoredChecksumSHA256 string `json:"restoredChecksumSha256,omitempty"`
RestoredBytes int64 `json:"restoredBytes,omitempty"`
RestoredStatusSHA256 string `json:"restoredStatusSha256,omitempty"`
RestoredKVHashSHA256 string `json:"restoredKvHashSha256,omitempty"`
SandboxStateSHA256 string `json:"sandboxStateSha256,omitempty"`
MemberHealthVerified bool `json:"memberHealthVerified"`
OfflineMemberDatabaseVerified bool `json:"offlineMemberDatabaseVerified"`
LoopbackOnly bool `json:"loopbackOnly"`
WorkspaceCleanupVerified bool `json:"workspaceCleanupVerified"`
StartedAt string `json:"startedAt"`
CompletedAt string `json:"completedAt"`
ObservedDurationMilliseconds int64 `json:"observedDurationMilliseconds"`
EvidenceSHA256 string `json:"evidenceSha256"`
}
Receipt is deliberately source-safe: it contains hashes, sizes, fixed tool identity, and timestamps, but no endpoint, object key/version, archive path, credential, snapshot ID, or recovered tenant data.
func InitializationFailureReceipt ¶
InitializationFailureReceipt creates the only valid receipt available when the fixed worker invocation itself is invalid before a request can be read.
func ParseCanonicalReceipt ¶
ParseCanonicalReceipt strictly decodes the complete public receipt. It rejects duplicate or unknown fields, non-canonical JSON bytes, invalid status/stage combinations, and an evidence digest mismatch.
type Request ¶
type Request struct {
SchemaVersion string `json:"schemaVersion"`
OperationID string `json:"operationId"`
SnapshotID string `json:"snapshotId"`
SnapshotChecksumSHA256 string `json:"snapshotChecksumSha256"`
SnapshotBytes int64 `json:"snapshotBytes"`
SourceMode string `json:"sourceMode"`
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
ObjectKey string `json:"objectKey"`
ObjectVersion string `json:"objectVersion"`
ObjectIdentitySHA256 string `json:"objectIdentitySha256"`
ClusterIdentitySHA256 string `json:"clusterIdentitySha256"`
JobTemplateSHA256 string `json:"jobTemplateSha256"`
ExecutionProfileSHA256 string `json:"executionProfileSha256"`
InputSecretSHA256 string `json:"inputSecretSha256"`
WorkerExecutableSHA256 string `json:"workerExecutableSha256"`
WorkerImageDigest string `json:"workerImageDigest"`
EtcdutlVersion string `json:"etcdutlVersion"`
EtcdutlSHA256 string `json:"etcdutlSha256"`
IssuedAt string `json:"issuedAt"`
ExpiresAt string `json:"expiresAt"`
TimeoutSeconds int `json:"timeoutSeconds"`
}
Request is the complete canonical input. Raw object identity fields are consumed only to recompute ObjectIdentitySHA256 and are never emitted.
type S3ObjectVersionLookup ¶
type S3ObjectVersionLookup struct {
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
ObjectKey string `json:"objectKey"`
ObjectVersionSHA256 string `json:"objectVersionSha256"`
ExpectedBytes int64 `json:"expectedBytes"`
}
S3ObjectVersionLookup is the minimum protected input needed to resolve the exact immutable version of an already uploaded recovery object. Callers keep the returned raw version in a protected runtime boundary and publish only its SHA-256 binding.