object

package
v3.0.0-rc55 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 142 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultNodeMaxParallel = 10

	// MinNodeMaxParallel is the least number of CRM actions the daemon lets
	// run in parallel, whatever node.max_parallel says: a lower one is too
	// dangerous to honor.
	MinNodeMaxParallel = 2
)
View Source
const (
	// AcmeLetsEncrypt is the directory of Let's Encrypt, which
	// acme.directory = letsencrypt names.
	AcmeLetsEncrypt = "https://acme-v02.api.letsencrypt.org/directory"

	// AcmeLetsEncryptStaging is the staging directory of Let's Encrypt,
	// which acme.directory = letsencrypt-staging names.
	AcmeLetsEncryptStaging = "https://acme-staging-v02.api.letsencrypt.org/directory"
)
View Source
const (

	// AcmeChallengeKeyPattern matches the keys of the challenge tokens.
	AcmeChallengeKeyPattern = acmeChallengeKeyPrefix + "*"
)
View Source
const RedactedValue = redacted

RedactedValue is what a secret value is shown as to a reader not allowed to see it.

Variables

View Source
var (
	ErrInvalidNode            = errors.New("invalid node")
	ErrDisabled               = errors.New("object instance is disabled")
	ErrEncapAgentNotInstalled = errors.New("opensvc is not installed in the container")
)
View Source
var (
	ErrKeyExist    = errors.New("key already exists")
	ErrKeyEmpty    = errors.New("key name is empty")
	ErrKeyNotExist = errors.New("key does not exist")
	ErrValueTooBig = errors.New("key value exceeds the allowed size")
)
View Source
var ErrCertificateNotIssued = errors.New("the certificate was not issued by the sec")

ErrCertificateNotIssued is the refusal to renew a certificate the sec did not issue, as one installed from elsewhere: generating one would replace it, with the names of the sec rather than the ones it was installed for.

View Source
var (
	ErrKeyNotFound = errors.New("key not found")
)
View Source
var ErrProvisionConflict = errors.New("the provision would take what something on the node holds")

ErrProvisionConflict is the refusal of a provision finding on the node a system resource holding what it would take.

View Source
var ErrRuntimeReference = errors.New("the reference evaluates only at run time")

ErrRuntimeReference is a reference evaluating only at run time, refused by an object evaluating its configuration from the configuration alone.

View Source
var ErrStopToChange = errors.New("the resource is not known to be stopped")

ErrStopToChange is the refusal of a configuration change a resource up on a node would leak by: a change of a keyword saying what it holds there, of its type, or the removal of its section.

View Source
var ErrStoreNotUsable = errors.New("not usable")

ErrStoreNotUsable is the refusal of a store of a sec to a namespace other than the sec's, which the sec does not share with, or which names a sec, or a store of it, that does not exist: the api answers it 403.

View Source
var ErrWrongType = errors.New("wrong type provided for interface")
View Source
var NodeKeywordStore = keywords.Store(append(nodePrivateKeywords, nodeCommonKeywords...))
View Source
var NodeMigrationRules = MigrationRules{
	{
		Doc: "A keyword written under a former name, which om still reads as an alias, " +
			"is written under its name: node.db_min_ping_interval becomes collector_ping_interval, " +
			"node.min_avail_mem_pct becomes min_avail_mem, listener.tls_port becomes port, " +
			"the name of an arbitrator becomes uri, the cmd of a stonith becomes command, " +
			"and so on for every alias the keyword reference lists.",
		// contains filtered or unexported fields
	},
	{
		Doc: "The secret of a pure array becomes its private_key, which names the same secret and reads its private_key key.",
		// contains filtered or unexported fields
	},
	{
		Doc: "The ips_per_node of a routed_bridge network becomes mask_per_node, " +
			"the prefix length of the subnet each node is given, on the address family of its network. " +
			"A network setting neither is given the mask_per_node the ips_per_node default of 1024 amounts to, " +
			"so its subnets keep their size.",
		// contains filtered or unexported fields
	},
	{
		Doc: "listener.openid_well_known becomes listener.openid_issuer: " +
			"the url without its /.well-known/openid-configuration end, which om appends itself. " +
			"An issuer without listener.openid_client_id is reported: om refuses openid logins " +
			"without the client id om3-webapp is registered with at the provider.",
		// contains filtered or unexported fields
	},
	{
		Doc: "The schedule of the brocade section moves to the brocade switch sections that set none, " +
			"as each switch is inventoried on its own schedule, and the brocade section is deleted.",
		// contains filtered or unexported fields
	},
	{
		Doc: "What om no longer reads is removed: the reboot, rotate_root_pw, stats_collection and dequeue_actions sections, " +
			"node.default_mon_format, the timeout and the secret of an arbitrator, " +
			"and the secret of a relay heartbeat that authenticates with a username.",
		// contains filtered or unexported fields
	},
	{
		Doc: "A relay heartbeat authenticating with a secret, and a switch reached with telnet, are reported and kept: " +
			"what replaces them is a decision, a relay user with the heartbeat grant and a password secret, " +
			"an ssh key or a password secret. " +
			"An arbitrator written with name, reached by a tcp connect without a port, is reported: om reaches it on listener.port, " +
			"1215 by default, where a v2 agent was reached on 1214, and only its admin knows whether it still runs one.",
		// contains filtered or unexported fields
	},
}

NodeMigrationRules is the rules the configuration of a node, or of the cluster, is migrated by.

View Source
var ObjectMigrationRules = MigrationRules{
	{
		Doc: "A filesystem that made the volume it mounts, its vg and size keywords set, " +
			"becomes a disk.lv resource and a filesystem resting on it. " +
			"A size written as a share of a volume group becomes arithmetic on what om reports of that group, " +
			"where the group is a resource of the object, and is kept as it is where it is not.",
		// contains filtered or unexported fields
	},
	{
		Doc: "The size and the mode options of the mnt_opt of a tmpfs become its size and mode keywords, " +
			"the size being what a resize records. " +
			"The tmpfs of a volume is sized {DEFAULT.size}, the size the volume is claimed with. " +
			"A size written as a share of the memory is kept in mnt_opt: om cannot say how big it is.",
		// contains filtered or unexported fields
	},
}

ObjectMigrationRules is the rules the configuration of an object is migrated by.

Functions

func AcmeChallengeKey

func AcmeChallengeKey(token string) (string, error)

AcmeChallengeKey returns the key of the sec holding the key authorization of the http-01 challenge token, and refuses a token which is not one: a token is a base64url string, so it names no other key.

func ApplyRefs

func ApplyRefs(ns string, doc RefsDocument, mode RefsMode) ([]string, error)

ApplyRefs writes the keys of the document into the datastores of the namespace ns, as mode says, and returns what it did and what it left: a datastore created, a key added, rewritten, or left with a value differing from the document's.

func ApplyRefsUndoable

func ApplyRefsUndoable(ns string, doc RefsDocument, mode RefsMode) ([]string, func() error, error)

ApplyRefsUndoable is ApplyRefs, returning too how to undo what it did, on an error as well: remove the keys it added, put back the values it rewrote, and delete the datastores it created, as the create of an object the keys were applied for does when it fails after.

func CheckLocalFileStopToChange

func CheckLocalFileStopToChange(p naming.Path, dst string) error

CheckLocalFileStopToChange refuses the configuration file at dst replacing the one of the object at p, as an edit does, when a resource up on this node would leak by it, as CheckStopToChange says.

func CheckLocalUpdateStopToChange

func CheckLocalUpdateStopToChange(p naming.Path, deletes []string, unsets []key.T, sets []keyop.T) error

CheckLocalUpdateStopToChange refuses the update of the configuration of the object at p a resource up on this node would leak by, as CheckStopToChange says, for a write made without the daemon, which knows the status of the other nodes.

func CheckStopToChange

func CheckStopToChange(kind naming.Kind, from, to *xconfig.T, statuses map[string]*instance.Status) error

CheckStopToChange refuses a change from the configuration from to the configuration to of an object of kind, for a resource up on a node, as statuses say, the instance statuses of the object by node:

  • a change of the value of a keyword marked StopToChange, as the mount point of a filesystem or the address of an ip, evaluated on the node, so a change of what it references is one too, unless the value was empty, which designates nothing the resource could have set up, as a required keyword left empty, which leaves the resource not configured and its status not known;
  • a change of its type, which is a change of the driver stopping it;
  • its disable, which leaves it running with nothing to stop it, and its values held with no hold said: the configuration of a disabled object holds nothing, so another can be made holding them;
  • the removal of its section, which nothing stops once it is gone.

