snapshotter

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSnapshotterConfig

func NewSnapshotterConfig() *brtypes.SnapshotterConfig

NewSnapshotterConfig returns the snapshotter config.

Types

type Snapshotter

type Snapshotter struct {
	HealthConfig *brtypes.HealthConfig

	PrevSnapshot       *brtypes.Snapshot
	PrevFullSnapshot   *brtypes.Snapshot
	PrevDeltaSnapshots brtypes.SnapList

	FullSnapshotLeaseUpdateTimer *time.Timer

	SsrStateMutex *sync.Mutex
	SsrState      brtypes.SnapshotterState

	K8sClientset client.Client
	// contains filtered or unexported fields
}

Snapshotter is a struct for etcd snapshot taker

func NewSnapshotter

func NewSnapshotter(logger *logrus.Entry, config *brtypes.SnapshotterConfig, store brtypes.SnapStore, etcdConnectionConfig *brtypes.EtcdConnectionConfig, compressionConfig *compressor.CompressionConfig, healthConfig *brtypes.HealthConfig, storeConfig *brtypes.SnapstoreConfig) (*Snapshotter, error)

NewSnapshotter returns the snapshotter object.

func (*Snapshotter) CollectEventsSincePrevSnapshot

func (ssr *Snapshotter) CollectEventsSincePrevSnapshot(stopCh <-chan struct{}) (bool, error)

CollectEventsSincePrevSnapshot takes the first delta snapshot on etcd startup.

func (*Snapshotter) GarbageCollectChunks added in v0.29.0

func (ssr *Snapshotter) GarbageCollectChunks(snapList brtypes.SnapList) (int, brtypes.SnapList)

GarbageCollectChunks removes obsolete chunks based on the latest recorded snapshot. It eliminates chunks associated with snapshots that have already been uploaded. Additionally, it avoids deleting chunks linked to snapshots currently being uploaded to prevent the garbage collector from removing chunks before the composite is formed.

func (*Snapshotter) GarbageCollectDeltaSnapshots added in v0.29.0

func (ssr *Snapshotter) GarbageCollectDeltaSnapshots(snapStream brtypes.SnapList) (int, error)

GarbageCollectDeltaSnapshots traverses the list of snapshots and removes delta snapshots that are older than the retention period specified in the Snapshotter's configuration.

Parameters:

snapStream brtypes.SnapList - List of snapshots to perform garbage collection on.

Returns:

int - Total number of delta snapshots deleted.
error - Error information, if any error occurred during the garbage collection. Returns 'nil' if operation is successful.

func (*Snapshotter) GetFullSnapshotMaxTimeWindow added in v0.29.0

func (ssr *Snapshotter) GetFullSnapshotMaxTimeWindow(fullSnapScheduleSpec string) float64

GetFullSnapshotMaxTimeWindow returns the maximum time period in hours for which backup-restore must take atleast one full snapshot.

func (*Snapshotter) IsFullSnapshotRequiredAtStartup added in v0.29.0

func (ssr *Snapshotter) IsFullSnapshotRequiredAtStartup(timeWindow float64) bool

IsFullSnapshotRequiredAtStartup checks whether to take a full snapshot or not during the startup of backup-restore.

func (*Snapshotter) IsNextFullSnapshotBeyondTimeWindow added in v0.29.0

func (ssr *Snapshotter) IsNextFullSnapshotBeyondTimeWindow(timeWindow float64) bool

IsNextFullSnapshotBeyondTimeWindow determines whether the next scheduled full snapshot will exceed the given time window or not.

func (*Snapshotter) RenewFullSnapshotLeasePeriodically added in v0.29.0

func (ssr *Snapshotter) RenewFullSnapshotLeasePeriodically(FullSnapshotLeaseStopCh chan struct{}, fullSnapshotLeaseUpdateInterval time.Duration)

RenewFullSnapshotLeasePeriodically has a timer and will periodically call FullSnapshotCaseLeaseUpdate to renew the fullsnapshot lease until it is updated or stopped. The timer starts upon snapshotter initialization and is reset after every full snapshot is taken.

func (*Snapshotter) Run

func (ssr *Snapshotter) Run(stopCh <-chan struct{}, startWithFullSnapshot bool) error

Run process loop for scheduled backup Setting startWithFullSnapshot to false will start the snapshotter without taking the first full snapshot.

func (*Snapshotter) RunGarbageCollector

func (ssr *Snapshotter) RunGarbageCollector(stopCh <-chan struct{})

RunGarbageCollector basically consider the older backups as garbage and deletes it

func (*Snapshotter) SetSnapshotterActive added in v0.29.0

func (ssr *Snapshotter) SetSnapshotterActive()

SetSnapshotterActive set the snapshotter state to active.

func (*Snapshotter) SetSnapshotterInactive added in v0.29.0

func (ssr *Snapshotter) SetSnapshotterInactive()

SetSnapshotterInactive set the snapshotter state to Inactive.

func (*Snapshotter) TakeDeltaSnapshot

func (ssr *Snapshotter) TakeDeltaSnapshot() (*brtypes.Snapshot, error)

TakeDeltaSnapshot takes a delta snapshot that contains the etcd events collected up till now

func (*Snapshotter) TakeFullSnapshotAndResetTimer

func (ssr *Snapshotter) TakeFullSnapshotAndResetTimer(isFinal bool) (*brtypes.Snapshot, error)

TakeFullSnapshotAndResetTimer takes a full snapshot and resets the full snapshot timer as per the schedule.

func (*Snapshotter) TriggerDeltaSnapshot added in v0.29.0

func (ssr *Snapshotter) TriggerDeltaSnapshot() (*brtypes.Snapshot, error)

TriggerDeltaSnapshot sends the events to take delta snapshot. This is to trigger delta snapshot externally out of regular schedule.

func (*Snapshotter) TriggerFullSnapshot

func (ssr *Snapshotter) TriggerFullSnapshot(ctx context.Context, isFinal bool) (*brtypes.Snapshot, error)

TriggerFullSnapshot sends the events to take full snapshot. This is to trigger full snapshot externally out of regular schedule.

func (*Snapshotter) WasScheduledFullSnapshotMissed added in v0.29.0

func (ssr *Snapshotter) WasScheduledFullSnapshotMissed(timeWindow float64) bool

WasScheduledFullSnapshotMissed determines whether the preceding full-snapshot was missed or not.

Jump to

Keyboard shortcuts

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