orchestrator

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ArtifactDirectory = "/var/vcap/store/bbr-backup"

Variables

This section is empty.

Functions

func BuildExitCode added in v1.1.4

func BuildExitCode(errs Error) int

func ConvertErrors

func ConvertErrors(errs []error) error

func NewJobPostFailedBackupUnlockExecutable added in v1.4.0

func NewJobPostFailedBackupUnlockExecutable(job Job) executor.Executable

func NewJobPostRestoreUnlockExecutable added in v1.2.1

func NewJobPostRestoreUnlockExecutable(job Job) executor.Executable

func NewJobPostSuccessfulBackupUnlockExecutable added in v1.4.0

func NewJobPostSuccessfulBackupUnlockExecutable(job Job) executor.Executable

func NewJobPreBackupLockExecutable added in v1.2.1

func NewJobPreBackupLockExecutable(job Job) executor.Executable

func NewJobPreRestoreLockExecutable added in v1.2.1

func NewJobPreRestoreLockExecutable(job Job) executor.Executable

func Reverse added in v1.1.6

func Reverse(jobsSliceOfSlices [][]Job) [][]Job

Types

type AddFinishTimeStep added in v1.1.0

type AddFinishTimeStep struct {
	// contains filtered or unexported fields
}

func (*AddFinishTimeStep) Run added in v1.1.0

func (s *AddFinishTimeStep) Run(session *Session) error

type ArtifactCopier added in v1.2.1

type ArtifactCopier interface {
	DownloadBackupFromDeployment(Backup, Deployment) error
	UploadBackupToDeployment(Backup, Deployment) error
}

func NewArtifactCopier added in v1.2.1

func NewArtifactCopier(executor executor.Executor, logger Logger) ArtifactCopier

type ArtifactDirError added in v1.3.0

type ArtifactDirError customError

func NewArtifactDirError added in v1.3.0

func NewArtifactDirError(errorMessage string) ArtifactDirError

type ArtifactIdentifier

type ArtifactIdentifier interface {
	InstanceName() string
	InstanceIndex() string
	InstanceID() string
	Name() string
	HasCustomName() bool
}

type AuthInfo

type AuthInfo struct {
	Type   string
	UaaUrl string
}

type Backup

type Backup interface {
	GetArtifactSize(ArtifactIdentifier) (string, error)
	CreateArtifact(ArtifactIdentifier) (io.WriteCloser, error)
	ReadArtifact(ArtifactIdentifier) (io.ReadCloser, error)
	AddChecksum(ArtifactIdentifier, BackupChecksum) error
	CreateMetadataFileWithStartTime(time.Time) error
	AddFinishTime(time.Time) error
	FetchChecksum(ArtifactIdentifier) (BackupChecksum, error)
	CalculateChecksum(ArtifactIdentifier) (BackupChecksum, error)
	DeploymentMatches(string, []Instance) (bool, error)
	SaveManifest(manifest string) error
	Valid() (bool, error)
}

type BackupArtifact

type BackupArtifact interface {
	ArtifactIdentifier
	Size() (string, error)
	Checksum() (BackupChecksum, error)
	StreamFromRemote(io.Writer) error
	Delete() error
	StreamToRemote(io.Reader) error
}

type BackupChecker added in v1.1.0

type BackupChecker struct {
	*Workflow
}

func NewBackupChecker added in v1.1.0

func NewBackupChecker(logger Logger, deploymentManager DeploymentManager, lockOrderer LockOrderer) *BackupChecker

func (BackupChecker) Check added in v1.3.0

func (b BackupChecker) Check(deploymentName string) Error

type BackupChecksum

type BackupChecksum map[string]string

func (BackupChecksum) Match

func (b BackupChecksum) Match(other BackupChecksum) (bool, []string)

type BackupCleaner added in v1.1.0

type BackupCleaner struct {
	Logger
	*Workflow
}

func NewBackupCleaner added in v1.1.0

func NewBackupCleaner(logger Logger, deploymentManager DeploymentManager, lockOrderer LockOrderer,
	executor executor.Executor) *BackupCleaner

func (BackupCleaner) Cleanup added in v1.1.0

