manager

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 24 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaemonRecoverPolicy

type DaemonRecoverPolicy int
const (
	RecoverPolicyInvalid DaemonRecoverPolicy = iota
	RecoverPolicyNone
	RecoverPolicyRestart
	RecoverPolicyFailover
)

func ParseRecoverPolicy

func ParseRecoverPolicy(p string) (DaemonRecoverPolicy, error)

func (DaemonRecoverPolicy) String

func (p DaemonRecoverPolicy) String() string

type DaemonStates

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

func (*DaemonStates) Add

func (s *DaemonStates) Add(daemon *daemon.Daemon) *daemon.Daemon

Return nil if the daemon is never inserted or managed, otherwise returns the previously inserted daemon pointer. Allowing replace an existed daemon since some fields in Daemon can change after restarting nydusd.

func (*DaemonStates) GetByDaemonID

func (s *DaemonStates) GetByDaemonID(id string, op func(d *daemon.Daemon)) *daemon.Daemon

func (*DaemonStates) List

func (s *DaemonStates) List() []*daemon.Daemon

func (*DaemonStates) RecoverDaemonState

func (s *DaemonStates) RecoverDaemonState(d *daemon.Daemon)

Also recover daemon runtime state here

func (*DaemonStates) Remove

func (s *DaemonStates) Remove(d *daemon.Daemon) *daemon.Daemon

func (*DaemonStates) RemoveByDaemonID

func (s *DaemonStates) RemoveByDaemonID(id string) *daemon.Daemon

func (*DaemonStates) Size

func (s *DaemonStates) Size() int

type FD

type FD = uintptr

type LivenessMonitor

type LivenessMonitor interface {
	// Subscribe death event of a nydusd daemon.
	// `path` is where the monitor is listening on.
	Subscribe(id string, path string, notifier chan<- deathEvent) error
	// Unsubscribe death event of a nydusd daemon.
	Unsubscribe(id string) error
	// Run the monitor, wait for nydusd death event.
	Run()
	// Stop the monitor and release all the resources.
	Destroy()
}

LivenessMonitor liveness of a nydusd daemon.

type Manager

type Manager struct {
	NydusdBinaryPath string

	// TODO: Close me
	LivenessNotifier chan deathEvent
	RecoverPolicy    DaemonRecoverPolicy
	SupervisorSet    *supervisor.SupervisorsSet

	// A basic configuration template loaded from the file
	DaemonConfig daemonconfig.DaemonConfig

	// In order to validate daemon fs driver is consistent with the latest snapshotter boot
	FsDriver string
	// contains filtered or unexported fields
}

Manage all nydusd daemons. Provide a daemon states cache to avoid frequently operating DB

func NewManager

func NewManager(opt Opt) (*Manager, error)

func (*Manager) BuildDaemonCommand

func (m *Manager) BuildDaemonCommand(d *daemon.Daemon, bin string, upgrade bool) (*exec.Cmd, error)

Build a daemon command which will be started to fork a new nydusd process later according to previously setup daemon object.

func (*Manager) CacheDir added in v0.5.0

func (m *Manager) CacheDir() string

func (*Manager) CleanUpDaemonResources

func (m *Manager) CleanUpDaemonResources(d *daemon.Daemon)

func (*Manager) DeleteDaemon

func (m *Manager) DeleteDaemon(daemon *daemon.Daemon) error

func (*Manager) DestroyDaemon

func (m *Manager) DestroyDaemon(d *daemon.Daemon) error

FIXME: should handle the inconsistent status caused by any step in the function that returns an error.

func (*Manager) GetByDaemonID

func (m *Manager) GetByDaemonID(id string) *daemon.Daemon

func (*Manager) IsSharedDaemon

func (m *Manager) IsSharedDaemon() bool

func (*Manager) ListDaemons

func (m *Manager) ListDaemons() []*daemon.Daemon

func (*Manager) Lock

func (m *Manager) Lock()

func (*Manager) NewDaemon

func (m *Manager) NewDaemon(daemon *daemon.Daemon) error

Put a instantiated daemon into states manager. The damon state is put to both states cache and DB. If the daemon with the same daemon ID is already stored, return error ErrAlreadyExists

func (*Manager) NewInstance

func (m *Manager) NewInstance(r *daemon.Rafs) error

func (*Manager) Recover

func (m *Manager) Recover(ctx context.Context) (map[string]*daemon.Daemon, map[string]*daemon.Daemon, error)

Recover running daemons and rebuild daemons management states It is invoked during nydus-snapshotter restarting 1. Don't erase ever written record 2. Just recover nydusd daemon states to manager's memory part. 3. Manager in SharedDaemon mode should starts a nydusd when recovering

func (*Manager) RemoveInstance

func (m *Manager) RemoveInstance(snapshotID string) error

func (*Manager) StartDaemon

func (m *Manager) StartDaemon(d *daemon.Daemon) error

Fork the nydusd daemon with the process PID decided

func (*Manager) SubscribeDaemonEvent

func (m *Manager) SubscribeDaemonEvent(d *daemon.Daemon) error

func (*Manager) Unlock

func (m *Manager) Unlock()

func (*Manager) UnsubscribeDaemonEvent

func (m *Manager) UnsubscribeDaemonEvent(d *daemon.Daemon) error

func (*Manager) UpdateDaemon

func (m *Manager) UpdateDaemon(daemon *daemon.Daemon) error

type Opt

type Opt struct {
	NydusdBinaryPath string
	Database         *store.Database
	DaemonMode       config.DaemonMode
	CacheDir         string
	RecoverPolicy    DaemonRecoverPolicy
	// Nydus-snapshotter work directory
	RootDir      string
	DaemonConfig daemonconfig.DaemonConfig
	// In order to validate daemon fs driver is consistent with the latest snapshotter boot
	FsDriver string
}

type Store

type Store interface {
	// If the daemon is inserted to DB before, return error ErrAlreadyExisted.
	AddDaemon(d *daemon.Daemon) error
	UpdateDaemon(d *daemon.Daemon) error
	DeleteDaemon(id string) error
	WalkDaemons(ctx context.Context, cb func(*daemon.States) error) error
	CleanupDaemons(ctx context.Context) error

	AddInstance(r *daemon.Rafs) error
	DeleteInstance(snapshotID string) error
	WalkInstances(ctx context.Context, cb func(*daemon.Rafs) error) error

	NextInstanceSeq() (uint64, error)
}

Nydus daemons and fs instances persistence storage.

Jump to

Keyboard shortcuts

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