Documentation
¶
Overview ¶
Package upgrade installs only release artifacts verified against an operator's local trust policy. The console cannot supply a new trust root or shell command.
Index ¶
- Constants
- Variables
- func DecommissionedExit() int
- func Run(ctx context.Context, opts Options) error
- func Socket(stateDir string) string
- type Bundle
- type Capabilities
- type Client
- func (c *Client) Ack(ctx context.Context, id string) error
- func (c *Client) AckLogs(ctx context.Context, ack LogsAck) error
- func (c *Client) Available(ctx context.Context) bool
- func (c *Client) Capabilities(ctx context.Context) (Capabilities, error)
- func (c *Client) Engine(ctx context.Context) bool
- func (c *Client) EngineStatus(ctx context.Context) (running bool, starts int, err error)
- func (c *Client) Healthy(ctx context.Context, version string) error
- func (c *Client) ReadDebugLogs(ctx context.Context, f nodelog.DebugFilter) (*nodelog.DebugSnapshot, error)
- func (c *Client) ReadLogs(ctx context.Context, instance string, after uint64) (*LogsPage, error)
- func (c *Client) ReportHealth(ctx context.Context, version string, healthy bool) error
- func (c *Client) Result(ctx context.Context) (*Result, error)
- func (c *Client) Stage(ctx context.Context, t Task) error
- type LogsAck
- type LogsPage
- type Options
- type RemoteEngine
- func (e *RemoteEngine) ModuleFeatures(ctx context.Context) ([]string, error)
- func (e *RemoteEngine) Reload(ctx context.Context) error
- func (e *RemoteEngine) Run(ctx context.Context) error
- func (e *RemoteEngine) Running() bool
- func (e *RemoteEngine) Started() <-chan struct{}
- func (e *RemoteEngine) Test(ctx context.Context, conf string) error
- func (e *RemoteEngine) Version(ctx context.Context) (string, error)
- type Result
- type Supervisor
- type Task
- type Trust
Constants ¶
const DecommissionedExitEnv = "EDGEWEIR_DECOMMISSIONED_EXIT"
DecommissionedExitEnv set to "3" tells the command that its parent (the unit, and through it the supervisor) stops on ExitDecommissioned. The unit of 1.7.0 sets it. Without it a decommissioned node exits with 2: a node upgraded in place by the console keeps its 1.6.x unit and 1.6.x supervisor, which restart status 3 but stop on 2 (since 1.4.0).
const DefaultSource = "https://github.com/marvinli001/edgeweir-node/releases/download"
const ExitDecommissioned = 3
ExitDecommissioned is the exit status of a node the console decommissioned (agent.ErrDecommissioned): it must not run again until it is enrolled anew. systemd counts it as a clean stop (SuccessExitStatus=3, RestartPreventExitStatus=3).
Variables ¶
var ErrDecommissioned = errors.New("edgeweir-node run exited with status 3: the console decommissioned this node; not restarting it")
ErrDecommissioned stops the supervisor when the node exits with ExitDecommissioned.
var ErrUsage = errors.New("edgeweir-node run exited with status 2 (invalid flags or local settings); not restarting it")
ErrUsage stops the supervisor when the node exits with status 2: its flags or local settings are wrong, and starting it again cannot help.
Functions ¶
func DecommissionedExit ¶ added in v1.7.0
func DecommissionedExit() int
DecommissionedExit is the exit status of a decommissioned node: ExitDecommissioned when DecommissionedExitEnv says the parent stops on it, else 2.
Types ¶
type Bundle ¶
type Capabilities ¶ added in v1.3.0
type Capabilities struct {
Enabled bool `json:"enabled"`
Engine bool `json:"engine"`
Logs bool `json:"logs"`
// GET /debug-logs (debug-logs-v1).
DebugLogs bool `json:"debug_logs"`
}
Capabilities are what the supervisor offers its child.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Capabilities ¶ added in v1.3.0
func (c *Client) Capabilities(ctx context.Context) (Capabilities, error)
Capabilities returns what the supervisor offers.
func (*Client) EngineStatus ¶
EngineStatus returns the state of the supervisor's OpenResty.
func (*Client) ReadDebugLogs ¶ added in v1.6.0
func (c *Client) ReadDebugLogs(ctx context.Context, f nodelog.DebugFilter) (*nodelog.DebugSnapshot, error)
ReadDebugLogs returns the entries of the supervisor's ring that f selects.
func (*Client) ReadLogs ¶ added in v1.3.0
ReadLogs returns the entries after after in the supervisor's buffer instance (all it holds for another instance).
func (*Client) ReportHealth ¶
type LogsAck ¶ added in v1.3.0
type LogsAck struct {
Instance string `json:"instance"`
Upto uint64 `json:"upto"`
RateLimitedMark uint64 `json:"rate_limited_mark"`
OverflowMark uint64 `json:"overflow_mark"`
}
LogsAck acknowledges entries up to Upto and the drops counted up to the marks of one buffer instance.
type LogsPage ¶ added in v1.3.0
type LogsPage struct {
// Instance names the supervisor's buffer; numbers start over in a
// new one.
Instance string `json:"instance"`
Entries []nodelog.Entry `json:"entries"`
// Last is the number of the last entry returned (after when none).
Last uint64 `json:"last"`
// Entries the supervisor dropped since the last acknowledgement, and
// its counters (the acknowledgement's marks).
DroppedRateLimited uint64 `json:"dropped_rate_limited"`
DroppedOverflow uint64 `json:"dropped_overflow"`
RateLimitedMark uint64 `json:"rate_limited_mark"`
OverflowMark uint64 `json:"overflow_mark"`
}
LogsPage is the answer of GET /logs.
type Options ¶
type Options struct {
Trust Trust
Executable string
LuaDir string
Version string
RunArgs []string
Log *slog.Logger
Output io.Writer
TrialTimeout time.Duration
StableWindow time.Duration
// Engine is OpenResty the supervisor runs for its children (see
// engine.go); nil: each child runs it itself.
Engine *engine.Config
// AllowDowngrade lets an upgrade task install an older version than
// the active one (refused otherwise: an older signed release may have
// known flaws).
AllowDowngrade bool
// Logs holds the supervisor's own warnings and events and OpenResty's
// error log (Engine.LogSink) for its children (GET /logs); nil: none.
Logs *nodelog.Collector
// DebugLogs is the supervisor's debug log ring (its own records and
// OpenResty's error log of every level) for its children (GET
// /debug-logs); nil: none.
DebugLogs *nodelog.Ring
// contains filtered or unexported fields
}
type RemoteEngine ¶
type RemoteEngine struct {
// contains filtered or unexported fields
}
RemoteEngine is the agent's engine when the supervisor runs OpenResty: tests and reloads go through the supervisor socket, version and module probes run the binary locally. Run only watches for restarts.
func NewRemoteEngine ¶
func NewRemoteEngine(socket string, local *engine.Nginx) *RemoteEngine
NewRemoteEngine returns the engine for a child of a supervisor that runs OpenResty (Client.Engine); local is the same binary, for probes.
func (*RemoteEngine) ModuleFeatures ¶
func (e *RemoteEngine) ModuleFeatures(ctx context.Context) ([]string, error)
func (*RemoteEngine) Reload ¶
func (e *RemoteEngine) Reload(ctx context.Context) error
Reload makes the supervisor's OpenResty load the installed configuration, starting it when it does not run.
func (*RemoteEngine) Run ¶
func (e *RemoteEngine) Run(ctx context.Context) error
Run signals Started whenever the supervisor's OpenResty (re)started after the agent began watching, until ctx is done. OpenResty keeps running when the agent stops.
func (*RemoteEngine) Running ¶
func (e *RemoteEngine) Running() bool
Running reports what the supervisor said last.
func (*RemoteEngine) Started ¶
func (e *RemoteEngine) Started() <-chan struct{}
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
func (*Supervisor) ServeHTTP ¶
func (s *Supervisor) ServeHTTP(w http.ResponseWriter, r *http.Request)