func (c BackupCleaner) Cleanup(deploymentName string) Error

type BackupDownloadExecutable added in v1.2.1

type BackupDownloadExecutable struct {
	Logger
	// contains filtered or unexported fields
}

func NewBackupDownloadExecutable added in v1.2.1

func NewBackupDownloadExecutable(localBackup Backup, remoteArtifact BackupArtifact, logger Logger) BackupDownloadExecutable

func (BackupDownloadExecutable) Execute added in v1.2.1

func (e BackupDownloadExecutable) Execute() error

type BackupError

type BackupError customError

func NewBackupError

func NewBackupError(errorMessage string) BackupError

type BackupExecutable added in v1.3.0

type BackupExecutable struct {
	Job
}

func NewBackupExecutable added in v1.3.0

func NewBackupExecutable(j Job) BackupExecutable

func (BackupExecutable) Execute added in v1.3.0

func (e BackupExecutable) Execute() error

type BackupManager

type BackupManager interface {
	Create(string, string, Logger) (Backup, error)
	Open(string, Logger) (Backup, error)
}

type BackupStep added in v1.1.0

type BackupStep struct {
	// contains filtered or unexported fields
}

func (*BackupStep) Run added in v1.1.0

func (s *BackupStep) Run(session *Session) error

type BackupUploadExecutable added in v1.2.1

type BackupUploadExecutable struct {
	Logger
	// contains filtered or unexported fields
}

func NewBackupUploadExecutable added in v1.2.1

func NewBackupUploadExecutable(localBackup Backup, remoteArtifact BackupArtifact, instance Instance, logger Logger) BackupUploadExecutable

func (BackupUploadExecutable) Execute added in v1.2.1

func (e BackupUploadExecutable) Execute() error

type BackupableStep added in v1.1.0

type BackupableStep struct {
	// contains filtered or unexported fields
}

func (*BackupableStep) Run added in v1.1.0

func (s *BackupableStep) Run(session *Session) error

type Backuper

type Backuper struct {
	// contains filtered or unexported fields
}

func NewBackuper

func NewBackuper(backupManager BackupManager, logger Logger, deploymentManager DeploymentManager,
	lockOrderer LockOrderer, executor exe.Executor, nowFunc func() time.Time, artifactCopier ArtifactCopier, timestamp string) *Backuper

func (Backuper) Backup

func (b Backuper) Backup(deploymentName, artifactPath string) Error

Backup checks if a deployment has backupable instances and backs them up.

type CleanupError

type CleanupError customError

func NewCleanupError

func NewCleanupError(errorMessage string) CleanupError

type CleanupPreviousStep added in v1.1.0

type CleanupPreviousStep struct{}

func (*CleanupPreviousStep) Run added in v1.1.0

func (s *CleanupPreviousStep) Run(session *Session) error

type CleanupStep added in v1.1.0

type CleanupStep struct{}

func (*CleanupStep) Run added in v1.1.0

func (s *CleanupStep) Run(session *Session) error

type CopyToRemoteStep added in v1.1.0

type CopyToRemoteStep struct {
	// contains filtered or unexported fields
}

func (*CopyToRemoteStep) Run added in v1.1.0

func (s *CopyToRemoteStep) Run(session *Session) error

type CreateArtifactStep added in v1.1.0

type CreateArtifactStep struct {
	// contains filtered or unexported fields
}

func (*CreateArtifactStep) Run added in v1.1.0

func (s *CreateArtifactStep) Run(session *Session) error

type Deployment

type Deployment interface {
	IsBackupable() bool
	BackupableInstances() []Instance
	CheckArtifactDir() error
	IsRestorable() bool
	RestorableInstances() []Instance
	PreBackupLock(LockOrderer, executor.Executor) error
	Backup(executor.Executor) error
	PostBackupUnlock(bool, LockOrderer, executor.Executor) error
	Restore() error
	Cleanup() error
	CleanupPrevious() error
	Instances() []Instance
	PreRestoreLock(LockOrderer, executor.Executor) error
	PostRestoreUnlock(LockOrderer, executor.Executor) error
	ValidateLockingDependencies(orderer LockOrderer) error
}

