Documentation
¶
Overview ¶
Package session remembers the actions the daemon ran, so a client that submitted one can ask how it ended.
A client submitting an action is handed a session id, and an orchestrated action an orchestration id, which several sessions run under. Neither is answerable from the process table: that one is keyed by pid, holds only what is running, and exists to be signaled. This one is keyed by the ids the client was given, and outlives the process.
What it holds is bounded, and the bound is the point: a session nobody asked about is forgotten rather than kept forever. A client asking for one that has been forgotten is told so, which is not the same answer as never having heard of it, so a poller can tell "not finished" from "I no longer know".
Index ¶
- Variables
- func AddExec(s Exec)
- func AddOrchestration(o Orchestration)
- func EndExec(execID, sessionID string, state State, errS string, exitCode int, ...)
- func EndOrchestration(id string, state State, errS string)
- func IDString(id xsession.ID) string
- func NoteMonitor(path, node, id, expect, failure string, updatedAt time.Time)
- func Purge()
- type Exec
- type Filter
- type Manager
- type Orchestration
- type State
Constants ¶
This section is empty.
Variables ¶
var ( // MaxEntries is how many ended entries of each kind are kept. A running // one is never dropped for the count: what is running is bounded by what // the node can run at once, and dropping it would lose the answer a // client is waiting for. MaxEntries = 1000 // MaxAge is how long an ended entry is kept. MaxAge = time.Hour )
Functions ¶
func AddOrchestration ¶
func AddOrchestration(o Orchestration)
AddOrchestration records an orchestration the monitor accepted.
func EndExec ¶
func EndExec(execID, sessionID string, state State, errS string, exitCode int, duration time.Duration)
EndExec records how an exec ended.
It ends the exec and not the session: several execs share a session id, and ending by that id would have the second of them overwrite the first, which is how a command reaching two objects of a node reported one outcome.
An exec the daemon never saw start is recorded all the same: the end carries what is needed to answer, and losing it because a message was missed would leave a client polling something that is over.
func EndOrchestration ¶
EndOrchestration records how an orchestration ended.
func IDString ¶
IDString renders an id, empty when it carries none, so a session that belongs to no orchestration does not report belonging to the nil one.
func NoteMonitor ¶
NoteMonitor records what the instance monitor of a node says about the orchestration of an object.
Every node holds the monitor of every node, the daemon replicating them for the orchestration to converge at all, so this is what lets any node answer for an orchestration accepted by another. The alternative was for the node that accepted one to be named to the client, and for the client to be able to ask that node, which a client reaching the cluster through a floating address cannot: the address moves, and a switch is what moves it.
id is empty when the monitor names no orchestration, which is how the end of one is seen: the id is unset on a node when the orchestration is reached there, so the last node to drop it ends it.
Types ¶
type Exec ¶
type Exec struct {
SessionID string `json:"session_id"`
ExecID string `json:"exec_id"`
OrchestrationID string `json:"orchestration_id,omitempty"`
Node string `json:"node"`
Path string `json:"path,omitempty"`
Origin string `json:"origin"`
RID string `json:"rid,omitempty"`
Title string `json:"title,omitempty"`
Command string `json:"command"`
State State `json:"state"`
Error string `json:"error,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at,omitempty"`
}
Exec is one command the daemon ran, or is running.
The exec is the unit, not the session: one command reaches several objects of a node under one session id, each of them its own exec with its own outcome and its own duration. So the exec id is what a record is keyed by, and the session id is what several of them share.
func WaitExec ¶
WaitExec waits for the exec of an id to end, and returns it and whether it is known.
func WaitExecs ¶
WaitExecs waits for the execs a filter selects to be done, and returns them, with whether any was still running when it gave up.
A session is not a record of its own: it is the id several execs share, one per object the submitted command reached on this node, so waiting for a session is waiting for this filter to select nothing running. A node that ran nothing for the filter answers at once with nothing, rather than holding the request: what the filter names may have run entirely elsewhere, and only the client gathering the nodes can tell.
type Filter ¶
type Filter struct {
States []State
Origins []string
SessionID string
OrchestrationID string
ExecID string
Path string
Node string
RID string
}
Filter is what a listing is narrowed by. A zero value narrows nothing.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager fills the session and orchestration tables from what the bus says, and drops from them what is too old.
func NewManager ¶
func NewManager(subQS pubsub.QueueSizer) *Manager
NewManager returns the manager of the session and orchestration tables.
type Orchestration ¶
type Orchestration struct {
OrchestrationID string `json:"orchestration_id"`
Node string `json:"node"`
Path string `json:"path,omitempty"`
// Expect is the state the orchestration is for. An object is asked
// by a global expect; a node by a global one to freeze and a local
// one to drain.
Expect string `json:"expect,omitempty"`
State State `json:"state"`
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at,omitempty"`
}
Orchestration is one orchestration the daemon accepted, and the execs it ran under it.
func GetOrchestration ¶
func GetOrchestration(id string) (Orchestration, bool)
GetOrchestration returns the orchestration of an id, and whether it is still known.
func ListOrchestrations ¶
func ListOrchestrations(f Filter) []Orchestration
ListOrchestrations returns every orchestration still known, newest first.
func WaitOrchestration ¶
func WaitOrchestration(ctx context.Context, id string) (Orchestration, bool)
WaitOrchestration waits for the orchestration of an id to end.
It returns the orchestration and whether it is known, so a caller can tell an orchestration still running when it gave up waiting from one this node never heard of or has forgotten.
type State ¶
type State string
State is where a session got to.
const ( // StateRunning is a session the daemon has not seen the end of. StateRunning State = "running" // StateSucceeded is a session that ended without an error. StateSucceeded State = "succeeded" // StateFailed is a session that ended with one. StateFailed State = "failed" // StateAborted is an orchestration that was asked to stop before // reaching what it was for. StateAborted State = "aborted" // StateRefused is an orchestration the monitor would not accept. StateRefused State = "refused" )