Documentation ¶
Index ¶
- Constants
- type AutoRollStateMachine
- func (s *AutoRollStateMachine) Current() string
- func (s *AutoRollStateMachine) GetNext(ctx context.Context) (string, error)
- func (s *AutoRollStateMachine) NextTransition(ctx context.Context) error
- func (s *AutoRollStateMachine) NextTransitionSequence(ctx context.Context) error
- func (s *AutoRollStateMachine) Transition(ctx context.Context, dest string) error
- type AutoRollerImpl
- type RollCLImpl
- type Throttler
Constants ¶
const ( // State names. S_NORMAL_IDLE = "idle" S_NORMAL_ACTIVE = "active" S_NORMAL_SUCCESS = "success" S_NORMAL_SUCCESS_THROTTLED = "success throttled" S_NORMAL_FAILURE = "failure" S_NORMAL_FAILURE_THROTTLED = "failure throttled" S_NORMAL_SAFETY_THROTTLED = "safety throttled" S_DRY_RUN_IDLE = "dry run idle" S_DRY_RUN_ACTIVE = "dry run active" S_DRY_RUN_SUCCESS = "dry run success" S_DRY_RUN_SUCCESS_LEAVING_OPEN = "dry run success; leaving open" S_DRY_RUN_FAILURE = "dry run failure" S_DRY_RUN_FAILURE_THROTTLED = "dry run failure throttled" S_DRY_RUN_SAFETY_THROTTLED = "dry run safety throttled" S_STOPPED = "stopped" // Transition function names. F_NOOP = "no-op" F_UPDATE_REPOS = "update repos" F_UPLOAD_ROLL = "upload roll" F_UPLOAD_DRY_RUN = "upload dry run" F_UPDATE_ROLL = "update roll" F_SWITCH_TO_DRY_RUN = "switch roll to dry run" F_SWITCH_TO_NORMAL = "switch roll to normal" F_CLOSE_FAILED = "close roll (failed)" F_CLOSE_STOPPED = "close roll (stopped)" F_CLOSE_DRY_RUN_FAILED = "close roll (dry run failed)" F_CLOSE_DRY_RUN_OUTDATED = "close roll (dry run outdated)" F_WAIT_FOR_LAND = "wait for roll to land" F_RETRY_FAILED_NORMAL = "retry failed roll" F_RETRY_FAILED_DRY_RUN = "retry failed dry run" F_NOTIFY_FAILURE_THROTTLE = "notify failure throttled" F_NOTIFY_SAFETY_THROTTLE = "notify safety throttled" // Maximum number of no-op transitions to perform at once. This is an // arbitrary limit just to keep us from performing an unbounded number // of transitions at a time. MAX_NOOP_TRANSITIONS = 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoRollStateMachine ¶
type AutoRollStateMachine struct {
// contains filtered or unexported fields
}
AutoRollStateMachine is a StateMachine for the AutoRoller.
func New ¶
func New(ctx context.Context, impl AutoRollerImpl, n *notifier.AutoRollNotifier, gcsClient gcs.GCSClient, gcsPrefix string) (*AutoRollStateMachine, error)
New returns a StateMachine for the autoroller.
func (*AutoRollStateMachine) Current ¶
func (s *AutoRollStateMachine) Current() string
Return the current state.
func (*AutoRollStateMachine) GetNext ¶
func (s *AutoRollStateMachine) GetNext(ctx context.Context) (string, error)
Get the next state.
func (*AutoRollStateMachine) NextTransition ¶
func (s *AutoRollStateMachine) NextTransition(ctx context.Context) error
Attempt to perform the next state transition.
func (*AutoRollStateMachine) NextTransitionSequence ¶
func (s *AutoRollStateMachine) NextTransitionSequence(ctx context.Context) error
Perform the next state transition, plus any subsequent transitions which are no-ops.
func (*AutoRollStateMachine) Transition ¶
func (s *AutoRollStateMachine) Transition(ctx context.Context, dest string) error
Attempt to perform the given state transition.
type AutoRollerImpl ¶
type AutoRollerImpl interface { // Upload a new roll. AutoRollerImpl should track the created roll. UploadNewRoll(ctx context.Context, from, to string, dryRun bool) error // Return a Throttler indicating that we have failed to roll too many // times within a time period. FailureThrottle() *Throttler // Return the currently-active roll. May be nil if no roll exists. GetActiveRoll() RollCLImpl // Return the currently-rolled revision of the sub-project. GetCurrentRev() string // Return the next revision of the sub-project which we want to roll. // This is the same as GetCurrentRev when the sub-project is up-to-date. GetNextRollRev() string // Return the current mode of the AutoRoller. GetMode() string // Return true if we have already rolled past the given revision. RolledPast(context.Context, string) (bool, error) // Return a Throttler indicating that we have attempted to upload too // many CLs within a time period. SafetyThrottle() *Throttler // Return a Throttler indicating whether we have successfully rolled too // many times within a time period. SuccessThrottle() *Throttler // Update the project and sub-project repos. UpdateRepos(context.Context) error }
Interface for interacting with the other elements of an autoroller.
type RollCLImpl ¶
type RollCLImpl interface { // Add a comment to the CL. AddComment(string) error // Close the CL. The first string argument is the result of the roll, // and the second is the message to add to the CL on closing. Close(context.Context, string, string) error // Return true iff the roll has finished (ie. succeeded or failed). IsFinished() bool // Return true iff the roll succeeded. IsSuccess() bool // Return true iff the dry run is finished. IsDryRunFinished() bool // Return true iff the dry run succeeded. IsDryRunSuccess() bool // Return the issue ID of the roll. IssueID() string // Return the URL of the roll. IssueURL() string // Retry the CQ in the case of a failure. RetryCQ(context.Context) error // Retry a dry run in the case of a failure. RetryDryRun(context.Context) error // The revision this roll is rolling to. RollingTo() string // Set the dry run bit on the CL. SwitchToDryRun(context.Context) error // Set the full CQ bit on the CL. SwitchToNormal(context.Context) error // Update our local copy of the CL from the codereview server. Update(context.Context) error }
Interface for interacting with a single autoroll CL.
type Throttler ¶
type Throttler struct {
// contains filtered or unexported fields
}
Throttler determines whether we should be throttled.
func NewThrottler ¶
func NewThrottler(ctx context.Context, gcsClient gcs.GCSClient, gcsPath string, period time.Duration, attempts int64) (*Throttler, error)
NewThrottler returns a Throttler instance.
func (*Throttler) IsThrottled ¶
IsThrottled returns true iff we should be throttled.
func (*Throttler) ThrottledUntil ¶
ThrottledUntil returns the approximate time when the Throttler will no longer be throttled.