The stop of the resource acts on the configuration it reads then: what the former value set up stays on the node, for root to find and undo, as a filesystem still mounted, an address still configured.

A resource is up on a node unless its status there is known to be stopped: down, standby down, or n/a, or undef for an error of its configuration while it holds nothing there, its ConfigError, which a change of the configuration fixes. Any other undef status is not known, and the refusal says so, and that a change forced is the operator's to make once sure the resource holds nothing. An object created changes nothing.

func CollectorResponseStatusCheck

func CollectorResponseStatusCheck(resp *http.Response, method, path string, wanted []int) error

CollectorResponseStatusCheck verifies if the HTTP response status code matches any of the expected codes in `wanted`. If it doesn't match, attempts to decode the response body as a `CollectorProblem` and includes its details in the error.

func DescribeComputeClaims

func DescribeComputeClaims(m map[string]int64) string

DescribeComputeClaims says what an object claims, in the words of the units, for a message.

func ForgetWrites

func ForgetWrites(varDir, nodename string) error

ForgetWrites removes the record of the writes of a node no longer in the scope of the object of varDir: it writes nothing of the object.

func GetSecEncryptDecrypter

func GetSecEncryptDecrypter() (encryptDecrypter, error)

func Holds

func Holds(p naming.Path, oc Configurer, nodes []string) []resource.ObjectHold

Holds returns the values the resources of the object hold, evaluated for each of the nodes, with the nodes each is held on: the nodes it evaluates to that value on, or every cluster node for a shared resource.

The configurer evaluates from the configuration alone, as one made with WithStaticReferences: a value referencing what another resource exposes is not held by this resource, but by the one it comes from. A disabled resource holds nothing, never being started.

func InitData

func InitData()

InitData reset package objects data, it can be used for tests.

func IsSecretKey

func IsSecretKey(kind naming.Kind, k key.T, sectionType string) bool

IsSecretKey says whether the value of k, in a configuration of an object of kind, is a secret: a key of a sec or usr data section, or a keyword declared with RedactSecret. kind is invalid for a node or cluster configuration, and sectionType is the type of the section k is in.

func IsWriting

func IsWriting(data instance.Status) bool

IsWriting says whether the instance may write its data: an app, container or share resource of it runs, or says nothing of whether it does. A standby resource, running on every node, is not counted, nor a disabled one. What writes behind the back of opensvc is not counted either.

func KeywordOptions

func KeywordOptions(kind naming.Kind, section string) []string

KeywordOptions returns the options of the keywords a section of a configuration of kind may hold, sorted, each once: the ones the drivers of its group declare, and the ones of the store of the kind. The node configuration is the kind naming.KindInvalid.

It is a superset. Which of them a section holds depends on the driver its type names, and on keywords limited to other kinds or sections, which is what the keyword lookup of the configuration says of each.

func KeywordStoreWithDrivers

func KeywordStoreWithDrivers(kind naming.Kind) keywords.Store

KeywordStoreWithDrivers return the keywords supported by a specific object kind, including all resource drivers keywords.

func ListenerTLSSecs

func ListenerTLSSecs(refs []string) []naming.Path

ListenerTLSSecs returns the secs listener.tls_secs names, as paths, or by their names in the system namespace. A reference naming no sec is left out.

func LockRefs

func LockRefs(ns string) (func(), error)

LockRefs takes the lock of the copies of referenced keys into the namespace ns. Held from a copy until the configuration it is made for lands or is taken back, a second copy of the same keys finds those of the first there and adds none, so the undo of either takes back nothing the other committed. The lock of the file serializes the processes, the mutex the requests of one, as the daemon api serves them, a lock of the file being held per process.

func New

func New(p naming.Path, opts ...funcopt.O) (any, error)

New allocates a new kinded object

func NewCfg

func NewCfg(path naming.Path, opts ...funcopt.O) (*cfg, error)

NewCfg allocates a cfg kind object.

func NewList

func NewList(paths naming.Paths, opts ...funcopt.O) ([]any, error)

func NewNscfg

func NewNscfg(path naming.Path, opts ...funcopt.O) (*nscfg, error)

func NewSec

func NewSec(path naming.Path, opts ...funcopt.O) (*sec, error)

NewSec allocates a sec kind object.

func NewSvc

func NewSvc(path naming.Path, opts ...funcopt.O) (*svc, error)

NewSvc allocates a svc kind object.

func NewT

func NewT(p naming.Path) any

NewT allocates a new kinded and uninitialized object

func NewUsr

func NewUsr(path naming.Path, opts ...funcopt.O) (*usr, error)

NewUsr allocates a usr kind object.

func NewVol

func NewVol(path naming.Path, opts ...funcopt.O) (*vol, error)

NewVol allocates a vol kind object.

func PGKeywords

func PGKeywords(kind naming.Kind) []*keywords.Keyword

PGKeywords returns the pg_* keywords of the objects of a kind, which set the process group caps of the object, of a subset or of a resource, sorted by name.

It is what a command setting caps documents and completes, so a keyword added to the store is offered by the command without the command changing.

func PKCS

func PKCS(privateKeyBytes, certificateChainBytes, passwordBytes []byte) ([]byte, error)

func PeerWrites

func PeerWrites(varDir, nodename string, data instance.Status) (bool, error)

PeerWrites records whether the instance of a peer writes the data of the object of varDir, as the status it publishes says, since at, when its record here says otherwise: a peer back after it was lost, or one whose record was not received. A peer never seen writing is not recorded as stopped. It says whether the record changed.

func PeerWritesStopped

func PeerWritesStopped(varDir, nodename string, at time.Time) (bool, error)

PeerWritesStopped records that the instance of a node the cluster lost no longer writes the data of the object of varDir, since at, when its record says it wrote: a dead node writes nothing, and says nothing either. The time it was lost is a little after its last write, which counts a little more of writes missed, not less. It says whether the record changed.

The loss always stops a record saying the node writes: the time of the record comes from the clock of the peer, ahead of this one maybe, and the stop is then recorded right after it, so a status of the peer from before its loss, replayed from a cache, is older still and changes nothing.

func RedactSecrets

func RedactSecrets(b []byte, kind string) ([]byte, error)

RedactSecrets returns b with the value of every keyword declared with RedactSecret, and of every key of a sec or usr data section, replaced by asterisks. kind is the object kind the configuration belongs to, empty for a node or cluster configuration.

Only those values change. The parser writes back verbatim the lines it was not asked to touch, so comments, blank lines, spacing, inline comments and multiline layout are all preserved, and the substitution is refused if it would not parse back to the redacted value.

An unparseable configuration is an error rather than a configuration returned unredacted.

func RegisterClusterConfigCheck

func RegisterClusterConfigCheck(f func(*xconfig.T) xconfig.Alerts)

RegisterClusterConfigCheck adds a check of the sections of the cluster configuration against one another, which its validation runs, so that a write making it fail is refused.

func SetClusterConfig

func SetClusterConfig() (cluster.Config, error)

SetClusterConfig refreshes the config data cache and returns the new config data.

func WithClusterConfigFile

func WithClusterConfigFile(s string) funcopt.O

WithConfigFile sets a non-standard configuration location.

func WithConfigData

func WithConfigData(b any) funcopt.O

WithConfigData sets configuration file (string) or content ([]byte) overriding what is installed in the config file. Useful for testing volatile services.

func WithConfigFile

func WithConfigFile(s string) funcopt.O

WithConfigFile sets a non-standard configuration location.

func WithLogger

func WithLogger(s *plog.Logger) funcopt.O

WithLogger let the factory user decide what kind of logging he wants

func WithStaticReferences

func WithStaticReferences() funcopt.O

WithStaticReferences has the object evaluate its configuration from the configuration alone: a reference evaluating only at run time, as what another resource exposes or the head of a volume, is an error ErrRuntimeReference rather than something run.

func WithVolatile

func WithVolatile(s bool) funcopt.O

WithVolatile makes sure not data is ever written by the object.

func WritesStoppedAt

func WritesStoppedAt(varDir string) time.Time

WritesStoppedAt is when the instances of the object of varDir stopped writing its data, the latest stop the records of its nodes say, and zero while one of them writes, or when none ever said.

