actionrouter

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 14 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

This section is empty.

Variables

This section is empty.

Functions

func DefaultHumanRenderer

func DefaultHumanRenderer(data interface{}) string

func Do

func Do(t Actioner) error

Do is the switch method between local, remote or async mode. If Watch is set, end up starting a monitor on the selected objects.

func WaitOrchestration

func WaitOrchestration(ctx context.Context, c *client.T, orchestrationID uuid.UUID, node string) error

WaitOrchestration waits for the orchestration an action was accepted as, and says how it went.

It asks the daemon rather than watching the event stream. The orchestration outlives the request in the daemon, which answers the moment it ends and goes on answering afterwards, so a client that asks late, or that lost its connection and asks again, is still told how its request went. An end event missed is missed for good.

The node asked is the one that accepted the orchestration, which records it before handing its id out. The other nodes hear of it from the monitors carrying its id, a heartbeat later: asked at once, they answer they do not know it, which is the answer for an id they forgot. An empty node is the node the client talks to, for an answer that names none.

The daemon holds one request for an hour at most, so a longer wait is that request asked again: the orchestration outlives it, and asking again resumes the wait rather than restarting it. The wait ends when the caller's own deadline does, and a caller that set none waits for as long as it takes.

func WaitOrchestrationThroughRestarts

func WaitOrchestrationThroughRestarts(ctx context.Context, c *client.T, orchestrationID uuid.UUID, nodes []string) error

WaitOrchestrationThroughRestarts waits for an orchestration to end, through the restarts of the daemons: an upgrade of the packages restarts every daemon in turn, the one the client talks to among them.

That daemon answers nothing while it restarts, and the wait asks again once it is back. Restarted, it forgot the orchestrations it knew: the one still running it learns of again from the monitors of its peers, and one that ended while it was down it never hears of, so the nodes are asked for it in turn, through it, when it says it does not know it. The last node to upgrade ends the orchestration as its daemon leaves to restart, so the end is not the whole of it: the wait then holds until every node is live and idle, which is when the upgrade is over.

The wait ends when the caller's own deadline does, and a caller that set none waits for as long as it takes.

Types

type Actioner

type Actioner interface {
	DoRemote() error
	DoLocal() error
	DoAsync() error
	HasLocal() bool
	Options() T
}

Actioner is the interface implemented by nodeaction.T and objectaction.T

type Result

type Result struct {
	Nodename      string        `json:"nodename"`
	Path          naming.Path   `json:"path,omitempty"`
	Data          interface{}   `json:"data"`
	Error         error         `json:"-"`
	Panic         interface{}   `json:"-"`
	HumanRenderer func() string `json:"-"`
}

Result is a predictable type of actions return value, for reflect.

func (Result) Unstructured

func (t Result) Unstructured() map[string]any

type T

type T struct {
	Digest bool

	//
	// ObjectSelector expands into a selection of objects to execute
	// the action on.
	//
	ObjectSelector string

	//
	// NodeSelector expands into a selection of nodes to execute the
	// action on.
	//
	NodeSelector string

	RID            string
	Subset         string
	Tag            string
	Slaves         []string
	IgnoreNotFound bool
	IsAllSlaves    bool
	IsMaster       bool

	//
	// Local routes the action to the CRM instead of remoting it via
	// orchestration or remote execution.
	//
	Local bool

	//
	// DefaultIsLocal makes actions not explicitly Local nor remoted
	// via NodeSelector be treated as local (CRM level).
	//
	DefaultIsLocal bool

	//
	// Flags is the command flags as parsed by cobra. This is the struct
	// passed to the object method on local execution.
	//
	Flags any

	//
	// Target is the node or object state the daemons should orchestrate
	// to reach.
	//
	Target string

	//
	// TargetOptions is the options of the orchestration needed to reach
	// the Target.
	//
	TargetOptions any

	// Wait runs an event watcher to wait for target state or global expect reached
	Wait bool

	// WaitDuration is the maximum duration allowed for the Wait
	WaitDuration time.Duration

	//
	// Watch runs a event-driven monitor on the selected objects after
	// setting a new target. So the operator can see the orchestration
	// unfolding.
	//
	Watch bool

	// Follow streams the logs of the action until it ends: the logs of
	// its session for an action asked of the daemons of nodes, the logs
	// of its orchestration for a target state.
	Follow bool

	//
	// Output controls the output data format.
	// <empty>   => human readable format
	// tab=...   => tubular customizable format
	// yaml      => yaml machine readable format
	// json      => json machine readable format
	// flat      => flattened json (<k>=<v>) machine readable format
	// flat_json => same as flat (backward compat)
	//
	Output string

	// Sort orders the result table, which an action reaching several
	// objects or several nodes answers a row per run of.
	Sort string

	// DefaultOutput defines a default output to use when Output is
	// not specified.
	DefaultOutput string

	//
	// Color activates the colorization of outputs
	// auto => yes if os.Stdout is a tty
	// yes
	// no
	//
	Color string
}

T holds the action options common to all actioner implementations.

Jump to

Keyboard shortcuts

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