broker

package
v0.4.26 Latest Latest
Warning

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

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

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.

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
	// 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