A copy of the data, or a snapshot of it, misses the writes made since it was taken, which end when the instance writing them stops: the copy of a stopped instance does not age.

One instance writing is enough: a node coming back after it died records its stop at its return, later than the start of the node that took over.

Types

type Actor

type Actor interface {
	Core

	PG() *pg.Config
	IsVolatile() bool
	ResourceSets() resourceset.L
	ResourceByID(rid string) resource.Driver
	GetActionResDeps() *actionresdeps.Store
	ConfigureResources()
	IsDisabled() bool

	Boot(context.Context) error
	Restart(context.Context) error
	Run(context.Context) error
	Shutdown(context.Context) error
	Start(context.Context) error
	StartStandby(context.Context) error
	Stop(context.Context) error
	Install(context.Context) error
	PRStart(context.Context) error
	PRStop(context.Context) error
	PGUpdate(context.Context) error
	Provision(context.Context) error
	Unprovision(context.Context) error
	ResourceHandlingDevice(ctx context.Context, p device.T) (resource.Driver, error)
	ResourceHandlingFile(ctx context.Context, filename string) (resource.Driver, error)
	SetProvisioned(context.Context) error
	SetUnprovisioned(context.Context) error
	SyncFull(context.Context) error
	SyncResync(context.Context) error
	SyncRestore(context.Context) error
	SyncSnapshots(context.Context) ([]SyncSnapshot, error)
	RestoredConfig(context.Context) ([]byte, []string, error)
	SyncSplit(context.Context) error
	SyncUpdate(context.Context) error
	SyncIngest(context.Context) error
	Enter(context.Context, string) error
	ContainerLogs(context.Context, string, bool, int) error
	ContainerLogsStream(context.Context, string, bool, int) (<-chan []byte, error)

	Schedules() schedule.Table
	RefreshResInfo(context.Context) (resource.Infos, error)

	HardAffinity() []string
	HardAntiAffinity() []string
	SoftAffinity() []string
	SoftAntiAffinity() []string
	// contains filtered or unexported methods
}

Actor is implemented by object kinds supporting start, stop, ...

func NewActor

func NewActor(p naming.Path, opts ...funcopt.O) (Actor, error)

NewActor returns a Actor interface from an object path

type ActorStatus

type ActorStatus struct {
	Avail            status.T         `json:"avail"`
	Frozen           string           `json:"frozen"`
	Orchestrate      string           `json:"orchestrate"`
	Overall          status.T         `json:"overall"`
	PlacementPolicy  placement.Policy `json:"placement_policy"`
	PlacementState   placement.State  `json:"placement_state"`
	Provisioned      provisioned.T    `json:"provisioned"`
	Topology         topology.T       `json:"topology"`
	UpInstancesCount int              `json:"up_instances_count"`
	Flex             *FlexStatus      `json:"flex,omitempty"`
}

func (*ActorStatus) AllowedInstances

func (s *ActorStatus) AllowedInstances() int

AllowedInstances is the number of instances the topology allows up at once: one for a failover object, flex_max for a flex one, and 0 when the topology sets no bound, as a flex object whose bounds are not known yet.

func (*ActorStatus) DeepCopy

func (s *ActorStatus) DeepCopy() *ActorStatus

func (*ActorStatus) ExcessInstances

func (s *ActorStatus) ExcessInstances() int

ExcessInstances is the number of instances up beyond the ones the topology allows, as two instances of a failover object, which may write the shared resources at once: an error, where a warn status says no more than something is not as it should be.

func (*ActorStatus) ExpectedInstances

func (s *ActorStatus) ExpectedInstances() int

ExpectedInstances is the number of instances the object is expected to run: the flex target, or one, as om mon reads it in its "up/expected" counter.

type ArrayItem

type ArrayItem struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type ArrayPush

type ArrayPush struct {
	Name  string `json:"name"`
	Type  string `json:"type"`
	Keys  int    `json:"keys"`
	Error string `json:"error,omitempty"`
}

ArrayPush is what came of pushing one array to the collector.

type Ccfg

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

Ccfg is the clusterwide configuration store.

The content is the same as node.conf, and is overridden by the definition found in node.conf.

func NewCluster

func NewCluster(opts ...funcopt.O) (*Ccfg, error)

func (*Ccfg) App

func (t *Ccfg) App() string

func (*Ccfg) Cluster

func (t *Ccfg) Cluster() (*Ccfg, error)

Cluster returns a cached Ccfg struct pointer. If none is already cached, allocate a new Ccfg{} and cache it.

func (*Ccfg) ComputeClaims

func (t *Ccfg) ComputeClaims() (map[string]int64, error)

ComputeClaims is what the object claims of each compute type, cluster-wide: what its processes are capped to, on every instance it may run at once.

A failover object runs one started instance, and a flex object as many as its target. Every other instance runs its standby resources. The instances started are counted where they take the most, since any node may be the one running them: the claim is what the object may take, not what it takes now.

A process capped by nothing takes what it finds, and makes the claim of the object Unbounded on that type.

func (*Ccfg) Config

func (t *Ccfg) Config() *xconfig.T

func (*Ccfg) ConfigData

func (t *Ccfg) ConfigData() any

func (*Ccfg) ConfigFile

func (t *Ccfg) ConfigFile() string

ConfigFile returns the absolute path of an opensvc object configuration file.

func (*Ccfg) DRPNodes

func (t *Ccfg) DRPNodes() ([]string, error)

DRPNodes implements DRPNodes() ([]string, error) to retrieve cluster drpnodes from config cluster.drpnodes This is required because embedded implementation from core is not valid for ccfg

func (*Ccfg) Delete

func (t *Ccfg) Delete(ctx context.Context) error

func (*Ccfg) DeleteSection

func (t *Ccfg) DeleteSection(ctx context.Context, rids ...string) error

DeleteSection deletes a resource section from object.

TODO: Fix/verify following doc If no resource selector is set, remove all etc, var and log file belonging to the object.

If a resource selector is set, only delete the corresponding sections in the configuration file.

func (*Ccfg) Dereference

func (t *Ccfg) Dereference(ref string) (string, error)

func (*Ccfg) DiscardAndEditConfig

func (t *Ccfg) DiscardAndEditConfig() error

func (*Ccfg) Domain

func (t *Ccfg) Domain() string

func (*Ccfg) EditConfig

func (t *Ccfg) EditConfig() error

func (*Ccfg) Env

func (t *Ccfg) Env() string

func (*Ccfg) Eval

func (t *Ccfg) Eval(k key.T) (interface{}, error)

Eval returns a keyword value

func (*Ccfg) EvalAs

func (t *Ccfg) EvalAs(k key.T, impersonate string) (interface{}, error)

func (*Ccfg) EvalConfig

func (t *Ccfg) EvalConfig() (rawconfig.T, error)

func (*Ccfg) EvalConfigAs

func (t *Ccfg) EvalConfigAs(nodename string) (rawconfig.T, error)

func (*Ccfg) FQDN

func (t *Ccfg) FQDN() string

func (*Ccfg) FlexMax

func (t *Ccfg) FlexMax() (int, error)

func (*Ccfg) FlexMin

func (t *Ccfg) FlexMin() (int, error)

func (*Ccfg) FlexTarget

func (t *Ccfg) FlexTarget() (int, error)

func (*Ccfg) FreshStatus

func (t *Ccfg) FreshStatus(ctx context.Context) (instance.Status, error)

func (*Ccfg) Get

func (t *Ccfg) Get(k key.T) (interface{}, error)

Get returns a keyword value

func (*Ccfg) ID

func (t *Ccfg) ID() uuid.UUID

func (*Ccfg) IsVolatile

func (t *Ccfg) IsVolatile() bool

func (*Ccfg) KeywordLookup

func (t *Ccfg) KeywordLookup(k key.T, sectionType string) *keywords.Keyword

func (*Ccfg) List

func (t *Ccfg) List() (string, error)

List returns the stringified path as data

func (*Ccfg) Log

func (t *Ccfg) Log() *plog.Logger

func (*Ccfg) LogDir

func (t *Ccfg) LogDir() string

func (*Ccfg) MonitorStatus

func (t *Ccfg) MonitorStatus(ctx context.Context) (instance.Status, error)

func (*Ccfg) Name

func (t *Ccfg) Name() string