func NewDeployment

func NewDeployment(logger Logger, instancesArray []Instance) Deployment

type DeploymentManager

type DeploymentManager interface {
	Find(deploymentName string) (Deployment, error)
	SaveManifest(deploymentName string, artifact Backup) error
}

type DrainStep added in v1.1.0

type DrainStep struct {
	// contains filtered or unexported fields
}

func (*DrainStep) Run added in v1.1.0

func (s *DrainStep) Run(session *Session) error

type Error

type Error []error

func NewError added in v1.1.4

func NewError(errs ...error) Error

func (Error) ContainsArtifactDirError added in v1.3.0

func (err Error) ContainsArtifactDirError() bool

func (Error) ContainsUnlockOrCleanupOrArtifactDirExists added in v1.4.0

func (err Error) ContainsUnlockOrCleanupOrArtifactDirExists() bool

func (Error) Error

func (err Error) Error() string

func (Error) IsCleanup

func (err Error) IsCleanup() bool

func (Error) IsFatal

func (err Error) IsFatal() bool

func (Error) IsNil

func (err Error) IsNil() bool

func (Error) IsPostBackup

func (err Error) IsPostBackup() bool

func (Error) PrettyError

func (err Error) PrettyError(includeStacktrace bool) string

type FindDeploymentStep added in v1.1.0

type FindDeploymentStep struct {
	// contains filtered or unexported fields
}

func (*FindDeploymentStep) Run added in v1.1.0

func (s *FindDeploymentStep) Run(session *Session) error

type Instance

type Instance interface {
	InstanceIdentifer
	IsBackupable() bool
	ArtifactDirExists() (bool, error)
	ArtifactDirCreated() bool
	MarkArtifactDirCreated()
	IsRestorable() bool
	Backup() error
	Restore() error
	Cleanup() error
	CleanupPrevious() error
	ArtifactsToBackup() []BackupArtifact
	ArtifactsToRestore() []BackupArtifact
	HasMetadataRestoreNames() bool
	Jobs() []Job
}

type InstanceIdentifer

type InstanceIdentifer interface {
	Name() string
	Index() string
	ID() string
}

type Job added in v1.1.0

type Job interface {
	HasBackup() bool
	HasRestore() bool
	HasNamedBackupArtifact() bool
	HasNamedRestoreArtifact() bool
	BackupArtifactName() string
	RestoreArtifactName() string
	HasMetadataRestoreName() bool
	Backup() error
	PreBackupLock() error
	PostBackupUnlock(afterSuccessfulBackup bool) error
	PreRestoreLock() error
	Restore() error
	PostRestoreUnlock() error
	Name() string
	Release() string
	InstanceIdentifier() string
	BackupArtifactDirectory() string
	RestoreArtifactDirectory() string
	BackupShouldBeLockedBefore() []JobSpecifier
	RestoreShouldBeLockedBefore() []JobSpecifier
}

type JobPostBackupUnlockExecutor added in v1.2.1

type JobPostBackupUnlockExecutor struct {
	Job
	// contains filtered or unexported fields
}

func (JobPostBackupUnlockExecutor) Execute added in v1.2.1

func (j JobPostBackupUnlockExecutor) Execute() error

type JobPostRestoreUnlockExecutor added in v1.2.1

type JobPostRestoreUnlockExecutor struct {
	Job
}

func (JobPostRestoreUnlockExecutor) Execute added in v1.2.1

func (j JobPostRestoreUnlockExecutor) Execute() error

type JobPreBackupLockExecutor added in v1.2.1

type JobPreBackupLockExecutor struct {
	Job
}

func (JobPreBackupLockExecutor) Execute added in v1.2.1

func (j JobPreBackupLockExecutor) Execute() error

type JobPreRestoreLockExecutor added in v1.2.1

type JobPreRestoreLockExecutor struct {
	Job
}

func (JobPreRestoreLockExecutor) Execute added in v1.2.1

func (j JobPreRestoreLockExecutor) Execute() error

type JobSpecifier added in v1.1.0

