reproxy

package
v0.0.0-...-223af15 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReclientTimeoutExitCode is an exit code corresponding to a timeout within reproxy
	ReclientTimeoutExitCode = command.RemoteErrorExitCode + 14
)

Variables

View Source
var (

	// AllowedIPTimeouts is the max number of IP timeouts before failing the build
	AllowedIPTimeouts = int64(7)
)

Functions

func DeleteOldLogFiles

func DeleteOldLogFiles(d time.Duration, dir string)

DeleteOldLogFiles removes RE tooling log files older than d from dir.

func IdleTimeout

func IdleTimeout(ctx context.Context, timeout time.Duration)

IdleTimeout checks the latest request received timestamp and sends a SIGINT signal if last request received is greater than the expected idle timeout.

func StashFiles

func StashFiles(paths []string) func()

StashFiles copies the given files to a temporary location. It returns a function that restores the original files.

Types

type Executor

type Executor interface {
	// ExecuteWithOutErr runs the given command inside the working directory.
	ExecuteWithOutErr(ctx context.Context, cmd *command.Command, oe outerr.OutErr) error
}

Executor can run commands and retrieve their outputs.

type Forecast

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

Forecast is responsible for forecasting specific parameters of an action based on historical data.

func (*Forecast) PercentileDownloadLatency

func (f *Forecast) PercentileDownloadLatency(a *action, p int) (time.Duration, error)

PercentileDownloadLatency returns the expected pth percentile download latency of the given action.

func (*Forecast) RecordSample

func (f *Forecast) RecordSample(a *action)

RecordSample stores a sample from an action to be used to forecast future behavior.

func (*Forecast) Run

func (f *Forecast) Run(ctx context.Context)

Run starts the background computation of parameter forecasts. Should be run in a goroutine.

type LocalPool

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

LocalPool is responsible for executing commands locally.

func NewLocalPool

func NewLocalPool(exec Executor, resMgr *localresources.Manager) *LocalPool

NewLocalPool creates a pool with the given args.

func (*LocalPool) Run

func (l *LocalPool) Run(ctx, cCtx context.Context, cmd *command.Command, lbls map[string]string, oe outerr.OutErr, rec *logger.LogRecord) (int, error)

Run runs a command locally. Returns the stdout, stderr, exit code, and error in case more information about the failure is needed.

type Server

type Server struct {
	InputProcessor            *inputprocessor.InputProcessor
	FileMetadataStore         filemetadata.Cache
	REClient                  *rexec.Client
	LocalPool                 *LocalPool
	Logger                    *logger.Logger
	KeepLastRecords           int
	CacheSilo                 string
	VersionCacheSilo          bool
	RemoteDisabled            bool
	DumpInputTree             bool
	Forecast                  *Forecast
	StartTime                 time.Time
	FailEarlyMinActionCount   int64
	FailEarlyMinFallbackRatio float64
	FailEarlyWindow           time.Duration
	RacingBias                float64
	DownloadTmp               string
	MaxHoldoff                time.Duration // Maximum amount of time to wait for downloads before starting racing.
	StartupCancelFn           func()
	// contains filtered or unexported fields
}

Server is the server responsible for executing and retrieving results of RunRequests.

func (*Server) AddProxyEvents

AddProxyEvents saves the provided event times to the proxy level metrics. This method returns immediately and event times are added asynchronously to not block startup.

func (*Server) DrainAndReleaseResources

func (s *Server) DrainAndReleaseResources()

DrainAndReleaseResources closes all external resources, cancels all inflight RunCommand rpcs and prevents future RunCommand rpcs in preparation for server exit. s.stats is populated with aggregated build metrics. All calls after the first are noops.

func (*Server) GetRecords

func (s *Server) GetRecords(ctx context.Context, req *ppb.GetRecordsRequest) (*ppb.GetRecordsResponse, error)

GetRecords returns the latest saved LogRecords.

func (*Server) Init

func (s *Server) Init()

Init initializes internal state and should only be called once.

func (*Server) MonitorFailBuildConditions

func (s *Server) MonitorFailBuildConditions(ctx context.Context)

MonitorFailBuildConditions monitors fail early conditions. If conditions such as ratio of fallbacks to total actions periodically or number of IP timeouts are exceeded, it sets failBuild flag and failBuildErr. If fail early is disabled the function returns immediately. Should be run in a goroutine.

func (*Server) RunCommand

func (s *Server) RunCommand(ctx context.Context, req *ppb.RunRequest) (*ppb.RunResponse, error)

RunCommand runs a command according to the parameters defined in the RunRequest.

func (*Server) SetInputProcessor

func (s *Server) SetInputProcessor(ip *inputprocessor.InputProcessor, cleanup func())

SetInputProcessor sets the InputProcessor property of Server and then unblocks startup. cleanup will be run in Server.DrainAndReleaseResources()

func (*Server) SetREClient

func (s *Server) SetREClient(rclient *rexec.Client, cleanup func())

SetREClient sets the REClient property of Server and then unblocks startup. If rclient.GrpcClient is not nil then rclient.GrpcClient will be closed in Server.DrainAndReleaseResources()

func (*Server) SetStartupErr

func (s *Server) SetStartupErr(err error)

SetStartupErr saves the first error that happens during async startup and then unblocks startup.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context, req *ppb.ShutdownRequest) (*ppb.ShutdownResponse, error)

Shutdown shuts the server down gracefully.

func (*Server) WaitForCleanupDone

func (s *Server) WaitForCleanupDone() <-chan bool

WaitForCleanupDone returns a channel that is closed when all cleanup has been completed.

func (*Server) WaitForShutdownCommand

func (s *Server) WaitForShutdownCommand() <-chan bool

WaitForShutdownCommand returns a channel that is closed when a shutdown command is recieved.

Jump to

Keyboard shortcuts

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