func (*Ccfg) NewCompliance

func (t *Ccfg) NewCompliance() (*compliance.T, error)

func (*Ccfg) Node

func (t *Ccfg) Node() (*Node, error)

Node returns a cached Node struct pointer. If none is already cached, allocate a new Node{} and cache it.

func (*Ccfg) Nodes

func (t *Ccfg) Nodes() ([]string, error)

Nodes implements Nodes() ([]string, error) to retrieve cluster nodes from config cluster.nodes This is required because embedded implementation from core is not valid for ccfg

func (*Ccfg) Orchestrate

func (t *Ccfg) Orchestrate() string

func (*Ccfg) PGClean

func (t *Ccfg) PGClean(ctx context.Context)

func (*Ccfg) Path

func (t *Ccfg) Path() naming.Path

func (*Ccfg) Peers

func (t *Ccfg) Peers() ([]string, error)

func (*Ccfg) Placement

func (t *Ccfg) Placement() placement.Policy

func (*Ccfg) PostCommit

func (t *Ccfg) PostCommit() error

func (*Ccfg) Priority

func (t *Ccfg) Priority() priority.T

func (*Ccfg) RawConfig

func (t *Ccfg) RawConfig() (rawconfig.T, error)

RawConfig gets a keyword value

func (*Ccfg) RecoverAndEditConfig

func (t *Ccfg) RecoverAndEditConfig() error

func (*Ccfg) Set

func (t *Ccfg) Set(ctx context.Context, kops ...keyop.T) error

Set changes or adds a keyword and its value in the configuration file.

func (*Ccfg) SetPostCommit

func (t *Ccfg) SetPostCommit(fn func() error)

func (*Ccfg) SetVolatile

func (t *Ccfg) SetVolatile(v bool)

func (*Ccfg) Status

func (t *Ccfg) Status(ctx context.Context) (instance.Status, error)

func (*Ccfg) String

func (t *Ccfg) String() string

func (*Ccfg) TmpDir

func (t *Ccfg) TmpDir() string

func (*Ccfg) Topology

func (t *Ccfg) Topology() topology.T

func (*Ccfg) Unset

func (t *Ccfg) Unset(ctx context.Context, kws ...key.T) error

Unset unsets keywords

func (*Ccfg) Update

func (t *Ccfg) Update(ctx context.Context, deleteSections []string, unsetKeys []key.T, keyOps []keyop.T) (err error)

Update updates applies configurations changes in the configuration file.

func (*Ccfg) ValidateConfig

func (t *Ccfg) ValidateConfig(ctx context.Context) (xconfig.Alerts, error)

ValidateConfig validates the configuration

func (*Ccfg) ValidateSections

func (t *Ccfg) ValidateSections(cfg *xconfig.T) xconfig.Alerts

ValidateSections runs the checks of the sections of the cluster configuration against one another.

func (*Ccfg) VarDir

func (t *Ccfg) VarDir() string

type CertificateRenewOptions

type CertificateRenewOptions struct {
	// Force issues a certificate even when the current one is not due.
	Force bool

	// Webroot is the host directory the http-01 challenge token is
	// written in, acme.webroot when empty. It is ignored when HTTP01
	// is set.
	Webroot string

	// HTTP01 writes the http-01 challenge token where the http server
	// of the domains serves it from, as a task writes it in a volume of
	// its object, confined there.
	HTTP01 challenge.Provider

	// Accounts are the secs whose account at the directory the sec
	// takes when it holds none there: the first of them holding one
	// registered at the directory, with the email of the sec. The secs
	// a task renews share one account so, as a directory limits the
	// accounts an address registers, and each keeps it: the one that
	// registered it going does not take it away.
	Accounts []naming.Path

	// RenewBefore is how long before its expiry a certificate is
	// due when the sec sets no acme.renew_before, 30 days when
	// zero. The daemon renews the cluster ca a longer time before,
	// as a node away when it is renewed trusts the former one until
	// it is back.
	RenewBefore time.Duration
}

CertificateRenewOptions says how a certificate is renewed.

type CertificateRenewal

type CertificateRenewal struct {
	// Renewed is true when a certificate was issued.
	Renewed bool `json:"renewed"`

	// Reason says why a certificate was issued, or why none was.
	Reason string `json:"reason"`

	// Sec is the sec the certificate is of, for a renewal of several.
	Sec string `json:"sec,omitempty"`

	Domains []string `json:"domains"`

	// Directory is the ACME directory the certificate is issued by,
	// empty for a certificate generated, self-signed or signed by the
	// ca of the sec.
	Directory string    `json:"directory,omitempty"`
	NotAfter  time.Time `json:"not_after,omitzero"`
}

CertificateRenewal tells what a certificate renewal did.

func (CertificateRenewal) Render

func (t CertificateRenewal) Render() string

Render is the renewal as a person reads it.

type Cfg

type Cfg interface {
	DataStore
}

Cfg is the cfg-kind object.

These objects are unencrypted key-value store. Values can be binary or text.

A Key can be installed as a file in a Vol, then exposed to apps and containers. A Key can be exposed as a environment variable for apps and containers. A Signal can be sent to consumer processes upon exposed key value changes.

type CollectorConfigRaw

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

func (*CollectorConfigRaw) AsConfig

func (t *CollectorConfigRaw) AsConfig() *collector.Config

func (*CollectorConfigRaw) FeederUrl

func (t *CollectorConfigRaw) FeederUrl() string

func (*CollectorConfigRaw) HasServerV3

func (t *CollectorConfigRaw) HasServerV3() bool

func (*CollectorConfigRaw) ServerUrl

func (t *CollectorConfigRaw) ServerUrl() string

type CollectorProblem

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

type ComputeClaimer

type ComputeClaimer interface {
	ComputeClaims() (map[string]int64, error)
}

ComputeClaimer is an object claiming compute of its namespace.

type Configurer

type Configurer interface {
	ConfigFile() string
	Config() *xconfig.T
	EditConfig() error
	RecoverAndEditConfig() error
	DiscardAndEditConfig() error
	RawConfig() (rawconfig.T, error)
	EvalConfig() (rawconfig.T, error)
	EvalConfigAs(string) (rawconfig.T, error)
	Eval(key.T) (interface{}, error)
	EvalAs(key.T, string) (interface{}, error)
	Get(key.T) (interface{}, error)
	ValidateConfig(context.Context) (xconfig.Alerts, error)
	DeleteSection(context.Context, ...string) error
	Delete(context.Context) error
	Set(context.Context, ...keyop.T) error
	Update(context.Context, []string, []key.T, []keyop.T) error
	Unset(context.Context, ...key.T) error
}

Configurer is implemented by object kinds supporting get, set, unset, eval, edit, ...

func CreatedConfig

func CreatedConfig(p naming.Path, b []byte, restore bool, sets ...keyop.T) (Configurer, []byte, error)

CreatedConfig returns the configuration b of an object created at p, as it is written, and the configurer reading it. The keyword operations sets apply last, so a keyword they name is kept, recorded or not: they say what the creator wants of this object.

The DEFAULT section is given a header, as OpenSVC v2 wrote it, so the keywords of that section are grouped under it whatever their rank.

Unless restore, the configuration is another object's copied, as a clone, a template or a configuration saved elsewhere: what it recorded of the thing it was made for does not come with it, the id it was created with, the disk its provision created, the address it drew. They are written again, for the new object, when it makes what they name. The id is given again at once, as an object has one from the moment it is created. With restore, the object is the one the configuration was saved from, and keeps them; it is given an id only when the configuration holds none.

func NewConfigurer

func NewConfigurer(p naming.Path, opts ...funcopt.O) (Configurer, error)

NewConfigurer returns a Configurer interface from an object path

type Core

type Core interface {
	Configurer

	Nodes() ([]string, error)
	Path() naming.Path
	FQDN() string

	FreshStatus(context.Context) (instance.Status, error)
	MonitorStatus(context.Context) (instance.Status, error)
	Status(context.Context) (instance.Status, error)
	// contains filtered or unexported methods
}

Core is implemented by all object kinds.

func NewCore

func NewCore(p naming.Path, opts ...funcopt.O) (Core, error)

NewCore returns a Core interface from an object path

type Data

type Data[T Dataer] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Data defines a shared holder for all objects Dataer

var (

	// StatusData is the package data holder for all objects statuses
	StatusData *Data[Status]
)

