Documentation
¶
Index ¶
- type DaemonCache
- func (s *DaemonCache) Add(daemon *daemon.Daemon) *daemon.Daemon
- func (s *DaemonCache) GetByDaemonID(id string, op func(d *daemon.Daemon)) *daemon.Daemon
- func (s *DaemonCache) List() []*daemon.Daemon
- func (s *DaemonCache) Remove(d *daemon.Daemon) *daemon.Daemon
- func (s *DaemonCache) RemoveByDaemonID(id string) *daemon.Daemon
- func (s *DaemonCache) Size() int
- func (s *DaemonCache) Update(d *daemon.Daemon)
- type FD
- type LivenessMonitor
- type Manager
- func (m *Manager) AddDaemon(daemon *daemon.Daemon) error
- func (m *Manager) AddRafsInstance(r *rafs.Rafs) error
- func (m *Manager) BuildDaemonCommand(d *daemon.Daemon, bin string, upgrade bool) (*exec.Cmd, error)
- func (m *Manager) CacheDir() string
- func (m *Manager) DeleteDaemon(daemon *daemon.Daemon) error
- func (m *Manager) DestroyDaemon(d *daemon.Daemon) error
- func (m *Manager) DoDaemonUpgrade(d *daemon.Daemon, nydusdPath string, manager *Manager) (*daemon.Daemon, error)
- func (m *Manager) GetByDaemonID(id string) *daemon.Daemon
- func (m *Manager) ListDaemons() []*daemon.Daemon
- func (m *Manager) Lock()
- func (m *Manager) Recover(ctx context.Context, recoveringDaemons *map[string]*daemon.Daemon, ...) error
- func (m *Manager) RemoveRafsInstance(snapshotID string) error
- func (m *Manager) StartDaemon(d *daemon.Daemon) error
- func (m *Manager) SubscribeDaemonEvent(d *daemon.Daemon) error
- func (m *Manager) Unlock()
- func (m *Manager) UnsubscribeDaemonEvent(d *daemon.Daemon) error
- func (m *Manager) UpdateDaemon(daemon *daemon.Daemon) error
- func (m *Manager) UpdateDaemonLocked(daemon *daemon.Daemon) error
- func (m *Manager) UpdateRafsInstance(r *rafs.Rafs) error
- type Opt
- type Store
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 (*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 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 (*Manager) AddDaemon ¶ added in v0.12.0
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 (*Manager) BuildDaemonCommand ¶
Build commandline according to nydusd daemon configuration.
func (*Manager) DestroyDaemon ¶
FIXME: should handle the inconsistent status caused by any step in the function that returns an error.
func (*Manager) DoDaemonUpgrade ¶ added in v0.15.4
func (m *Manager) DoDaemonUpgrade(d *daemon.Daemon, nydusdPath string, manager *Manager) (*daemon.Daemon, error)
Provide minimal parameters since most of it can be recovered by nydusd states. Create a new daemon in Manger to take over the service.
func (*Manager) ListDaemons ¶
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 (*Manager) StartDaemon ¶
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 (*Manager) UnsubscribeDaemonEvent ¶
func (*Manager) UpdateDaemonLocked ¶ added in v0.9.0
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
UpdateRafsInstance(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.