Documentation ¶
Index ¶
- func RetryOrQuit(ctx context.Context, f func() error, logger logging.Logger, errtext string) bool
- type Factory
- type Farm
- type FarmConfig
- type Labeler
- type RCGetter
- type RCStatusStore
- type ReplicationControllerLocker
- type ReplicationControllerStore
- type RollingUpdateStore
- type ServiceWatcher
- type Store
- type Update
- type UpdateFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RetryOrQuit ¶
retries a given function until it returns a nil error or the quit channel is closed. returns true if it exited in the former case, false in the latter. errors are sent to the given logger with the given string as the message.
Types ¶
type Farm ¶
type Farm struct {
// contains filtered or unexported fields
}
The Farm is responsible for spawning and reaping rolling updates as they are added to and deleted from Consul. Multiple farms can exist simultaneously, but each one must hold a different Consul session. This ensures that the farms do not instantiate the same rolling update multiple times.
Roll farms take an RC selector that is used to decide whether this farm should pick up a particular RU request. This can be used to assist in RU partitioning of work or to create test environments. Note that this is _not_ required for RU farms to cooperatively schedule work.
func (*Farm) Start ¶
func (rlf *Farm) Start(quit <-chan struct{})
Start is a blocking function that monitors Consul for updates. The Farm will attempt to claim updates as they appear and, if successful, will start goroutines for those updates to do their job. Closing the quit channel will cause this function to return, releasing all locks it holds.
Start is not safe for concurrent execution. Do not execute multiple concurrent instances of Start.
type FarmConfig ¶
type FarmConfig struct { // ShouldCreateAuditLogRecords determines whether the farm will create audit // log records when deleting a rolling update, which occurs after completing // the RU ShouldCreateAuditLogRecords bool }
FarmConfig contains configuration options for the farm. All fields have safe defaults
type RCStatusStore ¶
type ReplicationControllerStore ¶
type ReplicationControllerStore interface { Get(id rcf.ID) (rcf.RC, error) SetDesiredReplicas(id rcf.ID, n int) error Delete(id rcf.ID, force bool) error DeleteTxn(ctx context.Context, id rcf.ID, force bool) error TransferReplicaCounts(ctx context.Context, req rcstore.TransferReplicaCountsRequest) error DisableTxn(ctx context.Context, id rcf.ID) error EnableTxn(ctx context.Context, id rcf.ID) error }
type RollingUpdateStore ¶
type RollingUpdateStore interface { Watch(quit <-chan struct{}, jitterWindow time.Duration) (<-chan []roll_fields.Update, <-chan error) Delete(ctx context.Context, id roll_fields.ID) error }
type ServiceWatcher ¶
type Store ¶
type Store interface { SetPod(podPrefix consul.PodPrefix, nodename types.NodeName, manifest manifest.Manifest) (time.Duration, error) Pod(podPrefix consul.PodPrefix, nodename types.NodeName, podId types.PodID) (manifest.Manifest, time.Duration, error) DeletePod(podPrefix consul.PodPrefix, nodename types.NodeName, podId types.PodID) (time.Duration, error) NewUnmanagedSession(session, name string) consul.Session }
type Update ¶
type Update interface { // Run will execute the Update and modify the passed context such that // its transaction removes the old RC upon completion. Run should claim // exclusive ownership of both affected RCs, and release that // exclusivity upon completion. Run is long-lived and blocking; // canceling the context causes it to terminate it early. If an Update // is interrupted or encounters an unrecoverable error such as a // transaction violation, Run should leave the RCs in a state such that // it can later be called again to resume. The return value indicates // if the update completed (true) or if it was terminated early // (false). Run(ctx context.Context) bool }
func NewUpdate ¶
func NewUpdate( f fields.Update, consuls Store, consulClient consulutil.ConsulClient, rcLocker ReplicationControllerLocker, rcStore ReplicationControllerStore, rcStatusStore RCStatusStore, rollStore RollingUpdateStore, txner transaction.Txner, hcheck ServiceWatcher, labeler Labeler, logger logging.Logger, session consul.Session, watchDelay time.Duration, alerter alerting.Alerter, shouldCreateAuditLogRecords bool, auditLogStore auditlogstore.ConsulStore, ) Update
Create a new Update. The consul.Store, rcstore.Store, and labels.Applicator arguments should be the same as those of the RCs themselves. The session must be valid for the lifetime of the Update; maintaining this is the responsibility of the caller.
type UpdateFactory ¶
type UpdateFactory struct { Store Store Client consulutil.ConsulClient Txner transaction.Txner RCLocker ReplicationControllerLocker RCStore ReplicationControllerStore RCStatusStore RCStatusStore RollStore RollingUpdateStore HealthChecker checker.HealthChecker Labeler labeler WatchDelay time.Duration Alerter alerting.Alerter ShouldCreateAuditLogRecords bool AuditLogStore auditlogstore.ConsulStore }
func NewUpdateFactory ¶
func NewUpdateFactory( store Store, consulClient consulutil.ConsulClient, txner transaction.Txner, rcLocker ReplicationControllerLocker, rcStore ReplicationControllerStore, rcStatusStore RCStatusStore, rollStore RollingUpdateStore, healthChecker checker.HealthChecker, labeler labeler, watchDelay time.Duration, alerter alerting.Alerter, auditLogStore auditlogstore.ConsulStore, shouldCreateAuditLogRecords bool, ) UpdateFactory
func (UpdateFactory) New ¶
func (f UpdateFactory) New(u roll_fields.Update, l logging.Logger, session consul.Session) Update