func NewData

func NewData[T Dataer]() *Data[T]

func (*Data[T]) GetAll

func (c *Data[T]) GetAll() []DataElement[T]

func (*Data[T]) GetByPath

func (c *Data[T]) GetByPath(p naming.Path) *T

func (*Data[T]) GetPaths

func (c *Data[T]) GetPaths() naming.Paths

func (*Data[T]) Set

func (c *Data[T]) Set(p naming.Path, v *T)

func (*Data[T]) Unset

func (c *Data[T]) Unset(p naming.Path)

type DataElement

type DataElement[T Dataer] struct {
	Path  naming.Path
	Value *T
}

type DataStore

type DataStore interface {
	Core

	AddKey(name string, b []byte) error
	ChangeKey(name string, b []byte) error
	DecodeKey(name string) ([]byte, error)
	DecodeKeys(name ...string) ([][]byte, error)
	EditKey(name string) error
	InstallKey(name string) error
	InstallKeyTo(KVInstall) (bool, error)
	RemoveKey(name string) error
	RenameKey(name, to string) error

	Allow(string) bool
	Shares() []string
	HasKey(name string) bool
	AllKeys() ([]string, error)
	MatchingKeys(string) ([]string, error)

	TransactionAddKey(name string, b []byte) error
	TransactionChangeKey(name string, b []byte) error
	TransactionChangeOrAddKey(name string, b []byte) error
	TransactionRemoveKey(name string) error
	TransactionRenameKey(name, to string) error
}

DataStore is the base interface of sec, cfg and usr objects

func NewDataStore

func NewDataStore(p naming.Path, opts ...funcopt.O) (DataStore, error)

NewDataStore returns a DataStore interface from an object path

type Dataer

type Dataer interface {
	Status
}

type Digest

type Digest struct {
	IsCompat  bool                `json:"is_compat"`
	Instances instance.StatesList `json:"instances"`
	Object    Status              `json:"object"`
	Path      naming.Path         `json:"path"`
}

Digest is a composite extract of different parts of the cluster status.

func NewStatus

func NewStatus() *Digest

NewStatus allocates and return a struct to host an object full state dataset.

func (Digest) LoadTreeNode

func (t Digest) LoadTreeNode(head *tree.Node, nodes []string)

LoadTreeNode add the tree nodes representing the type instance into another.

func (Digest) ObjectWarningsString

func (t Digest) ObjectWarningsString() string

ObjectWarningsString returns a string presenting notable information at the object, instances-aggregated, level.

func (Digest) Render

func (t Digest) Render(nodes []string) string

Render returns a human friendy string representation of the type instance.

func (Digest) Tree

func (t Digest) Tree(nodes []string) *tree.Tree

Tree returns a tree loaded with the type instance.

type FlexStatus

type FlexStatus struct {
	Target int `json:"target,omitempty"`
	Min    int `json:"min,omitempty"`
	Max    int `json:"max,omitempty"`
}

func (*FlexStatus) DeepCopy

func (s *FlexStatus) DeepCopy() *FlexStatus

type KVInstall

type KVInstall struct {
	Required      bool
	ToLog         *plog.Logger
	ToHead        string
	ToPath        string
	FromPattern   string
	FromStore     naming.Path
	Source        string
	AccessControl KVInstallAccessControl
	Signals       *volsignal.T

	// Render, when set, makes the file installed from a key out of the
	// key content: a template rendered on the node. The file then
	// depends on more than the key, so it is compared to what it
	// renders to at each install, its time saying nothing.
	Render func(key string, b []byte) ([]byte, error)

	// LogUnchanged logs what the install leaves as it is, a file up to
	// date or a key the store does not hold, as an install report asked
	// by the user shows them. A start installs quietly what has not
	// changed.
	LogUnchanged bool

	// Wrote, when set, is called with each file the install wrote,
	// relative to ToHead: the files of a key pattern or a directory
	// key one by one, rather than the destination of the line.
	Wrote func(path string)

	// Holds, when set, is called with each file the install leaves at
	// its destination, written or found up to date, relative to
	// ToHead: what the line installs, as against what it changed, so
	// the file of a key the store no longer holds can be told.
	Holds func(path string)

	// Line, when set, names the install line the item is one of: a
	// line installing from the datastores a pattern names is an item
	// per datastore, each with its FromStore and its ToPath.
	Line string
	// contains filtered or unexported fields
}

func (KVInstall) IsZero

func (t KVInstall) IsZero() bool

func (KVInstall) RelativeToPath

func (t KVInstall) RelativeToPath() string

func (KVInstall) String

func (t KVInstall) String() string

type KVInstallAccessControl

type KVInstallAccessControl struct {
	User  string
	Group string
	Perm  os.FileMode

	// always align dir access
	DirUser  string
	DirGroup string
	DirPerm  os.FileMode

	// only align dir access on makedir
	MakedirUser  string
	MakedirGroup string
	MakedirPerm  os.FileMode
}

type KeyStore

type KeyStore interface {
	GenCert() error
	RenewCertificate(ctx context.Context, opts CertificateRenewOptions) (CertificateRenewal, error)
	GenCertificateSigningRequest() ([]byte, error)
	PKCS(password []byte) ([]byte, error)
}

KeyStore is implemented by encrypting KeyStore object kinds (usr, sec).

type Migration

type Migration struct {
	Sets    []keyop.T
	Unsets  []key.T
	Deletes []string

	// Notes is what changed, in the words of whoever has to read the
	// configuration afterwards, one line per change.
	Notes []string

	// Refusals is what a rule recognized and could not write, with the
	// reason. A configuration keeps what nothing can migrate for it.
	Refusals []string
}

Migration is what a configuration has to become for om to run what it describes, as the keyword changes a configuration update takes.

It is expressed that way so that it lands through the path every other configuration write takes: the same validation, the same policy, the same claim on a pool.

func MigrateConfig

func MigrateConfig(cfg *xconfig.T) Migration

MigrateConfig is what a configuration has to become for om to run what it describes.

A configuration written for om2 describes things om3 no longer reads that way. What it asked for is still possible, in another shape, and the shape is what this writes: the configuration says the same thing afterwards, in words om3 reads.

It changes nothing by itself. What it answers is what a configuration update would take, so that the caller can show it before writing it.

func MigrateNodeConfig

func MigrateNodeConfig(cfg *xconfig.T) Migration

MigrateNodeConfig is what a node or cluster configuration has to become for om to run what it describes. It changes nothing by itself, as MigrateConfig.

type MigrationRule

type MigrationRule struct {
	// Doc says what the rule rewrites, in the words of the help of the
	// command applying it: one paragraph, wrapped where it is shown.
	Doc string
	// contains filtered or unexported fields
}

MigrationRule is one change of shape a configuration written for an older agent takes.

type MigrationRules

type MigrationRules []MigrationRule

MigrationRules is the rules a kind of configuration is migrated by, in the order they apply.

func MigrationRulesOf

func MigrationRulesOf(kind naming.Kind) MigrationRules

MigrationRulesOf returns the rules the configuration of a kind of object is migrated by: the node ones for the cluster configuration, which holds the same keywords as the node one.

func (MigrationRules) Apply

func (t MigrationRules) Apply(cfg *xconfig.T) Migration

Apply returns what the configuration has to become by the rules.

func (MigrationRules) Doc

func (t MigrationRules) Doc(width int) string

Doc lists the rules as the help of a command shows them, a dash heading each, wrapped at width.

type Node

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

Node is the node struct.

func LoadApplied

func LoadApplied(consumer string, opts ...funcopt.O) (*Node, error)

LoadApplied returns the node configured as it was when the janitor named consumer last applied its configuration, or nil when it never did. The node is volatile, and opts apply to it as to NewNode.

func NewNode

func NewNode(opts ...funcopt.O) (*Node, error)

NewNode allocates a node.

func (*Node) AllowEnvs

func (t *Node) AllowEnvs() []string

AllowEnvs returns the envs of the objects allowed to run on this node, nil when the node env decides: the node.allow_envs keyword of the node or of the cluster configuration.

func (*Node) AllowsEnv

func (t *Node) AllowsEnv(env string) bool

AllowsEnv reports whether an object of the env may run on this node.

func (*Node) App

func (t *Node) App() string

func (*Node) Array

func (t *Node) Array(name string) array.Driver

