manager

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 28 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaemonCache added in v0.12.0

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

Daemon state cache to speed up access.

func (*DaemonCache) Add added in v0.12.0

func (s *DaemonCache) 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 (*DaemonCache) GetByDaemonID added in v0.12.0

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

func (*DaemonCache) List added in v0.12.0

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

func (*DaemonCache) Remove added in v0.12.0

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

func (*DaemonCache) RemoveByDaemonID added in v0.12.0

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

func (*DaemonCache) Size added in v0.12.0

func (s *DaemonCache) Size() int

func (*DaemonCache) Update added in v0.12.0

func (s *DaemonCache) Update(d *daemon.Daemon)

Also recover daemon runtime state here

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 {
	FsDriver string

	DaemonConfig *daemonconfig.DaemonConfig // Daemon configuration template.
	CgroupMgr    *cgroup.Manager

	LivenessNotifier chan deathEvent // TODO: Close me
	NydusdBinaryPath string
	RecoverPolicy    config.DaemonRecoverPolicy
	SupervisorSet    *supervisor.SupervisorsSet
	// contains filtered or unexported fields
}

Manage RAFS filesystem instances and nydusd daemons.

func NewManager

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

func (*Manager) AddDaemon added in v0.12.0

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

Add an instantiated daemon to be managed by the manager.

Return ErrAlreadyExists if a daemon with the same daemon ID already exists.

func (*Manager) AddRafsInstance added in v0.12.0

func (m *Manager) AddRafsInstance(r *rafs.Rafs) error

func (*Manager) BuildDaemonCommand

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

Build commandline according to nydusd daemon configuration.

func (*Manager) CacheDir added in v0.5.0

func (m *Manager) CacheDir() string

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) ListDaemons

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

func (*Manager) Lock

func (m *Manager) Lock()

func (*Manager) Recover

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

Recover nydusd daemons and RAFS instances on startup.

To be safe: - Never ever delete any records from DB - Only cache daemon information from DB, do not actually start/create daemons - Only cache RAFS instance information from DB, do not actually recover RAFS runtime state.

func (*Manager) RemoveRafsInstance added in v0.12.0

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

func (*Manager) StartDaemon

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

Spawn a nydusd daemon to serve the daemon instance.

When returning from `StartDaemon()` with out error:

  • `d.States.ProcessID` will be set to the pid of the nydusd daemon.
  • `d.State()` may return any validate state, please call `d.WaitUntilState()` to ensure the daemon has reached specified state.
  • `d` may have not been inserted into daemonStates and store yet.

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

func (*Manager) UpdateDaemonLocked added in v0.9.0

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

Notice: updating daemon states cache and DB should be protect by `mu` lock

type Opt

type Opt struct {
	CacheDir         string
	CgroupMgr        *cgroup.Manager
	DaemonConfig     *daemonconfig.DaemonConfig
	Database         *store.Database
	FsDriver         string
	NydusdBinaryPath string
	RecoverPolicy    config.DaemonRecoverPolicy
	RootDir          string // Nydus-snapshotter work directory
}

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.ConfigState) error) error
	CleanupDaemons(ctx context.Context) error

	AddRafsInstance(r *rafs.Rafs) error
	DeleteRafsInstance(snapshotID string) error
	WalkRafsInstances(ctx context.Context, cb func(*rafs.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