broker

package
v0.4.28 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 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

Overview

Package broker serves the read sandbox's only ways to reach data (ADR 0019): Unix sockets bound read-only into the sandbox, each forwarding reads of one source and nothing else.

Index

Constants

View Source
const (
	MaxRequest  = 16 << 10
	MaxResponse = 16 << 20
	CallTimeout = 60 * time.Second
)

Limits on one broker call.

View Source
const CallHeader = "X-Advisor-Call"

CallHeader carries the sandbox run's id into the audit record.

View Source
const DefaultDir = "/run/cube-advisor-agent/broker"

DefaultDir is where the sockets and client commands live on a node.

View Source
const DefaultPrometheus = "http://127.0.0.1:9091/prometheus"

DefaultPrometheus is CubeCOS's Prometheus (3.1.10 and 3.2.0).

View Source
const PeerTimeout = 90 * time.Second

PeerTimeout bounds one read on another node, connection included.

Variables

This section is empty.

Functions

func CheckCephArgs

func CheckCephArgs(table []CephCommand, args []string) error

CheckCephArgs decides whether args (the words after "ceph") may run. The commands whose literal words fit args best decide: all must be marked exactly "r" in Ceph's table. Only output-format flags are accepted.

func CheckOpenStackPath

func CheckOpenStackPath(service, target string) (string, string, error)

CheckOpenStackPath validates one os-ro request and returns its path and re-encoded query.

func LocalCephRun

func LocalCephRun(ctx context.Context, args []string) ([]byte, []byte, error)

LocalCephRun runs the ceph CLI without a shell.

func LocalHostRun

func LocalHostRun(ctx context.Context, name string, args []string) ([]byte, []byte, error)

LocalHostRun runs one of the host broker's fixed commands without a shell.

func LocalNodes added in v0.4.28

func LocalNodes(ctx context.Context) ([]string, error)

LocalNodes reads the cluster's node names from CubeCOS's node list.

func ParseNodeList added in v0.4.28

func ParseNodeList(b []byte) ([]string, error)

ParseNodeList takes the hostnames from `cubectl node list -j`.

func PeerReadsAvailable added in v0.4.28

func PeerReadsAvailable() bool

PeerReadsAvailable says whether this node can serve peer reads.

func RunScript added in v0.4.28

func RunScript(ctx context.Context, node, script string, args []string) ([]byte, []byte, error)

RunScript runs a fixed view script with sh on this node (node "") or on node over SSH, its output capped at MaxResponse. A failed connection returns errUnreachable.

func SSHCommand added in v0.4.28

func SSHCommand(node string, args []string) []string

SSHCommand is the argv of a peer read: the fixed script goes on stdin, and args are only the view's validated arguments.

Types

type CephCommand

type CephCommand struct {
	// Sig holds each position's literal word, or "" for a parameter.
	Sig []string
	// Rest is true when the last parameter takes any number of words.
	Rest bool
	Perm string
}

CephCommand is one entry of Ceph's own command table.

func LocalCephTable

func LocalCephTable(ctx context.Context) ([]CephCommand, error)

LocalCephTable reads the node's Ceph command tables with python3-rados.

func ParseCephDescriptions

func ParseCephDescriptions(raw []byte) ([]CephCommand, error)

ParseCephDescriptions reads get_command_descriptions output (the monitor's or manager's) into commands.

type OpenStackSource

type OpenStackSource interface {
	Endpoint(ctx context.Context, service string) (endpoint, token string, err error)
	Invalidate()
	HTTP() *http.Client
}

OpenStackSource resolves a catalogue service to its endpoint and a token. openstack.Admin satisfies it.

type Server

type Server struct {
	Dir        string
	Prometheus string // base URL, no trailing slash
	Audit      toolplane.Auditor
	// CephTable returns Ceph's command table; CephRun runs `ceph args...`.
	CephTable func(ctx context.Context) ([]CephCommand, error)
	CephRun   func(ctx context.Context, args []string) (stdout, stderr []byte, err error)
	// HostRun runs the host broker's fixed commands; nil means LocalHostRun.
	HostRun func(ctx context.Context, name string, args []string) (stdout, stderr []byte, err error)
	// ProcRoot is where /procs reads processes; "" means /proc.
	ProcRoot string
	// ScriptRun runs a fixed view script here (node "") or on a peer; nil
	// means RunScript.
	ScriptRun func(ctx context.Context, node, script string, args []string) (stdout, stderr []byte, err error)
	// Nodes lists the cluster's node names; nil means LocalNodes.
	Nodes func(ctx context.Context) ([]string, error)
	// Hostname names this node; nil means os.Hostname.
	Hostname func() (string, error)
	// OpenStack backs os-ro; nil refuses its calls.
	OpenStack OpenStackSource
	Client    *http.Client
	// contains filtered or unexported fields
}

Server serves the brokers.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start creates the directory, the client commands and the sockets, and serves until ctx ends.

Jump to

Keyboard shortcuts

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