Array returns the driver of the array named in the node or cluster configuration, or nil when no section names it or no driver serves its type.

The name is the one of the section, and the driver is chosen by the type that section declares: the two are not the same, and looking a driver up by the name of the array only ever worked for an array named after its own type.

func (*Node) Arrays

func (t *Node) Arrays() []array.Driver

func (*Node) CNIConfig

func (t *Node) CNIConfig() (string, error)

func (*Node) CNIPlugins

func (t *Node) CNIPlugins() (string, error)

func (Node) Checks

func (t Node) Checks(ctx context.Context) (check.ResultSet, error)

Checks finds and runs the check drivers. Results are aggregated and sent to the collector.

func (*Node) Cluster

func (t *Node) Cluster() (id, name string)

Cluster returns the id and the name of the cluster of the node, which the runs it writes into a store say: several clusters may write one store.

func (*Node) ClusterConfigFile

func (t *Node) ClusterConfigFile() string

func (*Node) Collector3RestAPIURL

func (t *Node) Collector3RestAPIURL() (*url.URL, error)

func (Node) CollectorComplianceClient

func (t Node) CollectorComplianceClient() (*collector.Client, error)

func (*Node) CollectorFeedClient

func (t *Node) CollectorFeedClient() (*collector.Client, error)

func (*Node) CollectorFeeder

func (t *Node) CollectorFeeder() (*httphelper.T, error)

CollectorFeeder returns new collector feeder client from config

func (Node) CollectorInitClient

func (t Node) CollectorInitClient() (*collector.Client, error)

func (*Node) CollectorRawConfig

func (t *Node) CollectorRawConfig() *CollectorConfigRaw

func (*Node) CollectorRestAPIClient

func (t *Node) CollectorRestAPIClient() *http.Client

func (*Node) CollectorRestAPIURL

func (t *Node) CollectorRestAPIURL() (*url.URL, error)

func (*Node) CollectorServer

func (t *Node) CollectorServer() (*httphelper.T, error)

CollectorServer returns new collector server client from config

func (*Node) CollectorServerWithAuth

func (t *Node) CollectorServerWithAuth(auth string) (*httphelper.T, error)

CollectorServer returns new collector server client from config

func (*Node) CollectorServerWithoutAuth

func (t *Node) CollectorServerWithoutAuth() (*httphelper.T, error)

CollectorServer returns new collector server client from config

func (*Node) Config

func (t *Node) Config() *xconfig.T

func (*Node) ConfigData

func (t *Node) ConfigData() any

func (*Node) ConfigFile

func (t *Node) ConfigFile() string

func (*Node) DNSUDSDir

func (t *Node) DNSUDSDir() string

func (*Node) DRPNodes

func (t *Node) DRPNodes() ([]string, error)

func (Node) DeleteSection

func (t Node) DeleteSection(s ...string) error

DeleteSection removes sections from node config

func (*Node) Dequeue

func (t *Node) Dequeue() error

Dequeue runs the actions the collector queued for the node, and posts their results.

Each request to the collector has a deadline of its own, and the actions have none, as in v2: an action is an array disk creation or a service action, which can run for minutes, and killing it midway would leave the array or the service half changed, with no result telling the collector so.

func (*Node) Dereference

func (t *Node) Dereference(ref string) (string, error)

func (Node) DiscardAndEditConfig

func (t Node) DiscardAndEditConfig() error

func (Node) Drivers

func (t Node) Drivers() (interface{}, error)

Drivers returns the builtin drivers list

func (Node) EditConfig

func (t Node) EditConfig() error

func (*Node) EncapNodes

func (t *Node) EncapNodes() ([]string, error)

func (*Node) Env

func (t *Node) Env() string

Env returns the env of the node, the node.env keyword of the node or of the cluster configuration.

func (*Node) Eval

func (t *Node) Eval(ctx context.Context, kw string) (interface{}, error)

Eval returns a keyword evaluated value

func (*Node) EvalAs

func (t *Node) EvalAs(ctx context.Context, kw string, impersonate string) (interface{}, error)

EvalAs returns a keyword evaluated value, as if the evaluator was another node

func (*Node) EvalConfig

func (t *Node) EvalConfig() (rawconfig.T, error)

func (*Node) EvalConfigAs

func (t *Node) EvalConfigAs(impersonate string) (rawconfig.T, error)

func (*Node) Exists

func (t *Node) Exists() bool

func (Node) ForceSysreport

func (t Node) ForceSysreport() error

ForceSysreport sends every file the agent tracks, as a full report the collector replaces what it holds of the node with.

func (*Node) Freeze

func (t *Node) Freeze() error

Freeze creates a persistent flag file that prevents orchestration of the object instance.

The flag records a freeze of the cluster when the node monitor says so, for the freeze to reach the nodes that missed it.

func (*Node) Frozen

func (t *Node) Frozen() time.Time

Frozen returns the unix timestamp of the last freeze.

func (*Node) FrozenScope

func (t *Node) FrozenScope() freeze.Scope

FrozenScope returns the scope of the freeze of the node, empty when it is not frozen.

func (*Node) Get

func (t *Node) Get(ctx context.Context, kw string) (interface{}, error)

Get returns a keyword unevaluated value

func (*Node) ID

func (t *Node) ID() uuid.UUID

func (Node) IsVolatile

func (t Node) IsVolatile() bool

func (Node) KeywordLookup

func (t Node) KeywordLookup(k key.T, sectionType string) *keywords.Keyword

func (*Node) ListArrays

func (t *Node) ListArrays() []ArrayItem

func (*Node) ListPools

func (t *Node) ListPools() []string

func (*Node) ListStores

func (t *Node) ListStores() []StoreItem

ListStores returns the stores declared in the cluster configuration, then the ones declared in the secs of the node.

func (*Node) ListSwitches

func (t *Node) ListSwitches() []SwitchItem

ListSwitches returns the switch sections of the node and cluster configuration.

func (Node) LoadDisks

func (t Node) LoadDisks() (disks.Disks, error)

func (Node) LoadPkg

func (t Node) LoadPkg() ([]packages.Pkg, error)

func (Node) LoadSystem

func (t Node) LoadSystem() (asset.Data, error)

func (*Node) Log

func (t *Node) Log() *plog.Logger

func (*Node) LogDir

func (t *Node) LogDir() string

func (*Node) MergedConfig

func (t *Node) MergedConfig() *xconfig.T

func (*Node) Nameservers

func (t *Node) Nameservers() ([]string, error)

func (Node) NewCompliance

func (t Node) NewCompliance() (*compliance.T, error)

func (*Node) Nodes

func (t *Node) Nodes() ([]string, error)

func (Node) PRKey

func (t Node) PRKey() (string, error)

PRKey returns the SCSI3-PR key stored as node.prkey in the node config. It sets a new key if not found.

func (*Node) Pools

func (t *Node) Pools() []pool.Pooler

func (*Node) PostCommit

func (t *Node) PostCommit() error

func (Node) PrintCapabilities

func (t Node) PrintCapabilities() (capabilities.L, error)

PrintCapabilities load and return node capabilities

func (Node) PushArrays

func (t Node) PushArrays(ctx context.Context, name string) ([]ArrayPush, error)

PushArrays reports the configuration of the arrays of the cluster to the collector.

The collector is fed through the jsonrpc method it exports for the type of each array, "update_freenas" for a freenas and so on, with the section names and their contents. That is the api v2 fed.

It is the jsonrpc api and not a rest one because oc3, which takes the roles of the old collector over one at a time, exposes no array feed yet: its feeder serves the node, the instance and the object, and nothing about an array. oc3 will drop the jsonrpc api when it has taken everything over, so this call is to be moved to the rest feed the day oc3 grows one, and a rest endpoint is to be preferred over jsonrpc wherever both exist.

One array failing does not stop the others: an array that is down or whose credentials have expired must not keep the ones that are reachable from being reported. What failed is in the result, and in the error.

func (Node) PushAsset

func (t Node) PushAsset() (asset.Data, error)

PushAsset assembles the asset inventory data. Each entry value comes from: * overrides (in config) * probes * default (code)

func (Node) PushAssetDryRun

func (t Node) PushAssetDryRun() (asset.Data, error)

func (Node) PushDisks

func (t Node) PushDisks() (disks.Disks, error)

func (Node) PushDisksDryRun

func (t Node) PushDisksDryRun() (disks.Disks, error)

