utils

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: AGPL-3.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dstFolder string) error

func GenerateJWT

func GenerateJWT(id string, skey string) (*string, error)

func GetLogger

func GetLogger() zerolog.Logger

func GetPid

func GetPid(processName string) (int32, error)

func GetProcessName

func GetProcessName(pid int32) (*string, error)

func GetProcessSimilarity

func GetProcessSimilarity(processName string, processes []*ps.Process) (int32, error)

func UnzipFolder

func UnzipFolder(src, dest string) error

func ZipFolder

func ZipFolder(folderPath, zipFilePath string) error

Types

type ActionScripts

type ActionScripts struct {
	PreDump    string `json:"pre_dump" mapstructure:"pre_dump"`
	PostDump   string `json:"post_dump" mapstructure:"post_dump"`
	PreRestore string `json:"pre_restore" mapstructure:"pre_restore"`
}

type CedanaStore

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

For pushing and pulling from a cedana managed endpoint

func (*CedanaStore) GetCheckpoint

func (cs *CedanaStore) GetCheckpoint(id string) (*string, error)

ID to GetCheckpoint gets populated from the data sent over as part of a ServerCommand

func (*CedanaStore) ListCheckpoints

func (cs *CedanaStore) ListCheckpoints() (*[]CheckpointMeta, error)

func (*CedanaStore) PushCheckpoint

func (cs *CedanaStore) PushCheckpoint(filepath string) error

TODO NR - multipart uploads & downloads

type CheckpointMeta

type CheckpointMeta struct {
	ID       string
	Name     string
	Bucket   string
	ModTime  time.Time
	Size     uint64
	Checksum string
}

type Client

type Client struct {
	ProcessName          string `json:"process_name" mapstructure:"process_name"`
	LeaveRunning         bool   `json:"leave_running" mapstructure:"leave_running"`
	SignalProcessPreDump bool   `json:"signal_process_pre_dump" mapstructure:"signal_process_pre_dump"`
	SignalProcessTimeout int    `json:"signal_process_timeout" mapstructure:"signal_process_timeout"`
}

type Config

type Config struct {
	CedanaManaged bool          `json:"cedana_managed" mapstructure:"cedana_managed"`
	Client        Client        `json:"client" mapstructure:"client"`
	ActionScripts ActionScripts `json:"action_scripts" mapstructure:"action_scripts"`
	Connection    Connection    `json:"connection" mapstructure:"connection"`
	Docker        Docker        `json:"docker" mapstructure:"docker"`
	SharedStorage SharedStorage `json:"shared_storage" mapstructure:"shared_storage"`
}

func InitConfig

func InitConfig() (*Config, error)

type ConfigClient

type ConfigClient struct {
	CedanaManaged bool          `json:"cedana_managed"`
	Client        Client        `json:"client"`
	ActionScripts ActionScripts `json:"action_scripts"`
	Connection    Connection    `json:"connection"`
	SharedStorage SharedStorage `json:"shared_storage"`
}

func LoadOverrides

func LoadOverrides(cdir string) (*ConfigClient, error)

type Connection

type Connection struct {
	NATSUrl       string `json:"nats_url" mapstructure:"nats_url"`
	NATSPort      int    `json:"nats_port" mapstructure:"nats_port"`
	NATSAuthToken string `json:"nats_auth_token" mapstructure:"nats_auth_token"`
	// for cedana managed systems
	CedanaUrl       string `json:"cedana_url" mapstructure:"cedana_url"`
	CedanaPort      int    `json:"cedana_port" mapstructure:"cedana_port"`
	CedanaAuthToken string `json:"cedana_auth_token" mapstructure:"cedana_auth_token"`
}

type Docker

type Docker struct {
	LeaveRunning  bool   `json:"leave_running" mapstructure:"leave_running"`
	ContainerName string `json:"container_name" mapstructure:"container_name"`
	CheckpointID  string `json:"checkpoint_id" mapstructure:"checkpoint_id"`
}

type MockStore

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

func (*MockStore) GetCheckpoint

func (ms *MockStore) GetCheckpoint() (*string, error)

func (*MockStore) ListCheckpoints

func (ms *MockStore) ListCheckpoints() (*[]CheckpointMeta, error)

func (*MockStore) PushCheckpoint

func (ms *MockStore) PushCheckpoint(filepath string) error

type NATSStore

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

NATS stores are tied to a job id

func NewNATSStore

func NewNATSStore(logger *zerolog.Logger, jsc nats.JetStreamContext, jobID string) *NATSStore

func (*NATSStore) GetCheckpoint

func (ns *NATSStore) GetCheckpoint(checkpointFilePath string) (*string, error)

func (*NATSStore) ListCheckpoints

func (ns *NATSStore) ListCheckpoints() (*[]CheckpointMeta, error)

func (*NATSStore) PushCheckpoint

func (ns *NATSStore) PushCheckpoint(filepath string) error

type Notify

type Notify struct {
	Config          *Config
	Logger          *zerolog.Logger
	PreDumpAvail    bool
	PostDumpAvail   bool
	PreRestoreAvail bool
}

func (Notify) NetworkLock

func (n Notify) NetworkLock() error

NetworkLock NoNotify

func (Notify) NetworkUnlock

func (n Notify) NetworkUnlock() error

NetworkUnlock NoNotify

func (Notify) PostDump

func (n Notify) PostDump() error

PostDump NoNotify

func (Notify) PostRestore

func (n Notify) PostRestore(pid int32) error

PostRestore NoNotify

func (Notify) PostResume

func (n Notify) PostResume() error

PostResume NoNotify

func (Notify) PostSetupNamespaces

func (n Notify) PostSetupNamespaces() error

PostSetupNamespaces NoNotify

func (Notify) PreDump

func (n Notify) PreDump() error

PreDump NoNotify

func (Notify) PreRestore

func (n Notify) PreRestore() error

PreRestore NoNotify

func (Notify) SetupNamespaces

func (n Notify) SetupNamespaces(pid int32) error

SetupNamespaces NoNotify

type S3Store

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

func (*S3Store) GetCheckpoint

func (s *S3Store) GetCheckpoint() (*string, error)

func (*S3Store) PushCheckpoint

func (s *S3Store) PushCheckpoint(filepath string) error

type SharedStorage

type SharedStorage struct {
	MountPoint     string `json:"mount_point" mapstructure:"mount_point"` // for multi-machine checkpoint/restore
	DumpStorageDir string `json:"dump_storage_dir" mapstructure:"dump_storage_dir"`
}

type Store

type Store interface {
	GetCheckpoint(string) (*string, error) // returns filepath to downloaded chekcpoint
	PushCheckpoint(filepath string) error
	ListCheckpoints() (*[]CheckpointMeta, error) // fix
}

Abstraction for storing and retreiving checkpoints

Jump to

Keyboard shortcuts

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