Documentation
¶
Index ¶
- Variables
- func Action(ctx context.Context, r Driver) error
- func Boot(ctx context.Context, r Driver) error
- func EvalStatus(ctx context.Context, r Driver) status.T
- func Full(ctx context.Context, r Driver) error
- func ImportDevices(ctx context.Context, r Driver) error
- func Ingest(ctx context.Context, r Driver) error
- func IsSelected(ctx context.Context, r Driver) (selected, known bool)
- func IsStopped(r varDirer) (bool, error)
- func NewResourceFunc(drvID driver.ID) func() Driver
- func PGReset(ctx context.Context, r Driver) error
- func PGUpdate(ctx context.Context, r Driver) error
- func PRStart(ctx context.Context, r Driver) error
- func PRStop(ctx context.Context, r Driver) error
- func Provision(ctx context.Context, r Driver, leader bool) error
- func Provisioned(ctx context.Context, t Driver) (provisioned.T, error)
- func Resync(ctx context.Context, r Driver) error
- func Run(ctx context.Context, r Driver) error
- func SCSIPersistentReservationStart(ctx context.Context, r Driver) error
- func SCSIPersistentReservationStatus(ctx context.Context, r Driver, coresourceStatus status.T) status.T
- func SCSIPersistentReservationStop(ctx context.Context, r Driver) error
- func SetProvisioned(ctx context.Context, r Driver) error
- func SetUnprovisioned(ctx context.Context, r Driver) error
- func Setenv(r Driver)
- func Shutdown(ctx context.Context, r Driver) error
- func Split(ctx context.Context, r Driver) error
- func Start(ctx context.Context, r Driver) error
- func StartStandby(ctx context.Context, r Driver) error
- func StatusCheckRequires(ctx context.Context, action string, r requirer) error
- func Stop(ctx context.Context, r Driver) error
- func Unprovision(ctx context.Context, r Driver, leader bool) error
- func Update(ctx context.Context, r Driver) error
- type Aborter
- type ActionResourceDepser
- type Commander
- type Configurer
- type Driver
- type Drivers
- func (t Drivers) Add(r Driver) Drivers
- func (t Drivers) Barrier(s string) string
- func (t Drivers) GetRID(rid string) Driver
- func (t Drivers) Has(d Driver) bool
- func (t Drivers) HasRID(rid string) bool
- func (t Drivers) Index(rid string) int
- func (t Drivers) Intersection(other Drivers) Drivers
- func (t Drivers) Len() int
- func (t Drivers) Less(i, j int) bool
- func (t Drivers) Linkers(names []string) Drivers
- func (t Drivers) LinkersRID(names []string) []string
- func (t Drivers) ResolveLink(to string) (Driver, bool)
- func (t Drivers) Reverse()
- func (t Drivers) Sort()
- func (t Drivers) Swap(i, j int)
- func (t Drivers) Union(other Drivers) Drivers
- type Encaper
- type File
- type Files
- type FollowerProvisioner
- type FollowerUnprovisioner
- type Freer
- type GetHostnamer
- type Hook
- type Info
- type InfoKey
- type InfoKeys
- type Infos
- type LeaderProvisioner
- type LeaderUnprovisioner
- type Level
- type LinkNameser
- type LinkToer
- type Loader
- type Mover
- type NetNSPather
- type ObjectDriver
- type PIDer
- type PoolCharger
- type PostMover
- type PreMoveRollbacker
- type PreMover
- type ProvisionStarter
- type ProvisionStatus
- type ResizeIsReplicated
- type ResizeProvides
- type ResizeRestsOn
- type ResizeSpansBelow
- type ResizeTargeter
- type Resizer
- type Restart
- type Runner
- type RunningInfo
- type RunningInfoList
- type Runninger
- type SCSIPersistentReservation
- type SSH
- type ScheduleOptions
- type Scheduler
- type SetSSHKeyFiler
- type Setenver
- type SizeInfoKeyer
- type Sizer
- type Status
- func (t *Status) DeepCopy() *Status
- func (t *Status) IsDisabledFlag() string
- func (t *Status) IsEncapFlag() string
- func (t *Status) IsMonitoredFlag() string
- func (t *Status) IsOptionalFlag() string
- func (t *Status) IsProvisionedFlag() string
- func (t *Status) IsStandbyFlag() string
- func (t *Status) RestartFlag(restart, retries int) string
- func (t *Status) Unstructured() map[string]any
- type StatusInfoSchedAction
- type StatusInfoer
- type StatusLog
- type StatusLogEntry
- type StatusLogger
- type SubDeviceser
- type T
- func (t *T) ApplyPG(ctx context.Context) error
- func (t *T) GetConfigurationError() error
- func (t *T) GetObject() any
- func (t *T) GetObjectDriver() ObjectDriver
- func (t *T) GetPG() *pg.Config
- func (t *T) GetPGID() string
- func (t *T) ID() *resourceid.T
- func (t *T) IsActionDisabled() bool
- func (t *T) IsDisabled() bool
- func (t *T) IsEncap() bool
- func (t *T) IsMonitored() bool
- func (t *T) IsOptional() bool
- func (t *T) IsProvisionDisabled() bool
- func (t *T) IsShared() bool
- func (t *T) IsStandby() bool
- func (t *T) IsStatusDisabled() bool
- func (t *T) IsStopped() bool
- func (t *T) IsUnprovisionDisabled() bool
- func (t *T) Lock(disable bool, timeout time.Duration, intent string) (func(), error)
- func (t *T) Log() *plog.Logger
- func (t *T) MatchRID(s string) bool
- func (t *T) MatchSubset(s string) bool
- func (t *T) MatchTag(s string) bool
- func (t *T) RID() string
- func (t *T) RSubset() string
- func (t *T) Requires(action string) *resourcereqs.T
- func (t *T) ResetPG(ctx context.Context) error
- func (t *T) RunningFromLock(intent string) (RunningInfoList, error)
- func (t *T) SetConfigurationError(err error)
- func (t *T) SetDisabled(v bool)
- func (t *T) SetLoggerForTest(l *plog.Logger)
- func (t *T) SetObject(o any)
- func (t *T) SetPG(v *pg.Config)
- func (t *T) SetRID(v string) error
- func (t *T) StatusLog() StatusLogger
- func (t *T) TagSet() TagSet
- func (t *T) Trigger(ctx context.Context, blocking trigger.Blocking, hook trigger.Hook, ...) error
- func (t *T) VarDir() string
- type TagSet
- type UnprovisionStoper
Constants ¶
This section is empty.
Variables ¶
var ( ErrActionNotSupported = errors.New("the resource action is not supported on resource") ErrActionPostponedToLinker = errors.New("the resource action is postponed to its linker") ErrDisabled = errors.New("the resource is disabled") ErrActionReqNotMet = errors.New("the resource action requirements are not met") ErrBarrier = errors.New("barrier hit") )
Functions ¶
func EvalStatus ¶
EvalStatus evaluates the status of a resource interfacer
func ImportDevices ¶
ImportDevices execute the Driver ImportDevices() function if defined. Some drivers need to import devices before they can list the reservable devices to register. So use this in the start codepath.
func IsSelected ¶
IsSelected tells whether the resource r is among the resources the running action recorded with actioncontext.WithSelectedRIDs, i.e. the ones it works on or reads the state of. The known return value is false when no selection is recorded for the object of r, so the caller can apply its default policy.
func NewResourceFunc ¶
func Provisioned ¶
func SetProvisioned ¶
SetProvisioned creates a flag file in the resource var dir to remember that the provision is done.
func SetUnprovisioned ¶
SetUnprovisioned removes the flag file in the resource var dir to forget that the provision is done.
func StartStandby ¶
StartStandby activates a resource interfacer
func StatusCheckRequires ¶
func Unprovision ¶
Unprovision handles triggers around unprovision() and resource dependencies
Types ¶
type Aborter ¶
Aborter implements the Abort func, which can return true to block a start action before any resource has entered Start().
type ActionResourceDepser ¶
type ActionResourceDepser interface {
ActionResourceDeps() []actionresdeps.Dep
}
ActionResourceDepser implements the ActionResourceDeps func, which return a list of {action, rid depending on, rid depended on} tuples.
type Configurer ¶
type Configurer interface {
Configure() error
}
Configurer is an optional interface resource drivers can implement if they want to configure the resource after the manifest data has been loaded. For example, tuning the logger.
type Driver ¶
type Driver interface {
Provisioned(context.Context) (provisioned.T, error)
// common
ApplyPG(context.Context) error
ResetPG(context.Context) error
DriverID() driver.ID
GetObject() any
GetPG() *pg.Config
GetPGID() string
ID() *resourceid.T
IsActionDisabled() bool
IsDisabled() bool
IsEncap() bool
IsMonitored() bool
IsOptional() bool
IsProvisionDisabled() bool
IsUnprovisionDisabled() bool
IsStandby() bool
IsStopped() bool
IsStatusDisabled() bool
GetConfigurationError() error
SetConfigurationError(error)
// Label returns a formatted short description of the Resource
Label(context.Context) string
Log() *plog.Logger
Manifest() *manifest.T
MatchRID(string) bool
MatchSubset(string) bool
MatchTag(string) bool
Requires(string) *resourcereqs.T
RID() string
RSubset() string
SetDisabled(v bool)
SetObject(any)
SetPG(*pg.Config)
SetRID(string) error
Status(context.Context) status.T
StatusLog() StatusLogger
TagSet() TagSet
Trigger(context.Context, trigger.Blocking, trigger.Hook, trigger.Action) error
VarDir() string
}
Driver exposes what can be done with a resource
type Drivers ¶
type Drivers []Driver
func (Drivers) Barrier ¶
Barrier returns the rid of the resource that the instance action must stop at (included).
Example:
- ip#1
- ip#2 link to container#2
- ip#3
- container#1
- container#2
- container#3
Barrier("ip#2") returns ip#2 Barrier("ip") returns ip#2 [idx=4]
As a consequence the startup sequence is:
ip#1 ip#3 container#1 container#2 ip#2
func (Drivers) Intersection ¶
Intersection returns a list of drivers ordered like t and purged from drivers in other.
func (Drivers) LinkersRID ¶
func (Drivers) ResolveLink ¶
ResolveLink returns the driver instance targeted by <to>
type FollowerProvisioner ¶
type FollowerUnprovisioner ¶
type Freer ¶
Freer is implemented by a resource that can say how much of what it holds nothing has taken yet, which is what "{<rid>.free}" answers.
It is the other half of Sizer: a volume group says how big it is and how much of it is unused, and a logical volume carved from it is sized from the second.
type GetHostnamer ¶
type GetHostnamer interface {
GetHostname() string
}
GetHostnamer exposes a GetHostname method a resource can call to get the hostname used by ip resources to obtain a hostname-based DNS record
type LeaderProvisioner ¶
type LeaderUnprovisioner ¶
type LinkNameser ¶
type LinkNameser interface {
LinkNames() []string
}
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader uses a Reader to load a JSON Resource configuration into the resource struct.
type Mover ¶
Mover implements a Move function that is exposed by resource drivers that support live migration (eg container.kvm).
type NetNSPather ¶
NetNSPather exposes a NetNSPath method a resource can call to get the string identifying the network namespace for libs like netlink. For example, the container.docker driver's NetNSPath() would return the SandboxKey
type ObjectDriver ¶
type PIDer ¶
PIDer exposes a PID method a resource can call to get the head pid of the head process started by the resource. Typically a container resource PID() returns the pid of the first process of the container. PID() must return 0 when no process is running.
type PoolCharger ¶
PoolCharger is implemented by a resource taking its storage from something a pool owns: a logical volume from a volume group, a file from a directory.
It says what it takes, and what it takes it from, named as a pool names what it is the head of. What owns that head, and whether anything does, is not the resource's to know.
The size answered is the one the configuration asks for rather than the one the resource holds: what a volume costs a pool is weighed before anything is provisioned, and a resource that holds nothing yet still costs what it was asked to hold. A resource asking for no size, or for a share of what it rests on, answers zero: what it takes is not a number anything can be rationed by.
type PostMover ¶
PostMover implements a PostMove function that is called by a moveable driver (eg container.kvm) after the move is done.
type PreMoveRollbacker ¶
PreMoveRollbacker implements a PreMove rollback function that is called by a moveable driver (eg container.kvm) when move has failed.
type PreMover ¶
PreMover implements a PreMove function that is called by a moveable driver (eg container.kvm) before starting a move.
type ProvisionStarter ¶
type ProvisionStatus ¶
type ProvisionStatus struct {
Mtime time.Time `json:"mtime,omitempty"`
State provisioned.T `json:"state"`
}
ProvisionStatus define if and when the resource became provisioned.
type ResizeIsReplicated ¶
type ResizeIsReplicated interface {
ResizeIsReplicated() bool
}
ResizeIsReplicated is implemented by a resource whose size is shared with peer nodes, so it can only be resized once every node has grown what is under it: a drbd resource offers what its smallest replica holds.
A resize chain is walked in two phases because of it. Every node first grows the links below the replicated one, and only then does the node holding the object up resize the replicated link and what rests on it.
type ResizeProvides ¶
ResizeProvides is implemented by a resource others rest on by name rather than through a device. A volume group answers "vg/<its name>".
type ResizeRestsOn ¶
ResizeRestsOn is implemented by a resource that rests on another resource of the same object that no device leads to. A logical volume rests on its volume group, but a volume group exposes logical volumes rather than itself, so nothing in the device topology connects the two.
It answers the name the resource below answers to, like "vg/data", or "" when there is nothing to name.
type ResizeSpansBelow ¶
type ResizeSpansBelow interface {
ResizeSpansBelow() bool
}
ResizeSpansBelow is implemented by a resource grown onto what is under it rather than to a size of its own. A filesystem is: it is told to take up the device it sits on, and the size it reports is that device.
A volume group and a drbd resource are grown the same way, keeping a cut of the device for their own metadata. What they report is the device less that cut, which their own plan computes: a link that has taken what is under it asks of it what it holds.
Such a resource cannot be told by its size whether it still has to grow. A chain grows from the bottom up, so the device under it already holds the new size by the time it is asked, and comparing the two says there is nothing to do when the filesystem has not been grown at all. So it is grown whenever something below it was.
type ResizeTargeter ¶
ResizeTargeter is implemented by a resource that holds no size of its own, but stands for a resource of another object that does: a volume resource stands for the head of the volume it points at.
A resize chain reaching such a resource continues in the named object, from that object's head, and the resource itself drops out of the chain: there is nothing in it to change.
type Resizer ¶
type Resizer interface {
ResizePlan(ctx context.Context, to int64) (needBelow int64, err error)
Resize(ctx context.Context, to int64) error
}
Resizer is implemented by a resource driver that can change its size.
ResizePlan is asked first, of every link of the chain, and changes nothing. It answers the size this resource needs from the resources below it, which is not always the size it was asked for: a raid6 md holding n devices needs to(n-2) from each of them. It errors to refuse, naming what it cannot do, so that a chain is refused whole rather than left half resized - an xfs filesystem cannot grow beyond its device, and finding that out after the device under it has shrunk is data loss.
Resize is asked second, of the same links, once every one of them has agreed.
type Restart ¶
type Restart struct {
// Count is how many times imon should try to restart before giving up.
Count int
// Delay is the duration between 2 restarts.
Delay *time.Duration
}
func (*Restart) GetRestart ¶
func (*Restart) SetRestart ¶
type Runner ¶
Runner implements the Run func, which runs a one-shot process Implemented by the resource. The object "run" action causes selected Runners to call Run().
type RunningInfo ¶
type RunningInfo struct {
PID int `json:"pid"`
RID string `json:"rid"`
SessionID uuid.UUID `json:"session_id"`
At time.Time `json:"at"`
}
RunningInfo describes a run in progress (for sync and task).
type RunningInfoList ¶
type RunningInfoList []RunningInfo
RunningInfoList is the list of the in-progress run info (for sync and task).
func (*RunningInfoList) Has ¶
func (t *RunningInfoList) Has(rid string) bool
Has is true if the rid is found running in the Instance Monitor data sent by the daemon.
func (*RunningInfoList) LoadRunDir ¶
func (t *RunningInfoList) LoadRunDir(rid string, runDir runfiles.Dir) error
type Runninger ¶
type Runninger interface {
Running() (RunningInfoList, error)
}
Runninger implements the Running func, which the core calls when evaluating an object instance status to build the "running" list: [{"pid": 123, "rid": "task#1", "session_id": "abcd..."}]
type SCSIPersistentReservation ¶
func (SCSIPersistentReservation) IsSCSIPersistentReservationEnabled ¶
func (t SCSIPersistentReservation) IsSCSIPersistentReservationEnabled() bool
func (SCSIPersistentReservation) IsSCSIPersistentReservationPreemptAbortDisabled ¶
func (t SCSIPersistentReservation) IsSCSIPersistentReservationPreemptAbortDisabled() bool
func (SCSIPersistentReservation) PersistentReservationKey ¶
func (t SCSIPersistentReservation) PersistentReservationKey() string
type SSH ¶
type SSH struct {
// contains filtered or unexported fields
}
SSH represents a configuration for SSH-based interactions, including the private key file used for authentication.
func (*SSH) GetSSHKeyFile ¶
func (*SSH) NewSSHClient ¶
type ScheduleOptions ¶
type ScheduleOptions struct {
Action string
MaxParallel int
Option string
Base string
RequireCollector bool
RequireProvisioned bool
RequireConfirmation bool
RunDir string
Require string
}
ScheduleOptions contains the information needed by the object to create a schedule.Entry to append to the object's schedule.Table.
type Scheduler ¶
Scheduler implements the Schedules func, which returns the list of schedulable job definition on behalf of the resource.
type SetSSHKeyFiler ¶
type SetSSHKeyFiler interface {
SetSSHKeyFile()
}
type SizeInfoKeyer ¶
type SizeInfoKeyer interface {
SizeInfoKey() string
}
SizeInfoKeyer is implemented by a Sizer whose size is not its own, to name the key it is reported under in the resource info. A fs.directory reports the size of the filesystem holding it, and calling that "size" next to "driver fs.directory" reads as the size of the directory.
type Sizer ¶
Sizer is implemented by a resource driver that knows how much space it holds. It is what a relative resize resolves against, and what decides how much a resize has to grow it.
It is not called Size because a driver whose size is configurable holds that keyword in a Size field, and the two are not the same thing: one is what was asked for, this is what is there.
type Status ¶
type Status struct {
ResourceID *resourceid.T `json:"-"`
Label string `json:"label"`
Log []StatusLogEntry `json:"log,omitempty"`
Status status.T `json:"status"`
Type string `json:"type"`
IsProvisioned ProvisionStatus `json:"provisioned,omitempty"`
IsMonitored bool `json:"monitor,omitempty"`
IsDisabled bool `json:"disable,omitempty"`
IsOptional bool `json:"optional,omitempty"`
IsEncap bool `json:"encap,omitempty"`
IsStandby bool `json:"standby,omitempty"`
IsStopped bool `json:"stopped,omitempty"`
// Subset is the name of the subset this resource is assigned to.
Subset string `json:"subset,omitempty"`
// Info is a list of key-value pairs providing interesting information to
// collect site-wide about this resource.
Info map[string]any `json:"info,omitempty"`
// Tags is a set of words attached to the resource.
Tags TagSet `json:"tags,omitempty"`
// Files exposes the list of files the driver wants the daemon to replicate
// from the primary instance to secondary instances.
Files Files `json:"files,omitempty"`
// Datastores is the list of datastores used by the resource.
// The daemon must watch for these datastore changes
// (e.g. reinstall files in fs and volumes)
Datastores naming.Paths `json:"datastores,omitempty"`
}
Status is the structure representing the resource status, which is embedded in the instance status.
func (*Status) IsDisabledFlag ¶
IsDisabledFlag returns a one character representation of the IsDisabled state.
func (*Status) IsEncapFlag ¶
IsEncapFlag returns a one character representation of the IsEncap state.
func (*Status) IsMonitoredFlag ¶
IsMonitoredFlag returns a one character representation of the IsMonitored state.
func (*Status) IsOptionalFlag ¶
IsOptionalFlag returns a one character representation of the IsOptional state.
func (*Status) IsProvisionedFlag ¶
IsProvisionedFlag returns a one character representation of the IsProvisioned state.
func (*Status) IsStandbyFlag ¶
IsStandbyFlag returns a one character representation of the IsStandby state.
func (*Status) RestartFlag ¶
RestartFlag returns a one character representation of the Restart state.
func (*Status) Unstructured ¶
type StatusInfoSchedAction ¶
type StatusInfoer ¶
StatusInfoer implements the StatusInfo func, which returns a resource specific key-val mapping pushed to the collector on "pushinfo" action.
type StatusLog ¶
type StatusLog struct {
// contains filtered or unexported fields
}
StatusLog holds the information, warning and alerts of a Resource
func NewStatusLog ¶
func NewStatusLog(entries ...StatusLogEntry) *StatusLog
func (*StatusLog) Entries ¶
func (l *StatusLog) Entries() []StatusLogEntry
func (*StatusLog) Merge ¶
func (l *StatusLog) Merge(other StatusLogger)
type StatusLogEntry ¶
StatusLogEntry is an element of LogType.Log
func (StatusLogEntry) String ¶
func (t StatusLogEntry) String() string
type StatusLogger ¶
type StatusLogger interface {
Info(string, ...any)
Warn(string, ...any)
Error(string, ...any)
Len() int
Reset()
Entries() []StatusLogEntry
Merge(StatusLogger)
}
type T ¶
type T struct {
ResourceID *resourceid.T
Subset string
Disable bool
Monitor bool
Optional bool
Standby bool
Encap bool
Tags *set.Set
BlockingPreStart string
BlockingPreStop string
BlockingPreRun string
BlockingPreProvision string
BlockingPreUnprovision string
PreStart string
PreStop string
PreRun string
PreProvision string
PreUnprovision string
BlockingPostStart string
BlockingPostStop string
BlockingPostRun string
BlockingPostProvision string
BlockingPostUnprovision string
PostStart string
PostStop string
PostRun string
PostProvision string
PostUnprovision string
StartRequires string
StopRequires string
ProvisionRequires string
UnprovisionRequires string
SyncRequires string
RunRequires string
EnableProvision bool
EnableUnprovision bool
// contains filtered or unexported fields
}
T is the resource type, embedded in each drivers type
func (*T) ApplyPG ¶
ApplyPG applies the pg configuration for the parents pg and for this resource pg.
func (*T) GetConfigurationError ¶
func (*T) GetObjectDriver ¶
func (t *T) GetObjectDriver() ObjectDriver
GetObjectDriver returns the object driver interface of the object set by SetObject upon configure.
func (*T) IsActionDisabled ¶
IsActionDisabled returns true if the resource definition contains tag=noaction ... In this case, the resource actions like stop and start are skipped.
func (*T) IsDisabled ¶
IsDisabled returns true if the resource definition contains disable=true.
func (*T) IsMonitored ¶
IsMonitored returns true if the resource definition contains monitor=true.
func (*T) IsOptional ¶
IsOptional returns true if the resource definition contains optional=true. An optional resource does not break an object action on error.
Resource having actions disabled are always considered optional, because there is nothing we can do to change the state, which would cause orchestration loops.
func (*T) IsProvisionDisabled ¶
IsProvisionDisabled returns true if the resource definition contains provision=false.
func (*T) IsStatusDisabled ¶
IsStatusDisabled returns true if the resource definition contains tag=nostatus ... In this case, the resource status is always n/a
func (*T) IsUnprovisionDisabled ¶
IsUnprovisionDisabled returns true if the resource definition contains unprovision=false.
func (*T) MatchRID ¶
MatchRID returns true if:
- the pattern is a just a drivergroup name and this name matches this resource's drivergroup ex: fs#1 matches fs
- the pattern is a fully qualified resourceid, and its string representation equals the pattern. ex: fs#1 matches fs#1
func (*T) MatchSubset ¶
MatchSubset returns true if the resource subset equals the pattern.
func (*T) ResetPG ¶
ResetPG lifts the capping of the process group of this resource, and of the groups above it the object owns.
It registers the group the way applying does, and lifts what is not lifted yet: the walk reaches every resource, and each call finds only its own group left to do.
func (*T) RunningFromLock ¶
func (t *T) RunningFromLock(intent string) (RunningInfoList, error)
func (*T) SetConfigurationError ¶
func (*T) SetDisabled ¶
SetDisable is used by the resource configurer to disable the resource if the instance is disabled.
func (*T) SetLoggerForTest ¶
SetLoggerForTest can be used to set resource log for testing purpose
func (*T) StatusLog ¶
func (t *T) StatusLog() StatusLogger
StatusLog returns a reference to the resource log