daemon

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	APISocketFileName   = "api.sock"
	SharedNydusDaemonID = "shared_daemon"
)
View Source
const (
	AnnoFsCacheDomainID string = "fscache.domainid"
	AnnoFsCacheID       string = "fscache.id"
)

Variables

View Source
var RafsSet rafsSet

Functions

func WaitUntilSocketExisted added in v0.4.0

func WaitUntilSocketExisted(sock string, pid int) error

Types

type Daemon

type Daemon struct {
	States States

	// Host all RAFS filesystems managed by this daemon:
	// fusedev dedicated mode: one and only one RAFS instance
	// fusedev shared mode: zero, one or more RAFS instances
	// fscache shared mode: zero, one or more RAFS instances
	Instances rafsSet

	// Nil means this daemon object has no supervisor
	Supervisor *supervisor.Supervisor
	Config     daemonconfig.DaemonConfig

	// How much CPU nydusd is utilizing when starts since full prefetch might
	// consume many CPU cycles
	StartupCPUUtilization float64
	Version               types.BuildTimeInfo
	// contains filtered or unexported fields
}

TODO: Record queried nydusd state

func NewDaemon

func NewDaemon(opt ...NewDaemonOpt) (*Daemon, error)

Instantiate a daemon object

func (*Daemon) AddInstance added in v0.4.0

func (d *Daemon) AddInstance(r *Rafs)

func (*Daemon) ClearVestige added in v0.3.0

func (d *Daemon) ClearVestige()

When daemon dies, clean up its vestige before start a new one.

func (*Daemon) CloneInstances added in v0.4.0

func (d *Daemon) CloneInstances(src *Daemon)

func (*Daemon) ConfigFile

func (d *Daemon) ConfigFile(instanceID string) string

Each nydusd daemon has a copy of configuration json file.

func (*Daemon) DecRef added in v0.4.0

func (d *Daemon) DecRef() int32

func (*Daemon) Exit added in v0.4.0

func (d *Daemon) Exit() error

func (*Daemon) GetAPISock added in v0.2.1

func (d *Daemon) GetAPISock() string

func (*Daemon) GetCacheMetrics added in v0.4.0

func (d *Daemon) GetCacheMetrics(sid string) (*types.CacheMetrics, error)

func (*Daemon) GetClient added in v0.4.0

func (d *Daemon) GetClient() (NydusdClient, error)

func (*Daemon) GetDaemonInfo added in v0.5.0

func (d *Daemon) GetDaemonInfo() (*types.DaemonInfo, error)

func (*Daemon) GetFsMetrics added in v0.4.0

func (d *Daemon) GetFsMetrics(sid string) (*types.FsMetrics, error)

func (*Daemon) GetInflightMetrics added in v0.6.0

func (d *Daemon) GetInflightMetrics() (*types.InflightMetrics, error)

func (*Daemon) GetRef added in v0.4.0

func (d *Daemon) GetRef() int32

func (*Daemon) GetState added in v0.4.0

func (d *Daemon) GetState() (types.DaemonState, error)

Get and cache daemon current working state by querying nydusd: 1. INIT 2. READY: All needed resources are ready. 3. RUNNING

func (*Daemon) HostMountpoint added in v0.4.0

func (d *Daemon) HostMountpoint() (mnt string)

func (*Daemon) ID

func (d *Daemon) ID() string

func (*Daemon) IncRef added in v0.4.0

func (d *Daemon) IncRef()

func (*Daemon) IsSharedDaemon

func (d *Daemon) IsSharedDaemon() bool

func (*Daemon) Lock added in v0.3.0

func (d *Daemon) Lock()

func (*Daemon) LogFile

func (d *Daemon) LogFile() string

func (*Daemon) NydusdThreadNum

func (d *Daemon) NydusdThreadNum() int

NydusdThreadNum returns how many working threads are needed of a single nydusd

func (*Daemon) Pid

func (d *Daemon) Pid() int

func (*Daemon) RecoveredMountInstances added in v0.4.0

func (d *Daemon) RecoveredMountInstances() error

Daemon must be started and reach RUNNING state before call this method

func (*Daemon) RemoveInstance added in v0.4.0

func (d *Daemon) RemoveInstance(snapshotID string)

func (*Daemon) ResetClient added in v0.3.0

func (d *Daemon) ResetClient()

func (*Daemon) ResetState added in v0.8.0

func (d *Daemon) ResetState()

Reset the cached nydusd working status

func (*Daemon) SendStates added in v0.4.0

func (d *Daemon) SendStates()

func (*Daemon) SharedMount

func (d *Daemon) SharedMount(rafs *Rafs) error

func (*Daemon) SharedUmount

func (d *Daemon) SharedUmount(rafs *Rafs) error

func (*Daemon) Start added in v0.4.0

func (d *Daemon) Start() error

func (*Daemon) State added in v0.4.0

func (d *Daemon) State() types.DaemonState

Return the cached nydusd working status, no API is invoked.

func (*Daemon) TakeOver added in v0.4.0

func (d *Daemon) TakeOver() error

func (*Daemon) Terminate added in v0.3.0

func (d *Daemon) Terminate() error

func (*Daemon) UmountAllInstances added in v0.4.0