type JobSpecifier struct {
	Name    string
	Release string
}

type Jobs added in v1.1.0

type Jobs []Job

func (Jobs) AnyAreBackupable added in v1.1.0

func (jobs Jobs) AnyAreBackupable() bool

func (Jobs) AnyAreRestorable added in v1.1.0

func (jobs Jobs) AnyAreRestorable() bool

func (Jobs) Backupable added in v1.1.0

func (jobs Jobs) Backupable() Jobs

func (Jobs) CustomRestoreArtifactNames added in v1.1.0

func (jobs Jobs) CustomRestoreArtifactNames() []string

func (Jobs) HasMetadataRestoreNames added in v1.5.0

func (jobs Jobs) HasMetadataRestoreNames() bool

func (Jobs) Restorable added in v1.1.0

func (jobs Jobs) Restorable() Jobs

type LockError

type LockError customError

func NewLockError

func NewLockError(errorMessage string) LockError

type LockOrderer added in v1.1.0

type LockOrderer interface {
	Order(jobs []Job) ([][]Job, error)
}

type LockStep added in v1.1.0

type LockStep struct {
	// contains filtered or unexported fields
}

func (*LockStep) Run added in v1.1.0

func (s *LockStep) Run(session *Session) error

type Logger

type Logger interface {
	Debug(tag, msg string, args ...interface{})
	Info(tag, msg string, args ...interface{})
	Warn(tag, msg string, args ...interface{})
	Error(tag, msg string, args ...interface{})
}

type Node added in v1.1.0

type Node struct {
	// contains filtered or unexported fields
}

func NewNode added in v1.1.0

func NewNode(step Step) *Node

func (*Node) OnFailure added in v1.1.0

func (node *Node) OnFailure(failStep Step) *Node

func (*Node) OnSuccess added in v1.1.0

func (node *Node) OnSuccess(successStep Step) *Node

func (*Node) OnSuccessOrFailure added in v1.1.0

func (node *Node) OnSuccessOrFailure(step Step) *Node

type PostBackupUnlockStep added in v1.1.0

type PostBackupUnlockStep struct {
	// contains filtered or unexported fields
}

func (*PostBackupUnlockStep) Run added in v1.1.0

func (s *PostBackupUnlockStep) Run(session *Session) error

type PostRestoreUnlockStep added in v1.1.0

type PostRestoreUnlockStep struct {
	// contains filtered or unexported fields
}

func (*PostRestoreUnlockStep) Run added in v1.1.0

func (s *PostRestoreUnlockStep) Run(session *Session) error

type PreRestoreLockStep added in v1.1.0

type PreRestoreLockStep struct {
	// contains filtered or unexported fields
}

func (*PreRestoreLockStep) Run added in v1.1.0

func (s *PreRestoreLockStep) Run(session *Session) error

type RestorableStep added in v1.1.0

type RestorableStep struct {
	// contains filtered or unexported fields
}

func (*RestorableStep) Run added in v1.1.0

func (s *RestorableStep) Run(session *Session) error

type RestoreCleaner added in v1.1.0

type RestoreCleaner struct {
	Logger
	*Workflow
}

func NewRestoreCleaner added in v1.1.0

func NewRestoreCleaner(logger Logger, deploymentManager DeploymentManager, lockOrderer LockOrderer, executor executor.Executor) *RestoreCleaner

func (RestoreCleaner) Cleanup added in v1.1.0

func (c RestoreCleaner) Cleanup(deploymentName string) Error

type RestoreStep added in v1.1.0

type RestoreStep struct {
	// contains filtered or unexported fields
}

func (*RestoreStep) Run added in v1.1.0

func (s *RestoreStep) Run(session *Session) error

type Restorer

type Restorer struct {
	// contains filtered or unexported fields
}

func NewRestorer

func NewRestorer(backupManager BackupManager, logger Logger, deploymentManager DeploymentManager,
	lockOrderer LockOrderer, executor executor.Executor, artifactCopier ArtifactCopier) *Restorer

func (Restorer) Restore

func (r Restorer) Restore(deploymentName, backupPath string) Error

type Session added in v1.1.0

