Documentation
¶
Index ¶
- Constants
- Variables
- func DeepCopyURL(in *url.URL) *url.URL
- func DeepCopyURLs(in types.URLs) types.URLs
- type ApplierInfo
- type CompactOptions
- type CompactorConfig
- type Config
- type EtcdConnectionConfig
- type EtcdMemberStatusCallbackFunc
- type Event
- type ExponentialBackoffConfig
- type FetcherInfo
- type HealthConfig
- type InitIndex
- type LeaderCallbacks
- type MemberLeaseCallbacks
- type NewClientFactoryFunc
- type PromoteLearnerCallback
- type RestorationConfig
- type RestoreOptions
- type SecondarySnapstoreConfig
- type SnapList
- type SnapStore
- type Snapshot
- type SnapshotterConfig
- type SnapstoreConfig
Constants ¶
const ( // DefaultEtcdConnectionTimeout defines default timeout duration for etcd client connection. DefaultEtcdConnectionTimeout time.Duration = 30 * time.Second // DefaultDefragConnectionTimeout defines default timeout duration for ETCD defrag call. DefaultDefragConnectionTimeout time.Duration = 8 * time.Minute // DefaultSnapshotTimeout defines default timeout duration for taking FullSnapshot. DefaultSnapshotTimeout time.Duration = 15 * time.Minute // DefragRetryPeriod is used as the duration after which a defragmentation is retried. DefragRetryPeriod time.Duration = 1 * time.Minute )
const ( // DefaultSnapshotLeaseRenewalEnabled is a default value for enabling the snapshot lease renewal feature DefaultSnapshotLeaseRenewalEnabled = false // FullSnapshotLeaseUpdateInterval is the interval for updating full snapshot lease FullSnapshotLeaseUpdateInterval = 1 * time.Minute // DefaultMemberLeaseRenewalEnabled is a default value for enabling the member lease renewal feature DefaultMemberLeaseRenewalEnabled = false // DefaultEtcdMemberGCEnabled is a default value for enabling the etcd member garbage collection feature DefaultEtcdMemberGCEnabled = false // DefaultFullSnapshotLeaseName is the name for the full snapshot lease. DefaultFullSnapshotLeaseName = "full-snapshot-revisions" // DefaultDeltaSnapshotLeaseName is the name for the delta snapshot lease. DefaultDeltaSnapshotLeaseName = "delta-snapshot-revisions" // DefaultHeartbeatDuration is the default heartbeat duration or lease renewal deletion. DefaultHeartbeatDuration = 30 * time.Second // LeaseUpdateTimeoutDuration is the timeout duration for updating snapshot leases LeaseUpdateTimeoutDuration = 60 * time.Second // DefaultMemberGarbageCollectionPeriod is the default etcd member garbage collection period. DefaultMemberGarbageCollectionPeriod = 60 * time.Second )
const ( // DefaultReelectionPeriod defines default time period for Reelection. DefaultReelectionPeriod = 5 * time.Second // DefaultEtcdStatusConnecTimeout defines default ConnectionTimeout for etcd client to get Etcd endpoint status. DefaultEtcdStatusConnecTimeout = 5 * time.Second )
const ( // GarbageCollectionPolicyExponential defines the exponential policy for garbage collecting old backups GarbageCollectionPolicyExponential = "Exponential" // GarbageCollectionPolicyLimitBased defines the limit based policy for garbage collecting old backups GarbageCollectionPolicyLimitBased = "LimitBased" // DefaultMaxBackups is default number of maximum backups for limit based garbage collection policy. DefaultMaxBackups = 7 // SnapshotterActive is set when the snapshotter has started taking snapshots. SnapshotterActive = true // DefaultDeltaSnapMemoryLimit is default memory limit for delta snapshots. DefaultDeltaSnapMemoryLimit = 10 * 1024 * 1024 //10Mib // DefaultDeltaSnapshotInterval is the default interval for delta snapshots. DefaultDeltaSnapshotInterval = 20 * time.Second // DefaultFullSnapshotSchedule is the default schedule DefaultFullSnapshotSchedule = "0 */1 * * *" // DefaultGarbageCollectionPeriod is the default interval for garbage collection DefaultGarbageCollectionPeriod = time.Minute // DeltaSnapshotIntervalThreshold is interval between delta snapshot DeltaSnapshotIntervalThreshold = time.Second )
const ( // SnapstoreProviderLocal is constant for local disk storage provider. SnapstoreProviderLocal = "Local" // SnapstoreProviderS3 is constant for aws S3 storage provider. SnapstoreProviderS3 = "S3" // SnapstoreProviderABS is constant for azure blob storage provider. SnapstoreProviderABS = "ABS" // SnapstoreProviderGCS is constant for GCS object storage provider. SnapstoreProviderGCS = "GCS" // SnapstoreProviderSwift is constant for Swift object storage. SnapstoreProviderSwift = "Swift" // SnapstoreProviderOSS is constant for Alicloud OSS storage provider. SnapstoreProviderOSS = "OSS" // SnapstoreProviderECS is constant for Dell EMC ECS S3 storage provider. SnapstoreProviderECS = "ECS" // SnapstoreProviderOCS is constant for OpenShift Container Storage S3 storage provider. SnapstoreProviderOCS = "OCS" // SnapstoreProviderFakeFailed is constant for fake failed storage provider. SnapstoreProviderFakeFailed = "FAILED" // SnapshotKindFull is constant for full snapshot kind. SnapshotKindFull = "Full" // SnapshotKindDelta is constant for delta snapshot kind. SnapshotKindDelta = "Incr" // SnapshotKindChunk is constant for chunk snapshot kind. SnapshotKindChunk = "Chunk" // AzureBlobStorageGlobalDomain is the default domain for azure blob storage service. AzureBlobStorageGlobalDomain = "blob.core.windows.net" // FinalSuffix is the suffix appended to the names of final snapshots. FinalSuffix = ".final" // MinChunkSize is set to 5Mib since it is lower chunk size limit for AWS. MinChunkSize int64 = 5 * (1 << 20) //5 MiB // ExcludeSnapshotMetadataKey is the tag that is to be added on snapshots in the object store if they are not to be included in SnapStore's List output. // Note: applicable for storage provider: ABS, GCS and S3. ExcludeSnapshotMetadataKey = "x-etcd-snapshot-exclude" // DefaultSecondaryBackupSyncPeriod is the default period for secondary backup sync operations. DefaultSecondaryBackupSyncPeriod = 1 * time.Hour )
Variables ¶
var ( // ErrSnapshotDeleteFailDueToImmutability is the error returned when the Delete call fails due to immutability ErrSnapshotDeleteFailDueToImmutability = fmt.Errorf("ErrSnapshotDeleteFailDueToImmutability") )
Functions ¶
Types ¶
type ApplierInfo ¶
ApplierInfo stores the info about applier
type CompactOptions ¶
type CompactOptions struct {
*RestoreOptions
*CompactorConfig
TempDir string
}
CompactOptions holds all configurable options of compact.
type CompactorConfig ¶
type CompactorConfig struct {
FullSnapshotLeaseName string `json:"fullSnapshotLeaseName,omitempty"`
DeltaSnapshotLeaseName string `json:"deltaSnapshotLeaseName,omitempty"`
SnapshotTimeout wrappers.Duration `json:"snapshotTimeout,omitempty"`
DefragTimeout wrappers.Duration `json:"defragTimeout,omitempty"`
MetricsScrapeWaitDuration wrappers.Duration `json:"metricsScrapeWaitDuration,omitempty"`
NeedDefragmentation bool `json:"needDefrag,omitempty"`
EnabledLeaseRenewal bool `json:"enabledLeaseRenewal"`
}
CompactorConfig holds all configuration options related to `compact` subcommand.
func NewCompactorConfig ¶
func NewCompactorConfig() *CompactorConfig
NewCompactorConfig returns the CompactorConfig.
func (*CompactorConfig) AddFlags ¶
func (c *CompactorConfig) AddFlags(fs *flag.FlagSet)
AddFlags adds the flags to flagset.
func (*CompactorConfig) Validate ¶
func (c *CompactorConfig) Validate() error
Validate validates the config.
type Config ¶
type Config struct {
// ReelectionPeriod defines the Period after which leadership status is checked.
ReelectionPeriod wrappers.Duration `json:"reelectionPeriod,omitempty"`
// EtcdConnectionTimeout defines the timeout duration for etcd client connection during leader election.
EtcdConnectionTimeout wrappers.Duration `json:"etcdConnectionTimeout,omitempty"`
}
Config holds the LeaderElection config.
func NewLeaderElectionConfig ¶
func NewLeaderElectionConfig() *Config
NewLeaderElectionConfig returns the Config.
type EtcdConnectionConfig ¶
type EtcdConnectionConfig struct {
CertFile string `json:"certFile,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
KeyFile string `json:"keyFile,omitempty"`
CaFile string `json:"caFile,omitempty"`
ServiceEndpoints []string `json:"serviceEndpoints,omitempty"`
// Endpoints are the endpoints from which the backup will be take or defragmentation will be called.
// This need not be necessary match the entire etcd cluster.
Endpoints []string `json:"endpoints"`
ConnectionTimeout wrappers.Duration `json:"connectionTimeout,omitempty"`
SnapshotTimeout wrappers.Duration `json:"snapshotTimeout,omitempty"`
DefragTimeout wrappers.Duration `json:"defragTimeout,omitempty"`
MaxCallSendMsgSize int `json:"maxCallSendMsgSize,omitempty"`
InsecureTransport bool `json:"insecureTransport,omitempty"`
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
}
EtcdConnectionConfig holds the etcd connection config.
func NewEtcdConnectionConfig ¶
func NewEtcdConnectionConfig() *EtcdConnectionConfig
NewEtcdConnectionConfig returns etcd connection config.
func (*EtcdConnectionConfig) AddFlags ¶
func (c *EtcdConnectionConfig) AddFlags(fs *flag.FlagSet)
AddFlags adds the flags to flagset.
func (*EtcdConnectionConfig) Validate ¶
func (c *EtcdConnectionConfig) Validate() error
Validate validates the config.
type EtcdMemberStatusCallbackFunc ¶
type EtcdMemberStatusCallbackFunc func(context.Context, *EtcdConnectionConfig, time.Duration, *logrus.Entry) (bool, bool, error)
EtcdMemberStatusCallbackFunc is type declaration for callback function to Check Etcd member Status.
type ExponentialBackoffConfig ¶
type ExponentialBackoffConfig struct {
// Multiplier defines multiplicative factor for Exponential-Backoff mechanism.
Multiplier uint `json:"multiplier,omitempty"`
// AttemptLimit defines the threshold no. of attempts to retry before a ThresholdTime is achieved.
AttemptLimit uint `json:"attemptLimit,omitempty"`
// ThresholdTime defines the upper bound time of Exponential-Backoff mechanism for retry operation.
ThresholdTime wrappers.Duration `json:"thresholdTime,omitempty"`
}
ExponentialBackoffConfig holds the configuration of the Exponential-Backoff mechanism.
func NewExponentialBackOffConfig ¶
func NewExponentialBackOffConfig() *ExponentialBackoffConfig
NewExponentialBackOffConfig returns new ExponentialBackoff.
func (*ExponentialBackoffConfig) AddFlags ¶
func (e *ExponentialBackoffConfig) AddFlags(fs *flag.FlagSet)
AddFlags adds the flags to flagset.
func (*ExponentialBackoffConfig) Validate ¶
func (e *ExponentialBackoffConfig) Validate() error
Validate validates the ExponentialBackoffConfig.
type FetcherInfo ¶
FetcherInfo stores the information about fetcher
type HealthConfig ¶
type HealthConfig struct {
FullSnapshotLeaseName string `json:"fullSnapshotLeaseName,omitempty"`
DeltaSnapshotLeaseName string `json:"deltaSnapshotLeaseName,omitempty"`
HeartbeatDuration wrappers.Duration `json:"heartbeatDuration,omitempty"`
SnapshotLeaseRenewalEnabled bool `json:"snapshotLeaseRenewalEnabled,omitempty"`
MemberLeaseRenewalEnabled bool `json:"memberLeaseRenewalEnabled,omitempty"`
}
HealthConfig holds the health configuration.
func NewHealthConfig ¶
func NewHealthConfig() *HealthConfig
NewHealthConfig returns the health config.
func (*HealthConfig) AddFlags ¶
func (c *HealthConfig) AddFlags(fs *flag.FlagSet)
AddFlags adds the flags to flagset.
func (*HealthConfig) Validate ¶
func (c *HealthConfig) Validate() error
Validate validates the health Config.
type InitIndex ¶
type InitIndex int
InitIndex stores the index
func (*InitIndex) ConsistentIndex ¶
ConsistentIndex gets the index
type LeaderCallbacks ¶
type LeaderCallbacks struct {
// OnStartedLeading is called when a LeaderElector client starts leading.
OnStartedLeading func(context.Context)
// OnStoppedLeading is called when a LeaderElector client stops leading.
OnStoppedLeading func()
}
LeaderCallbacks are callbacks that are triggered to start/stop the snapshottter when leader's currentState changes.
type MemberLeaseCallbacks ¶
type MemberLeaseCallbacks struct {
// StartLeaseRenewal is called when etcd member moved from StateUnknown to either StateLeader or StateFollower.
StartLeaseRenewal func()
// OnStoppedLeading is called when etcd member moved to StateUnknown from any other State.
StopLeaseRenewal func()
}
MemberLeaseCallbacks are callbacks that are triggered to start/stop periodic member lease renewel.
type NewClientFactoryFunc ¶
type NewClientFactoryFunc func(cfg EtcdConnectionConfig, opts ...client.Option) client.Factory
NewClientFactoryFunc allows to define how to create a client.Factory
func DeepCopyNewClientFactory ¶
func DeepCopyNewClientFactory(in NewClientFactoryFunc) NewClientFactoryFunc
DeepCopyNewClientFactory returns a deep copy
type PromoteLearnerCallback ¶
PromoteLearnerCallback is callback which is triggered when backup-restore wants to promote etcd learner to a voting member.
type RestorationConfig ¶
type RestorationConfig struct {
InitialCluster string `json:"initialCluster"`
InitialClusterToken string `json:"initialClusterToken,omitempty"`
DataDir string `json:"dataDir,omitempty"`
TempSnapshotsDir string `json:"tempDir,omitempty"`
Name string `json:"name"`
AutoCompactionRetention string `json:"autoCompactionRetention,omitempty"`
AutoCompactionMode string `json:"autoCompactionMode,omitempty"`
InitialAdvertisePeerURLs []string `json:"initialAdvertisePeerURLs"`
MaxTxnOps uint `json:"MaxTxnOps,omitempty"`
MaxRequestBytes uint `json:"MaxRequestBytes,omitempty"`
MaxCallSendMsgSize int `json:"maxCallSendMsgSize,omitempty"`
EmbeddedEtcdQuotaBytes int64 `json:"embeddedEtcdQuotaBytes,omitempty"`
MaxFetchers uint `json:"maxFetchers,omitempty"`
SkipHashCheck bool `json:"skipHashCheck,omitempty"`
}
RestorationConfig holds the restoration configuration. Note: Please ensure DeepCopy and DeepCopyInto are properly implemented.
func NewRestorationConfig ¶
func NewRestorationConfig() *RestorationConfig
NewRestorationConfig returns the restoration config.
func (*RestorationConfig) AddFlags ¶
func (c *RestorationConfig) AddFlags(fs *flag.FlagSet)
AddFlags adds the flags to flagset.
func (*RestorationConfig) DeepCopy ¶
func (c *RestorationConfig) DeepCopy() *RestorationConfig
DeepCopy returns a deeply copied structure.
func (*RestorationConfig) DeepCopyInto ¶
func (c *RestorationConfig) DeepCopyInto(out *RestorationConfig)
DeepCopyInto copies the structure deeply from in to out.
func (*RestorationConfig) Validate ¶
func (c *RestorationConfig) Validate() error
Validate validates the config.
type RestoreOptions ¶
type RestoreOptions struct {
Config *RestorationConfig
ClusterURLs types.URLsMap
// Base full snapshot + delta snapshots to restore from
BaseSnapshot *Snapshot
NewClientFactory NewClientFactoryFunc
PeerURLs types.URLs
DeltaSnapList SnapList
// OriginalClusterSize indicates the actual cluster size from the ETCD config
OriginalClusterSize int
}
RestoreOptions hold all snapshot restore related fields Note: Please ensure DeepCopy and DeepCopyInto are properly implemented.
func (*RestoreOptions) DeepCopy ¶
func (in *RestoreOptions) DeepCopy() *RestoreOptions
DeepCopy returns a deeply copied structure.
func (*RestoreOptions) DeepCopyInto ¶
func (in *RestoreOptions) DeepCopyInto(out *RestoreOptions)
DeepCopyInto copies the structure deeply from in to out.
type SecondarySnapstoreConfig ¶ added in v0.41.0
type SecondarySnapstoreConfig struct {
StoreConfig *SnapstoreConfig
BackupSyncEnabled bool `json:"backupSyncEnabled,omitempty"`
SyncPeriod wrappers.Duration `json:"syncPeriod,omitempty"`
}
SecondarySnapstoreConfig defines the configuration to enable and create secondary snapshot store.
func (*SecondarySnapstoreConfig) AddFlags ¶ added in v0.41.0
func (c *SecondarySnapstoreConfig) AddFlags(fs *flag.FlagSet)
AddFlags adds the flags to flagset and also adds `secondary-` prefix for all snapstore parameters.
func (*SecondarySnapstoreConfig) Complete ¶ added in v0.41.0
func (c *SecondarySnapstoreConfig) Complete()
Complete completes the config.
func (*SecondarySnapstoreConfig) Validate ¶ added in v0.41.0
func (c *SecondarySnapstoreConfig) Validate() error
Validate validates the config.
type SnapList ¶
type SnapList []*Snapshot
SnapList is list of snapshots.
func DeepCopySnapList ¶
DeepCopySnapList returns a deep copy
type SnapStore ¶
type SnapStore interface {
// Fetch should open reader for the snapshot file from store.
Fetch(Snapshot) (io.ReadCloser, error)
// List returns a sorted list (based on the last revision, ascending) of all snapshots in the store.
// includeAll specifies whether to include all snapshots while listing, including those with exclude tags.
// Snapshots with exclude tags are not listed unless includeAll is set to true.
// Note: "includeAll" boolean is only applicable for storage provider: ABS and GCS.
List(includeAll bool) (SnapList, error)
// Save will write the snapshot to store.
Save(Snapshot, io.ReadCloser) error
// Delete should delete the snapshot file from store.
Delete(Snapshot) error
}
SnapStore is the interface to be implemented for different storage backend like local file system, S3, ABS, GCS, Swift, OSS, ECS etc. Only purpose of these implementation to provide CPI layer to access files.
type Snapshot ¶
type Snapshot struct {
CreatedOn time.Time `json:"createdOn"`
ImmutabilityExpiryTime time.Time `json:"immutabilityExpriyTime"`
VersionID *string `json:"versionID"` // It is used only for AWS S3 object lock immutability.
Kind string `json:"kind"` // incr:incremental, full:full
SnapDir string `json:"snapDir"`
SnapName string `json:"snapName"`
Prefix string `json:"prefix"` // Points to correct prefix of a snapshot in snapstore (Required for Backward Compatibility)
CompressionSuffix string `json:"compressionSuffix"` // CompressionSuffix depends on compression policy
StartRevision int64 `json:"startRevision"`
LastRevision int64 `json:"lastRevision"` // latest revision of snapshot
IsChunk bool `json:"isChunk"`
IsFinal bool `json:"isFinal"`
}
Snapshot structure represents the metadata of snapshot.
func (*Snapshot) GenerateSnapshotDirectory ¶
func (s *Snapshot) GenerateSnapshotDirectory()
GenerateSnapshotDirectory prepares the snapshot directory name from metadata
func (*Snapshot) GenerateSnapshotName ¶
func (s *Snapshot) GenerateSnapshotName()
GenerateSnapshotName prepares the snapshot name from metadata
func (*Snapshot) GetSnapshotDirectoryCreationTimeInUnix ¶
GetSnapshotDirectoryCreationTimeInUnix returns the creation time for snapshot directory.
func (*Snapshot) IsDeletable ¶ added in v0.31.0
IsDeletable determines if the snapshot can be deleted. It checks if the immutability expiry time is set and whether the current time is after the immutability expiry time.
type SnapshotterConfig ¶
type SnapshotterConfig struct {
FullSnapshotSchedule string `json:"schedule,omitempty"`
GarbageCollectionPolicy string `json:"garbageCollectionPolicy,omitempty"`
DeltaSnapshotPeriod wrappers.Duration `json:"deltaSnapshotPeriod,omitempty"`
DeltaSnapshotMemoryLimit uint `json:"deltaSnapshotMemoryLimit,omitempty"`
GarbageCollectionPeriod wrappers.Duration `json:"garbageCollectionPeriod,omitempty"`
MaxBackups uint `json:"maxBackups,omitempty"`
DeltaSnapshotRetentionPeriod wrappers.Duration `json:"deltaSnapshotRetentionPeriod,omitempty"`
}
SnapshotterConfig holds the snapshotter config.
func (*SnapshotterConfig) AddFlags ¶
func (c *SnapshotterConfig) AddFlags(fs *flag.FlagSet)
AddFlags adds the flags to flagset.
func (*SnapshotterConfig) Validate ¶
func (c *SnapshotterConfig) Validate() error
Validate validates the config.
type SnapstoreConfig ¶
type SnapstoreConfig struct {
// Provider indicated the cloud provider.
Provider string `json:"provider,omitempty"`
// Container holds the name of bucket or container to which snapshot will be stored.
Container string `json:"container"`
// EndpointOverride denotes the storage endpoint that will be used to override the provider's default.
EndpointOverride string `json:"endpointOverride,omitempty"`
// Prefix holds the prefix or directory under StorageContainer under which snapshot will be stored.
Prefix string `json:"prefix,omitempty"`
// Temporary Directory
TempDir string `json:"tempDir,omitempty"`
// EnvPrefix is the prefix to be used for environment variables.
// It is used to differentiate between primary and secondary snapstore configs.
EnvPrefix string `json:"envPrefix,omitempty"`
// MaxParallelChunkUploads holds the maximum number of parallel chunk uploads allowed.
MaxParallelChunkUploads uint `json:"maxParallelChunkUploads,omitempty"`
// MinChunkSize holds the minimum size for a multi-part chunk upload.
MinChunkSize int64 `json:"minChunkSize,omitempty"`
// IsSource determines if this SnapStore is the source for a copy operation
IsSource bool `json:"isSource,omitempty"`
}
SnapstoreConfig defines the configuration to create snapshot store.
func (*SnapstoreConfig) AddFlags ¶
func (c *SnapstoreConfig) AddFlags(fs *flag.FlagSet)
AddFlags adds the flags to flagset.
func (*SnapstoreConfig) AddSourceFlags ¶
func (c *SnapstoreConfig) AddSourceFlags(fs *flag.FlagSet)
AddSourceFlags adds the flags to flagset using `source-` prefix for all parameters.
func (*SnapstoreConfig) Complete ¶
func (c *SnapstoreConfig) Complete()
Complete completes the config.
func (*SnapstoreConfig) MergeWith ¶
func (c *SnapstoreConfig) MergeWith(other *SnapstoreConfig)
MergeWith completes the config based on other config
func (*SnapstoreConfig) Validate ¶
func (c *SnapstoreConfig) Validate() error
Validate validates the config.