func (d *Daemon) UmountAllInstances() error

func (*Daemon) UmountInstance added in v0.4.0

func (d *Daemon) UmountInstance(r *Rafs) error

func (*Daemon) Unlock added in v0.3.0

func (d *Daemon) Unlock()

func (*Daemon) Wait added in v0.3.0

func (d *Daemon) Wait() error

func (*Daemon) WaitUntilState added in v0.4.0

func (d *Daemon) WaitUntilState(expected types.DaemonState) error

Wait for the nydusd daemon to reach specified state with timeout.

type NewDaemonOpt

type NewDaemonOpt func(d *Daemon) error

func WithConfigDir

func WithConfigDir(dir string) NewDaemonOpt

func WithDaemonMode added in v0.9.0

func WithDaemonMode(daemonMode config.DaemonMode) NewDaemonOpt

func WithFsDriver added in v0.3.0

func WithFsDriver(fsDriver string) NewDaemonOpt

func WithLogDir

func WithLogDir(dir string) NewDaemonOpt

func WithLogLevel

func WithLogLevel(logLevel string) NewDaemonOpt

func WithLogToStdout

func WithLogToStdout(logToStdout bool) NewDaemonOpt

func WithMountpoint added in v0.4.0

func WithMountpoint(mountpoint string) NewDaemonOpt

func WithNydusdThreadNum

func WithNydusdThreadNum(nydusdThreadNum int) NewDaemonOpt

func WithRef added in v0.4.0

func WithRef(ref int32) NewDaemonOpt

func WithSocketDir

func WithSocketDir(dir string) NewDaemonOpt

Build runtime nydusd daemon object, which might be persisted later

type NewRafsOpt added in v0.4.0

type NewRafsOpt func(r *Rafs) error

type NydusdClient added in v0.4.0

type NydusdClient interface {
	GetDaemonInfo() (*types.DaemonInfo, error)

	Mount(mountpoint, bootstrap, daemonConfig string) error
	Umount(mountpoint string) error

	BindBlob(daemonConfig string) error
	UnbindBlob(domainID, blobID string) error

	GetFsMetrics(sid string) (*types.FsMetrics, error)
	GetInflightMetrics() (*types.InflightMetrics, error)
	GetCacheMetrics(sid string) (*types.CacheMetrics, error)

	TakeOver() error
	SendFd() error
	Start() error
	Exit() error
}

Nydusd HTTP client to query nydusd runtime status, operate file system instances. Control nydusd workflow like failover and upgrade.

func NewNydusClient added in v0.4.0

func NewNydusClient(sock string) (NydusdClient, error)

type Rafs added in v0.4.0

type Rafs struct {
	Seq uint64
	// Usually is the image reference
	ImageID  string
	DaemonID string
	// Given by containerd
	SnapshotID  string
	SnapshotDir string
	// 1. A host kernel EROFS mountpoint
	// 2. Absolute path to each rafs instance root directory.
	Mountpoint  string
	Annotations map[string]string
}

The whole struct will be persisted

func NewRafs added in v0.4.0

func NewRafs(snapshotID, imageID string) (*Rafs, error)

func (*Rafs) AddAnnotation added in v0.4.0

func (r *Rafs) AddAnnotation(k, v string)

func (*Rafs) BootstrapFile added in v0.4.0

func (r *Rafs) BootstrapFile() (string, error)

func (*Rafs) FscacheWorkDir added in v0.4.0

func (r *Rafs) FscacheWorkDir() string

Blob caches' chunk bitmap and meta headers are stored here.

func (*Rafs) GetMountpoint added in v0.4.0

func (r *Rafs) GetMountpoint() string

Get top level mount point for the RAFS instance:

  • FUSE with dedicated mode: the FUSE filesystem mount point, the RAFS filesystem is directly mounted at the mount point.
  • FUSE with shared mode: the FUSE filesystem mount point, the RAFS filesystem is mounted at a subdirectory under the mount point.
  • EROFS/fscache: the EROFS filesystem mount point.

func (*Rafs) GetSnapshotDir added in v0.4.0

func (r *Rafs) GetSnapshotDir() string

func (*Rafs) RelaMountpoint added in v0.4.0

func (r *Rafs) RelaMountpoint() string

Get the sub-directory under a FUSE mount point to mount a RAFS instance. For a nydusd daemon in shared mode, one or more RAFS filesystem instances can be mounted to sub-directories of the FUSE filesystem. This method returns the subdirectory for a RAFS filesystem instance.

func (*Rafs) SetMountpoint added in v0.4.0

func (r *Rafs) SetMountpoint(mp string)

type States added in v0.4.0

type States struct {
	// A unique ID generated by daemon manager to identify the nydusd instance.
	ID          string
	ProcessID   int
	APISocket   string
	LogDir      string
	LogLevel    string
	LogToStdout bool
	DaemonMode  config.DaemonMode
	FsDriver    string
	// Fusedev mountpoint on host kernel, the fscache fs driver doesn't need a host kernel mountpoint.
	Mountpoint string
	ThreadNum  int
	// Where the configuration file resides, all rafs instances share the same configuration template
	ConfigDir      string
	SupervisorPath string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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