type Session struct {
	// contains filtered or unexported fields
}

func NewSession added in v1.1.0

func NewSession(deploymentName string) *Session

func (*Session) CurrentArtifact added in v1.1.0

func (session *Session) CurrentArtifact() Backup

func (*Session) CurrentArtifactPath added in v1.1.0

func (session *Session) CurrentArtifactPath() string

func (*Session) CurrentDeployment added in v1.1.0

func (session *Session) CurrentDeployment() Deployment

func (*Session) DeploymentName added in v1.1.0

func (session *Session) DeploymentName() string

func (*Session) SetCurrentArtifact added in v1.1.0

func (session *Session) SetCurrentArtifact(artifact Backup)

func (*Session) SetCurrentArtifactPath added in v1.1.0

func (session *Session) SetCurrentArtifactPath(artifactPath string)

func (*Session) SetCurrentDeployment added in v1.1.0

func (session *Session) SetCurrentDeployment(deployment Deployment)

type Step added in v1.1.0

type Step interface {
	Run(*Session) error
}

func NewAddFinishTimeStep added in v1.1.0

func NewAddFinishTimeStep(nowFunc func() time.Time) Step

func NewBackupStep added in v1.1.0

func NewBackupStep(executor executor.Executor) Step

func NewBackupableStep added in v1.1.0

func NewBackupableStep(lockOrderer LockOrderer, logger Logger) Step

func NewCleanupPreviousStep added in v1.1.0

func NewCleanupPreviousStep() Step

func NewCleanupStep added in v1.1.0

func NewCleanupStep() Step

func NewCopyToRemoteStep added in v1.1.0

func NewCopyToRemoteStep(artifactCopier ArtifactCopier) Step

func NewCreateArtifactStep added in v1.1.0

func NewCreateArtifactStep(logger Logger, backupManager BackupManager, deploymentManager DeploymentManager, nowFunc func() time.Time, timeStamp string) Step

func NewDrainStep added in v1.1.0

func NewDrainStep(logger Logger, artifactCopier ArtifactCopier) Step

func NewFindDeploymentStep added in v1.1.0

func NewFindDeploymentStep(deploymentManager DeploymentManager, logger Logger) Step

func NewLockStep added in v1.1.0

func NewLockStep(lockOrderer LockOrderer, executor executor.Executor) Step

func NewPostBackupUnlockStep added in v1.1.0

func NewPostBackupUnlockStep(afterSuccessfulBackup bool, lockOrderer LockOrderer, executor executor.Executor) Step

func NewPostRestoreUnlockStep added in v1.1.0

func NewPostRestoreUnlockStep(lockOrderer LockOrderer, executor executor.Executor) Step

func NewPreRestoreLockStep added in v1.1.0

func NewPreRestoreLockStep(lockOrderer LockOrderer, executor executor.Executor) Step

func NewRestorableStep added in v1.1.0

func NewRestorableStep(lockOrderer LockOrderer, logger Logger) Step

func NewRestoreStep added in v1.1.0

func NewRestoreStep(logger Logger) Step

func NewValidateArtifactStep added in v1.1.0

func NewValidateArtifactStep(logger Logger, backupManager BackupManager) Step

type UnlockError added in v1.0.0

type UnlockError customError

func NewPostUnlockError added in v1.1.0

func NewPostUnlockError(errorMessage string) UnlockError

type ValidateArtifactStep added in v1.1.0

type ValidateArtifactStep struct {
	// contains filtered or unexported fields
}

func (*ValidateArtifactStep) Run added in v1.1.0

func (s *ValidateArtifactStep) Run(session *Session) error

type Workflow added in v1.1.0

type Workflow struct {
	StartingNode *Node
	Nodes        []*Node
}

func NewWorkflow added in v1.1.0

func NewWorkflow() *Workflow

func (*Workflow) Add added in v1.1.0

func (workflow *Workflow) Add(step Step) *Node

func (*Workflow) Run added in v1.1.0

func (workflow *Workflow) Run(session *Session) Error

func (*Workflow) StartWith added in v1.1.0

func (workflow *Workflow) StartWith(step Step) *Node

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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