package manager
import "github.com/containerd/nydus-snapshotter/pkg/manager"
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 NewManager(opt Opt) (*Manager, error)
- 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) 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, liveDaemons *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
- type Opt
- type Store
Types ¶
type DaemonCache ¶
type DaemonCache struct {
// contains filtered or unexported fields
}
Daemon state cache to speed up access.
func (*DaemonCache) Add ¶
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 ¶
func (*DaemonCache) List ¶
func (s *DaemonCache) List() []*daemon.Daemon
func (*DaemonCache) Remove ¶
func (s *DaemonCache) Remove(d *daemon.Daemon) *daemon.Daemon
func (*DaemonCache) RemoveByDaemonID ¶
func (s *DaemonCache) RemoveByDaemonID(id string) *daemon.Daemon
func (*DaemonCache) Size ¶
func (s *DaemonCache) Size() int
func (*DaemonCache) Update ¶
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 (*Manager) AddDaemon ¶
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 ¶
func (*Manager) BuildDaemonCommand ¶
Build commandline according to nydusd daemon configuration.
func (*Manager) CacheDir ¶
func (*Manager) DeleteDaemon ¶
func (*Manager) DestroyDaemon ¶
FIXME: should handle the inconsistent status caused by any step in the function that returns an error.
func (*Manager) GetByDaemonID ¶
func (*Manager) ListDaemons ¶
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 ¶
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) Unlock ¶
func (m *Manager) Unlock()
func (*Manager) UnsubscribeDaemonEvent ¶
func (*Manager) UpdateDaemon ¶
func (*Manager) UpdateDaemonLocked ¶
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.
Source Files ¶
daemon_adaptor.go daemon_cache.go daemon_event.go manager.go monitor.go store.go
- Version
- v0.15.1 (latest)
- Published
- Jan 26, 2025
- Platform
- linux/amd64
- Imports
- 28 packages
- Last checked
- 5 days ago –
Tools for package owners.