func (Node) PushPkg

func (t Node) PushPkg() ([]packages.Pkg, error)

func (Node) PushPkgDryRun

func (t Node) PushPkgDryRun() ([]packages.Pkg, error)

func (Node) PushRegistered

func (t Node) PushRegistered(ctx context.Context) error

PushRegistered sends the collector the initial inventory of a node just registered: asset, packages, disks, sysreport and checks. The collector then knows the node in details, and can serve it contextualized compliance rulesets, without waiting for the scheduled pushes.

The asset, package and disk pushes are required, the sysreport and checks pushes are not supported by every collector yet.

func (*Node) PushStats

func (t *Node) PushStats(ctx context.Context, o PushStatsOptions) (PushStatsResult, error)

PushStats sends the performance statistics of the node to the collector, as the pushstats action of the v2 agent did: cpu, memory, swap, load, block and network i/o read from sysstat, and the file system usage.

func (*Node) PushStatsDryRun

func (t *Node) PushStatsDryRun(ctx context.Context, o PushStatsOptions) (PushStatsResult, error)

PushStatsDryRun reads the statistics a push would send, and sends nothing.

func (Node) PushSwitches

func (t Node) PushSwitches(ctx context.Context, name string) ([]SwitchPush, error)

PushSwitches inventories the SAN switches of the node and cluster configuration, all of them or the one named, and reports their configuration to the collector.

The report goes to the switch feed of oc3. Where oc3 does not serve it, because the node feeds the old collector only or because the oc3 it feeds is older than the feed, it goes to the "update_<type>" jsonrpc method of the old collector, as v2 sent it. That fallback is to be removed when oc3 has replaced the old collector, which drops the jsonrpc api.

One switch failing does not stop the others: a switch out of reach must not keep the reachable ones from being reported.

func (*Node) RawConfig

func (t *Node) RawConfig() (rawconfig.T, error)

func (Node) RecoverAndEditConfig

func (t Node) RecoverAndEditConfig() error

func (Node) Register

func (t Node) Register(ctx context.Context, user, password, app string) error

Register logs in to the collector using the provided user credentials.

If the node is not already known to the collector, a new node uuid is generated by the collector and stored by the agent in the node config as a node.uuid key.

If user credentials are given, the POST /register collector handler is used, and the app code is supported. If no user credentials are given, the "register_node" jsonrpc handler is used, and app code is ignored.

If app is not set, the node is added to any app under the user's responsibility.

func (*Node) RegisterJoiningNode

func (t *Node) RegisterJoiningNode(ctx context.Context, nodename, prevUUID string) (string, error)

RegisterJoiningNode registers on the collector the node nodename joining the cluster, authenticated by this node registration id, and returns the new registration id of the joining node.

prevUUID is the registration id the joining node held before the join: the collector only registers a joining node already registered under its nodename, and moves it to the app and the cluster of this node.

func (*Node) SaveApplied

func (t *Node) SaveApplied(consumer string) error

SaveApplied records the configuration of the node, the cluster configuration merged, as the one the janitor named consumer applied.

A janitor undoes what the configuration it applied held and the one it applies no longer does. The configuration of the node changes through the daemon, a write made without it, an edit of the file or a restore, so the janitor diffs against what it applied, not against a change it was told of: a change made while the daemon was down would never be.

func (Node) ScanCapabilities

func (t Node) ScanCapabilities(ctx context.Context) (capabilities.L, error)

ScanCapabilities scan node capabilities and return new capabilities

func (Node) ScanSCSI

func (t Node) ScanSCSI(ctx context.Context, hba, target, lun string) error

ScanSCSI scans the SCSI hosts in search of new disks

func (*Node) Schedules

func (t *Node) Schedules() schedule.Table

func (Node) SendSysreport

func (t Node) SendSysreport(archive string, deleted []string, full bool) error

SendSysreport posts a sysreport to the oc3 feeder, as a multipart form: the archive in the "file" part, when there is one, each deleted file in a "deleted" part, and the "full" flag.

func (*Node) Set

func (t *Node) Set(ctx context.Context, kops ...keyop.T) error

Set sets a keyword value

func (*Node) SetVolatile

func (t *Node) SetVolatile(v bool)

func (*Node) ShowPools

func (t *Node) ShowPools(ctx context.Context) pool.StatusList

func (*Node) ShowPoolsByName

func (t *Node) ShowPoolsByName(ctx context.Context, name string) pool.StatusList

func (*Node) Stonith

func (t *Node) Stonith(nodename string) error

func (*Node) Store

func (t *Node) Store(ref string, reader naming.Path) (backup.Driver, error)

Store returns the driver of the store ref names, as the object at reader uses it, zero for a node command, configured from its section.

A bare name is a store#<name> section of the cluster configuration. A store of a sec is named from <sec> store#<name>, a ./ path naming a sec of the namespace of reader: the stores never clash, a bare name never meaning a store of a sec.

A store of a sec is one its namespace, or one it shares with, uses, its keys read as the object using it, and a store the daemon reaches over the network: a namespace does not choose a directory of the node, which the daemon would read and write as root.

func (Node) String

func (t Node) String() string

func (*Node) Switch

func (t *Node) Switch(name string) sanswitch.Driver

Switch returns the driver of the switch named in the node or cluster configuration, or nil when no section names it or no driver serves its type. The name is the one of the section, with or without its "switch#" prefix.

func (Node) Sysreport

func (t Node) Sysreport() error

Sysreport sends an archive of modified files the agent is configured to track, and the list of files deleted since the last call.

The collector is in charge of versioning this information and of reporting on changes.

func (*Node) TmpDir

func (t *Node) TmpDir() string

func (*Node) Unfreeze

func (t *Node) Unfreeze() error

Unfreeze removes the persistent flag file that prevents orchestration of the object instance.

func (*Node) Unset

func (t *Node) Unset(ctx context.Context, kws ...key.T) error

Unset removes keywords from node config

func (*Node) Update

func (t *Node) Update(ctx context.Context, deleteSections []string, unsetKeys []key.T, keyOps []keyop.T) (err error)

Update updates applies configurations changes in the configuration file.

func (*Node) ValidateConfig

func (t *Node) ValidateConfig() (xconfig.Alerts, error)

ValidateConfig node configuration

func (*Node) VarDir

func (t *Node) VarDir() string

type Nscfg

type Nscfg interface {
	Core
	PG() *pg.Config
}

type PushStatsOptions

type PushStatsOptions struct {
	Begin    time.Time
	End      time.Time
	StatsDir string
}

PushStatsOptions bound the statistics a push sends. A zero Begin starts where the last scheduled push left, a zero End is now.

type PushStatsResult

type PushStatsResult struct {
	Begin time.Time `json:"begin"`
	End   time.Time `json:"end"`

	// Batches is the number of requests the range was sent in, a day
	// of statistics each.
	Batches int `json:"batches"`

	// Rows is the number of rows read, by group.
	Rows map[string]int `json:"rows"`

	Series   int      `json:"series"`
	Points   int      `json:"points"`
	Skipped  []string `json:"skipped,omitempty"`
	Disabled []string `json:"disabled,omitempty"`

	// DryRun says the statistics were read and not sent.
	DryRun bool `json:"dry_run,omitempty"`
}

PushStatsResult tells what a push read and what the collector stored.

func (PushStatsResult) Render

func (t PushStatsResult) Render() string

Render is the result as a person reads it: the range read, how many rows of each group, and what the collector stored.

type QueuedAction

type QueuedAction struct {
	Command    string    `json:"command"`
	DequeuedAt time.Time `json:"dequeued_at"`
	Id         int       `json:"id"`
	Nodename   string    `json:"nodename"`
	QueuedAt   time.Time `json:"queued_at"`
	Status     string    `json:"status"`
	SvcId      string    `json:"svc_id"`
	Svcname    string    `json:"svcname"`
}

QueuedAction defines the model for QueuedAction.

type QueuedActionDone

type QueuedActionDone struct {
	DequeuedAt time.Time `json:"dequeued_at"`
	Id         int       `json:"id"`
	Ret        int       `json:"ret"`
	Stderr     string    `json:"stderr"`
	Stdout     string    `json:"stdout"`
}

QueuedActionDone defines the action queued result processed by the node

type QueuedActionRunning

type QueuedActionRunning struct {
	// Ids list of queued action ids
	Ids []int `json:"ids"`
}

