Example #1
0
// Attempts to claim a lock on replicating this pod. Other pkg/replication
// operations for this pod ID will not be able to take place.
// if overrideLock is true, will destroy any session holding any of the keys we
// wish to lock
func (r *replication) lockHosts(overrideLock bool, lockMessage string) (kp.Session, chan error, error) {
	session, renewalErrCh, err := r.store.NewSession(lockMessage, nil)
	if err != nil {
		return nil, nil, err
	}

	lockPath := kp.ReplicationLockPath(r.manifest.ID())

	// We don't keep a reference to the consulutil.Unlocker, because we just destroy
	// the session at the end of the replication anyway
	_, err = r.lock(session, lockPath, overrideLock)
	if err != nil {
		_ = session.Destroy()
		return nil, nil, err
	}

	return session, renewalErrCh, nil
}
Example #2
0
func testLockPath(testPodId types.PodID) (string, error) {
	return kp.ReplicationLockPath(testPodId), nil
}