Documentation ¶
Index ¶
- Variables
- func IsAmbiguousRCSelector(err error) bool
- func RollLockPath(id roll_fields.ID) (string, error)
- func RollPath(id roll_fields.ID) (string, error)
- type ConflictingRUError
- type ConsulStore
- func (s ConsulStore) CreateRollingUpdateFromExistingRCs(ctx context.Context, u roll_fields.Update, newRCLabels klabels.Set, ...) (roll_fields.Update, error)
- func (s ConsulStore) CreateRollingUpdateFromOneExistingRCWithID(ctx context.Context, oldRCID rc_fields.ID, desiredReplicas int, ...) (roll_fields.Update, error)
- func (s ConsulStore) CreateRollingUpdateFromOneMaybeExistingWithLabelSelector(ctx context.Context, oldRCSelector klabels.Selector, desiredReplicas int, ...) (roll_fields.Update, error)
- func (s ConsulStore) Delete(ctx context.Context, id roll_fields.ID) error
- func (s ConsulStore) Get(id roll_fields.ID) (roll_fields.Update, error)
- func (s ConsulStore) List() ([]roll_fields.Update, error)
- func (s ConsulStore) Lock(id roll_fields.ID, session string) (bool, error)
- func (s ConsulStore) Watch(quit <-chan struct{}, jitterWindow time.Duration) (<-chan []roll_fields.Update, <-chan error)
- type KV
- type ReplicationControllerStore
- type RollLabeler
Constants ¶
This section is empty.
Variables ¶
var AmbiguousRCSelector error = errors.New("The old RC selector was ambigous and produced > 1 matches")
Functions ¶
func IsAmbiguousRCSelector ¶
func RollLockPath ¶
func RollLockPath(id roll_fields.ID) (string, error)
Roll paths are computed using the id of the new replication controller
Types ¶
type ConflictingRUError ¶
type ConflictingRUError struct { ConflictingID roll_fields.ID ConflictingRCID rc_fields.ID }
func (*ConflictingRUError) Error ¶
func (c *ConflictingRUError) Error() string
type ConsulStore ¶
type ConsulStore struct {
// contains filtered or unexported fields
}
func NewConsul ¶
func NewConsul(c consulutil.ConsulClient, labeler RollLabeler, logger *logging.Logger) ConsulStore
func (ConsulStore) CreateRollingUpdateFromExistingRCs ¶
func (s ConsulStore) CreateRollingUpdateFromExistingRCs( ctx context.Context, u roll_fields.Update, newRCLabels klabels.Set, rollLabels klabels.Set, ) (roll_fields.Update, error)
CreateRollingUpdateFromExistingRCs creates a rolling update in consul, under the following conditions: 1) A lock can be acquired for both the old and new replication controllers.
- this is in lexicographical order by replication controller id so that identical update requests will not deadlock eachother
- A rolling update does not already exist that refers to the same replication controllers (whether new or old). - This check is done while the locks are held, so that no new rolling update can be created referring to old and new while doing this query. - It naively searches every rolling update and checks its fields. While this introduces O(n) runtime complexity on the number of updates, since updates are short lived we don't anticipate it to be a scalability bottleneck. If scalability were a concern, an alternate approach would be to place labels on replication controllers referring back to the RUs that they refer to. Then a constant lookup can be done for those labels, and the operation can be aborted.
func (ConsulStore) CreateRollingUpdateFromOneExistingRCWithID ¶
func (s ConsulStore) CreateRollingUpdateFromOneExistingRCWithID( ctx context.Context, oldRCID rc_fields.ID, desiredReplicas int, minimumReplicas int, leaveOld bool, rollDelay time.Duration, availabilityZone pc_fields.AvailabilityZone, clusterName pc_fields.ClusterName, newRCManifest manifest.Manifest, newRCNodeSelector klabels.Selector, newRCPodLabels klabels.Set, newRCLabels klabels.Set, rollLabels klabels.Set, newAllocationStrategy rc_fields.Strategy, ) (roll_fields.Update, error)
CreateRollingUpdateFromOneExistingWithRCID is like CreateRollingUpdateFromExistingRCs except will create the new RC based on passed parameters, using oldRCID for the old RC. The new RC and new RU will be created transactionally (all or nothing)
func (ConsulStore) CreateRollingUpdateFromOneMaybeExistingWithLabelSelector ¶
func (s ConsulStore) CreateRollingUpdateFromOneMaybeExistingWithLabelSelector( ctx context.Context, oldRCSelector klabels.Selector, desiredReplicas int, minimumReplicas int, leaveOld bool, rollDelay time.Duration, availabilityZone pc_fields.AvailabilityZone, clusterName pc_fields.ClusterName, newRCManifest manifest.Manifest, newRCNodeSelector klabels.Selector, newRCPodLabels klabels.Set, newRCLabels klabels.Set, rollLabels klabels.Set, newAllocationStrategy rc_fields.Strategy, ) (roll_fields.Update, error)
CreateRollingUpdateFromOneMaybeExistingWithLabelSelector creates a rolling update that may or may not already have an existing old RC. If one matches the oldRCSelector, it will be used as the old RC in the new update. If one does not exist, a "dummy" old RC will be created that is identical to the specifications for the new RC. Returns an error if the old RC exists but is part of another RU, or if the label selector returns more than one match.
func (ConsulStore) Delete ¶
func (s ConsulStore) Delete(ctx context.Context, id roll_fields.ID) error
Delete deletes a rolling update based on its ID.
func (ConsulStore) Get ¶
func (s ConsulStore) Get(id roll_fields.ID) (roll_fields.Update, error)
Get retrieves a rolling update record by it ID.
func (ConsulStore) List ¶
func (s ConsulStore) List() ([]roll_fields.Update, error)
List returns all rolling update records.
func (ConsulStore) Lock ¶
func (s ConsulStore) Lock(id roll_fields.ID, session string) (bool, error)
Lock takes a lock on a rolling update by ID. Before taking ownership of an Update, its new RC ID, and old RC ID if any, should both be locked. If the error return is nil, then the boolean indicates whether the lock was successfully taken.
func (ConsulStore) Watch ¶
func (s ConsulStore) Watch(quit <-chan struct{}, jitterWindow time.Duration) (<-chan []roll_fields.Update, <-chan error)
Watch wtches for changes to the store and generate a list of Updates for each change. This function does not block.
type KV ¶
type KV interface { Get(key string, q *api.QueryOptions) (*api.KVPair, *api.QueryMeta, error) List(prefix string, q *api.QueryOptions) (api.KVPairs, *api.QueryMeta, error) CAS(p *api.KVPair, q *api.WriteOptions) (bool, *api.WriteMeta, error) Delete(key string, w *api.WriteOptions) (*api.WriteMeta, error) Acquire(p *api.KVPair, q *api.WriteOptions) (bool, *api.WriteMeta, error) }
Interface that allows us to inject a test implementation of the consul api
type ReplicationControllerStore ¶
type ReplicationControllerStore interface { LockForUpdateCreation(rcID rc_fields.ID, session consul.Session) (consul.Unlocker, error) CreateTxn( ctx context.Context, manifest manifest.Manifest, nodeSelector klabels.Selector, availabilityZone pc_fields.AvailabilityZone, clusterName pc_fields.ClusterName, podLabels klabels.Set, additionalLabels klabels.Set, allocationStrategy rc_fields.Strategy, ) (rc_fields.RC, error) Delete(id rc_fields.ID, force bool) error UpdateCreationLockPath(rcID rc_fields.ID) (string, error) // TODO: delete this. the tests are still using it but the real code isn't Create( manifest manifest.Manifest, nodeSelector klabels.Selector, availabilityZone pc_fields.AvailabilityZone, clusterName pc_fields.ClusterName, podLabels klabels.Set, additionalLabels klabels.Set, allocationStrategy rc_fields.Strategy, ) (rc_fields.RC, error) }
type RollLabeler ¶
type RollLabeler interface { SetLabel(labelType labels.Type, id, name, value string) error SetLabels(labelType labels.Type, id string, labels map[string]string) error SetLabelsTxn(ctx context.Context, labelType labels.Type, id string, labels map[string]string) error RemoveAllLabelsTxn(ctx context.Context, labelType labels.Type, id string) error RemoveAllLabels(labelType labels.Type, id string) error GetLabels(labelType labels.Type, id string) (labels.Labeled, error) GetMatches(selector klabels.Selector, labelType labels.Type) ([]labels.Labeled, error) }