Documentation
¶
Overview ¶
Package bot wraps managing Swarming bots.
Index ¶
Constants ¶
const GraceInterval = 3 * time.Minute
GraceInterval is the amount of time to provide for bots to terminate gracefully.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot interface { // Wait waits for the bot process to exit. The return value // on subsequent calls is undefined. Wait() error // Drain signals for the bot to drain. Note that this requires // support from the bot script. This should be handled by Swarming // bots by waiting for the currently running task to finish before // exiting. Drain() error // TerminateOrKill terminates the bot with SIGTERM, then force kills it // after a grace period. // Swarming bots handle SIGTERM by aborting the currently running task and // exiting, but it can be hours long. // It relies on Wait() to be called to notify if the bot process has been // terminated. TerminateOrKill() error }
Bot is the interface for interacting with a started Swarming bot. Wait must be called to ensure the process is waited for.
type Cgroup ¶
Cgroup is an alias of cgroups.Cgroup, which cannot be built on neither Windows or Mac.
type Config ¶
type Config struct { BotID string // WorkDirectory is the Swarming bot's work directory. // The caller should create this. // The parent directory should be writable to allow creation // of the drain file. WorkDirectory string // The Linux compute resources (CPU, RAM, I/O, etc.) assigned to this bot. Resources *specs.LinuxResources PythonVersion string }
Config is the configuration needed for starting a generic Swarming bot.
type DroneStarter ¶
type DroneStarter struct { // WorkingDir is used for Swarming bot working dirs. It is // the caller's responsibility to create this. WorkingDir string // StartBotFunc is used to start Swarming bots. StartBotFunc func(Config) (Bot, error) // BotConfigFunc is used to make a bot config. BotConfigFunc func(botID string, workDir string) Config // LogFunc is used for logging messages. LogFunc func(string, ...any) }
A DroneStarter starts a bot for a drone. It handles setting up the working dir, etc. Low level process execution is handled by a separate StartBotFunc for testing and abstraction. All fields must be set. In particular, the function fields must not be nil.
type FakeBot ¶
type FakeBot struct { // DrainFunc, if set, is called when the bot is drained. The // default behavior is Stop. DrainFunc func(*FakeBot) error // TerminateFunc, if set, is called when the bot is terminated. // The default behavior is Stop. TerminateFunc func(*FakeBot) error // contains filtered or unexported fields }
FakeBot is a fake implementation of Bot for tests.
func (*FakeBot) TerminateOrKill ¶
TerminateOrKill implements Bot.
type Starter ¶
type Starter struct {
// contains filtered or unexported fields
}
Starter has a Start method for starting Swarming bots.
func NewStarter ¶
NewStarter returns a new Starter. swarmingURL is the URL of the Swarming instance. Should be a full URL without the path, e.g. https://host.example.com