kubernetes

package
v3.88.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInterrupt = errors.New("interrupt signal received")

Functions

func Umask

func Umask(mask int) (old int, err error)

Umask is a wrapper for `unix.Umask()` on non-Windows platforms

Types

type Client

type Client struct {
	ID         int
	SocketPath string
	// contains filtered or unexported fields
}

func (*Client) Await

func (c *Client) Await(ctx context.Context, desiredState RunState) error

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) (*RegisterResponse, error)

func (*Client) Exit

func (c *Client) Exit(exitStatus int) error

func (*Client) Write

func (c *Client) Write(p []byte) (int, error)

Write implements io.Writer

type ClientState added in v3.84.0

type ClientState int
const (
	StateNotYetConnected ClientState = iota
	StateConnected
	StateExited
	StateLost
)

type Empty

type Empty struct{}

Empty is an empty RPC message.

type ExitCode

type ExitCode struct {
	ID         int
	ExitStatus int
}

ExitCode is an RPC message that specifies an exit status for a client ID.

type Logs

type Logs struct {
	Data []byte
}

Logs is an RPC message that contains log data.

type RegisterResponse

type RegisterResponse struct {
	Env []string
}

RegisterResponse is an RPC message to registering clients containing info needed to run.

type RunState

type RunState int

RunState is an RPC message that describes to a client whether the job should continue waiting before running, start running, or stop running.

const (
	// RunStateWait means the job is not ready to start executing yet.
	RunStateWait RunState = iota

	// RunStateStart means the job can begin.
	RunStateStart

	// RunStateInterrupt means the job is cancelled or should be terminated for
	// some other reason.
	RunStateInterrupt
)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner implements the agent's jobRunner interface, but instead of directly managing a subprocess, it runs a socket server that is connected to from another container.

func NewRunner added in v3.84.0

func NewRunner(l logger.Logger, c RunnerConfig) *Runner

NewRunner returns a runner, implementing the agent's jobRunner interface.

func (*Runner) AnyClientIn added in v3.84.0

func (r *Runner) AnyClientIn(state ClientState) bool

AnyClientIn reports whether any of the clients are in a particular state.

func (*Runner) Done

func (r *Runner) Done() <-chan struct{}

Done returns a channel that is closed when the job is completed.

func (*Runner) Exit

func (r *Runner) Exit(args ExitCode, reply *Empty) error

Exit is called when the client exits.

func (*Runner) Interrupt

func (r *Runner) Interrupt() error

Interrupts all clients, triggering graceful shutdown.

func (*Runner) Register

func (r *Runner) Register(id int, reply *RegisterResponse) error

Register is called when the client registers with the runner. The reply contains the env vars that would normally be in the environment of the bootstrap subcommand, particularly, the agent session token.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

Run runs the socket server.

func (*Runner) Started

func (r *Runner) Started() <-chan struct{}

Started returns a channel that is closed when the job has started running.

func (*Runner) Status

func (r *Runner) Status(id int, reply *RunState) error

Status is called by the client to check the status of the job, so that it can pack things up if the job is cancelled. If the client stops calling Status before calling Exit, we assume it is lost.

func (*Runner) Terminate

func (r *Runner) Terminate() error

Terminate stops the RPC server, allowing Run to return immediately.

func (*Runner) WaitStatus

func (r *Runner) WaitStatus() process.WaitStatus

WaitStatus returns a wait status that represents all the clients.

func (*Runner) WriteLogs

func (r *Runner) WriteLogs(args Logs, reply *Empty) error

WriteLogs is called to pass logs on to Buildkite.

type RunnerConfig added in v3.84.0

type RunnerConfig struct {
	SocketPath        string
	ClientCount       int
	Stdout, Stderr    io.Writer
	Env               []string
	ClientLostTimeout time.Duration
}

Jump to

Keyboard shortcuts

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