Skip to content

Commit

Permalink
add no fail on connect option
Browse files Browse the repository at this point in the history
  • Loading branch information
seletskiy committed Jun 16, 2016
1 parent 10fdff1 commit 33e1ad2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func acquireDistributedLock(
runnerFactory runnerFactory,
addresses []address,
failOnError bool,
noConnFail bool,
) (*distributedLock, error) {
var (
cluster = &distributedLock{
Expand All @@ -34,13 +35,22 @@ func acquireDistributedLock(
err := connectToNode(cluster, runnerFactory, nodeAddress, mutex)

if err != nil {
debugf(`%4d/%d connection established: %s`,
atomic.AddInt64(&nodeIndex, 1),
len(addresses),
nodeAddress,
)
if noConnFail {
warningf("%s", err.Error())
errors <- nil
} else {
errors <- err
}

return
}

debugf(`%4d/%d connection established: %s`,
atomic.AddInt64(&nodeIndex, 1),
len(addresses),
nodeAddress,
)

errors <- err
}(nodeAddress)
}
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Options:
behaviour, this option can be used.
-t --no-lock-fail Try to obtain global lock, but only print warning if
it cannot be done, do not stop execution.
-w --no-conn-fail Skip unreachable servers whatsoever.
-r --root <root> Specify root dir to extract files into.
By default, orgalorg will create temporary directory
inside of '$ROOT'.
Expand Down Expand Up @@ -551,6 +552,8 @@ func connectAndLock(
rootDir, _ = args["--root"].(string)
sshKeyPath, _ = args["--key"].(string)
lockFile, _ = args["--lock-file"].(string)

noConnFail = args["--no-conn-fail"].(bool)
)

addresses, err := parseAddresses(hosts, defaultUser, fromStdin)
Expand Down Expand Up @@ -592,6 +595,7 @@ func connectAndLock(
runners,
addresses,
failOnError,
noConnFail,
)
if err != nil {
return nil, hierr.Errorf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:not tests:ensure :orgalorg:with-key -o example.com -C whoami

tests:ensure :orgalorg:with-key -o example.com -w -C whoami

tests:assert-stderr-re "WARNING.*can't create runner.*example.com"

:check-node-output() {
local container_ip="$2"

tests:assert-stdout "$container_ip $orgalorg_user"
}

containers:do :check-node-output

0 comments on commit 33e1ad2

Please sign in to comment.