Documentation
¶
Index ¶
- Constants
- func BelongsToCluster(prefix, key string, lc logicalcluster.Name) bool
- func ClusterOf(prefix, key string, isCluster func(string) bool) (logicalcluster.Name, bool)
- func NextClusterRange(ctx context.Context, kv clientv3.KV, prefix, key string, ...) (string, string, error)
- func ScanEtcdDigests(ctx context.Context, kv clientv3.KV, leases LeaseTimeToLive, ...) ([]migrationv1alpha1.EtcdEntryDigest, string, error)
- func ScanEtcdEntries(ctx context.Context, kv clientv3.KV, leases LeaseTimeToLive, ...) ([]migrationv1alpha1.EtcdEntry, string, error)
- func TransformerForKey(transformers value.ResourceTransformers, key string) (value.Transformer, error)
- type KeyParts
- type LeaseTimeToLive
Constants ¶
const DumpMaxBytes int64 = 2 * 1024 * 1024
DumpMaxBytes is the default cap on the total size of entry values returned in a single LogicalClusterDump page, used when the request doesn't specify spec.maxBytes.
const ScanPageSize int64 = 1000
ScanPageSize is the page size used in etcd range scans.
Variables ¶
This section is empty.
Functions ¶
func BelongsToCluster ¶ added in v0.31.5
func BelongsToCluster(prefix, key string, lc logicalcluster.Name) bool
BelongsToCluster reports whether key belongs to logical cluster lc. It checks both the built-in (parts[2]) and CRD/identity-based (parts[3]) cluster positions via SplitKey.
func ClusterOf ¶ added in v0.33.0
ClusterOf returns the logical cluster a storage key belongs to. Unlike SplitKey it does not require a target logical cluster: the ambiguous 5-segment case (group/resource/cluster/namespace/name for built-in namespaced resources vs. group/resource/identity/cluster/name for identity-based cluster-scoped resources) is resolved via isCluster, which reports whether the given segment is a known logical cluster name.
func NextClusterRange ¶ added in v0.34.0
func NextClusterRange(ctx context.Context, kv clientv3.KV, prefix, key string, target logicalcluster.Name) (string, string, error)
NextClusterRange seeks over unrelated cluster prefixes without reading their values. A trailing slash keeps similarly named clusters outside each range. Discovery still uses a shard-wide range, so etcd's range-counting cost remains.
func ScanEtcdDigests ¶ added in v0.34.0
func ScanEtcdDigests( ctx context.Context, kv clientv3.KV, leases LeaseTimeToLive, storagePrefix string, target logicalcluster.Name, continueToken, endKey string, limit int64, transformers value.ResourceTransformers, ) ([]migrationv1alpha1.EtcdEntryDigest, string, error)
ScanEtcdDigests returns a single page of etcd key/SHA-256-digest pairs belonging to the given logical cluster, resuming at continueToken if set.
If endKey is non-empty, the scan stops before reaching endKey (exclusive). If limit is zero or negative, ScanPageSize is used.
Values are decrypted using transformers (with the full storage key as authenticated context) before hashing so digests match across shards that use different storage prefixes or encryption keys.
func ScanEtcdEntries ¶ added in v0.34.0
func ScanEtcdEntries( ctx context.Context, kv clientv3.KV, leases LeaseTimeToLive, storagePrefix string, target logicalcluster.Name, continueToken, endKey string, limit, maxBytes int64, transformers value.ResourceTransformers, ) ([]migrationv1alpha1.EtcdEntry, string, error)
ScanEtcdEntries returns a single page of etcd key/value pairs belonging to the given logical cluster, resuming at continueToken if set.
If endKey is non-empty, the scan stops before reaching endKey (exclusive). The page stops growing once it holds limit entries or once adding another entry would push the accumulated value size past maxBytes, whichever happens first (a single entry larger than maxBytes is still returned alone, so the scan always makes progress). If limit or maxBytes is zero or negative, a default is used.
The second return value is the continue token for the next page, or the empty string if the scan reached the end of the logical cluster's keyspace (or endKey).
func TransformerForKey ¶ added in v0.34.0
func TransformerForKey(transformers value.ResourceTransformers, key string) (value.Transformer, error)
TransformerForKey selects the same resource transformer used by API storage. key is relative to the shard's storage prefix. Kcp stores the core API group as "core", whereas encryption configuration uses the empty group name. Keep ResourceTransformers itself, rather than a snapshot of its transformers, so automatic encryption configuration reloads apply to migration as well.
Types ¶
type KeyParts ¶ added in v0.31.5
type KeyParts struct {
Group string
Resource string
// Segment is "customresources", an identity hash, or "" for built-in resources.
Segment string
Cluster logicalcluster.Name
// Rest is everything after the cluster segment: [<namespace>/]<name>.
Rest string
}
KeyParts holds the parsed components of an etcd key produced by SplitKey.
func SplitKey ¶ added in v0.31.5
func SplitKey(prefix, key string, lc logicalcluster.Name) (KeyParts, bool)
SplitKey parses an etcd key into its structural components. true is only returned when the key was parsed correctly into KeyParts, not if KeyParts matches the lc.
func (KeyParts) ClusterPrefix ¶ added in v0.31.5
ClusterPrefix reconstructs the etcd key prefix that scopes.
type LeaseTimeToLive ¶ added in v0.34.0
type LeaseTimeToLive interface {
TimeToLive(ctx context.Context, id clientv3.LeaseID, opts ...clientv3.LeaseOption) (*clientv3.LeaseTimeToLiveResponse, error)
}
LeaseTimeToLive abstracts etcd's lease TTL lookup.