QueuedActionRunning defines the model for QueuedActionRunning.

type QueuedActions

type QueuedActions struct {
	Actions []QueuedAction `json:"actions"`
}

QueuedActions defines the model for QueuedActions.

type RefsDocument

type RefsDocument map[string]map[string][]byte

RefsDocument is the keys of the sec and cfg an object references, by datastore, named "<kind>/<name>" relative to the namespace of the object, so a clone into another namespace lands its references there. The values are decoded, base64 in json.

func RefsDocumentOf

func RefsDocumentOf(ns string, paths naming.Paths) (RefsDocument, error)

RefsDocumentOf returns the keys of the datastores at paths, decoded, named relative to the namespace ns.

type RefsMode

type RefsMode string

RefsMode says how a restore applies a RefsDocument.

const (
	// RefsMissing creates the datastores and the keys absent, leaves the
	// keys there as they are, and reports the ones whose value differs.
	RefsMissing RefsMode = "missing"

	// RefsSkip applies no reference.
	RefsSkip RefsMode = "skip"

	// RefsOverwrite rewrites every key of the document.
	RefsOverwrite RefsMode = "overwrite"
)

func ParseRefsMode

func ParseRefsMode(s string) (RefsMode, error)

ParseRefsMode returns the mode s names, missing when empty.

type ResizeOptions

type ResizeOptions struct {
	// SkipHeadStage leaves the last stage of the chain alone. It holds
	// the head, which grows only where the object is up, so a node that
	// does not hold it up asks for the stages below it and is told there
	// is no stage of that number to run here when it reaches the last.
	SkipHeadStage bool

	// Force allows a resize that would grow one replica of a replicated
	// object on its own. The orchestration passes it for the phase that
	// runs once every node has grown what is under the replicated
	// resource.
	Force bool
}

ResizeOptions tunes a resize.

type ResizePlan

type ResizePlan struct {
	// Steps are ordered as they would be applied, which is up from the
	// device to the filesystem: the space has to exist before anything
	// is stretched onto it.
	Steps []ResizeStep `json:"steps"`

	// Stages is how many stages the chain is grown in, which is one more
	// than the number of replicated resources it crosses. Every node has
	// to finish a stage before any node starts the next one: a replicated
	// resource offers only what its smallest replica holds.
	Stages int `json:"stages"`
}

ResizePlan is what a resize would do, in the order it would do it.

func (ResizePlan) HasWork

func (t ResizePlan) HasWork() bool

HasWork says the plan changes something. A plan of links that all hold enough already changes nothing.

func (ResizePlan) String

func (t ResizePlan) String() string

type ResizeStep

type ResizeStep struct {
	// Path names the object the resource belongs to, and is empty for
	// the object the resize was asked of. A chain can cross into another
	// object: a volume resource stands for the head of its volume.
	Path    string `json:"path,omitempty"`
	RID     string `json:"rid"`
	Driver  string `json:"driver"`
	From    int64  `json:"from"`
	To      int64  `json:"to"`
	Comment string `json:"comment,omitempty"`

	// Skip says the link already holds what the link above it needs, so
	// there is nothing to do to it. It is listed so a plan shows the
	// whole chain.
	Skip bool `json:"skip,omitempty"`

	// Stage is the step of the chain this link is grown in. A chain
	// crossing no replicated resource has one stage, numbered 0.
	Stage int `json:"stage"`
	// contains filtered or unexported fields
}

ResizeStep is one link of the chain a resize walks, and the size that link is asked to reach.

func (ResizeStep) String

func (t ResizeStep) String() string

type Sec

type Sec interface {
	DataStore
	KeyStore
}

Sec is the sec-kind object.

These objects are encrypted key-value store. Values can be binary or text.

A Key can be installed as a file in a Vol, then exposed to apps and containers. A Key can be exposed as a environment variable for apps and containers. A Signal can be sent to consumer processes upon exposed key value changes.

type Status

type Status struct {
	Priority  priority.T `json:"priority"`
	Scope     []string   `json:"scope"`
	UpdatedAt time.Time  `json:"updated_at"`

	*ActorStatus
	*VolStatus
}

Status contains the object states obtained via aggregation of all instances states. It exists when an instance config exists somewhere

func (*Status) DeepCopy

func (s *Status) DeepCopy() *Status

type StoreItem

type StoreItem struct {
	// Ref is the reference to the store, as a store keyword names it.
	Ref  string `json:"ref"`
	Type string `json:"type"`
	URL  string `json:"url"`

	// Share are the namespaces whose objects may use the store: every
	// one for a store of the cluster configuration, the namespace of the
	// sec and the ones it shares with otherwise.
	Share []string `json:"share"`
}

StoreItem is a store declared in the cluster configuration, or in a sec.

type Svc

type Svc interface {
	Actor
}

Svc is the svc-kind object.

These objects contain front facing resources like app and containers.

type SwitchItem

type SwitchItem struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

SwitchItem is a switch section of the node or cluster configuration.

type SwitchPush

type SwitchPush struct {
	Name string `json:"name"`
	Type string `json:"type"`

	// Commands is the number of switch commands whose output was
	// pushed.
	Commands int `json:"commands"`

	// Via says which collector api received the push: "oc3", or
	// "jsonrpc" where oc3 does not serve the switch feed.
	Via string `json:"via,omitempty"`

	Error string `json:"error,omitempty"`
}

SwitchPush is what came of pushing one SAN switch to the collector.

type SyncSnapshot

type SyncSnapshot struct {
	RID string `json:"rid"`
	resource.Snapshot
}

SyncSnapshot is a point in time a sync resource of the object can restore.

type Usr

type Usr interface {
	Sec
}

Usr is the usr-kind object.

These objects contain a opensvc api user grants and credentials. They are required for basic, session and x509 api access, but not for OpenID access (where grants are embedded in the trusted token)

type UsrDB

type UsrDB struct{}

UsrDB implements UserGrants to authenticate user and get its grants

func (*UsrDB) GrantsFromUsername

func (_ *UsrDB) GrantsFromUsername(username string) ([]string, error)

GrantsFromUsername returns grants for username if username existing usr object

func (*UsrDB) GrantsFromUsernameAndPassword

func (_ *UsrDB) GrantsFromUsernameAndPassword(username, password string) ([]string, error)

GrantsFromUsernameAndPassword returns grants for username if username and password match existing usr object

func (*UsrDB) UXGrantsFromCgroup

func (_ *UsrDB) UXGrantsFromCgroup(cg string) (string, []string, error)

UXGrantsFromCgroup returns the name and the grants of the container resource whose process group holds the cgroup cg, the one of a process of a sidecar connected to the user socket: the uxgrant keyword of the resource. The name is "<path>:<rid>". It returns an empty name when no container resource of the node grants anything to that cgroup.

The configurations are read first, and an object is loaded only when one of its container sections sets uxgrant, to compute the process group of that resource.

func (*UsrDB) UsrFromUXUser

func (_ *UsrDB) UsrFromUXUser(login string, uid uint32) (string, []string, error)

UsrFromUXUser returns the name and the grants of the user of the system namespace whose uxuser keyword names login or uid, the local account connected to the user socket. A user naming neither is no local account, whatever its name. It returns an empty name when no user names them, and refuses several users naming them, a configuration to fix rather than grants to merge.

type Vol

type Vol interface {
	Actor
	Head() string
	HeadRID(context.Context) (string, error)
	ConfiguredSize() (int64, error)
	PoolName() (string, error)
	ExposedDevice(context.Context) *device.T
	ExposedDevices(context.Context) device.L
	ExposedDeviceResource(context.Context) resource.Driver
	SubDevice(context.Context) *device.T
	SubDevices(context.Context) device.L
	HoldersExcept(ctx context.Context, p naming.Path) (naming.Paths, error)
	Access() (volaccess.T, error)
	Children() (naming.Relations, error)
}

Vol is the vol-kind object.

These objects contain cluster-dependent fs, disk and sync resources.

They are created by feeding a volume resource configuration (cluster independent) to a pool.

type VolStatus

type VolStatus struct {
	Pool string `json:"pool,omitempty"`
	Size int64  `json:"size,omitempty"`
}

func (*VolStatus) DeepCopy

func (s *VolStatus) DeepCopy() *VolStatus

Source Files

Jump to

Keyboard shortcuts

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