-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
173 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import "github.com/theairkit/runcmd" | ||
|
||
type archiveReceiverNode struct { | ||
node distributedLockNode | ||
command runcmd.CmdWorker | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/seletskiy/hierr" | ||
"golang.org/x/crypto/ssh" | ||
) | ||
|
||
type archiveReceivers struct { | ||
stdin io.WriteCloser | ||
nodes []archiveReceiverNode | ||
} | ||
|
||
func (receivers *archiveReceivers) wait() error { | ||
err := receivers.stdin.Close() | ||
if err != nil { | ||
return hierr.Errorf( | ||
err, | ||
`can't close archive stream`, | ||
) | ||
} | ||
|
||
for _, receiver := range receivers.nodes { | ||
err := receiver.command.Wait() | ||
if err != nil { | ||
if sshErr, ok := err.(*ssh.ExitError); ok { | ||
return fmt.Errorf( | ||
`%s failed to receive archive, `+ | ||
`remote command exited with non-zero code: %d`, | ||
receiver.node.String(), | ||
sshErr.Waitmsg.ExitStatus(), | ||
) | ||
} | ||
|
||
return hierr.Errorf( | ||
err, | ||
`%s failed to receive archive, unexpected error`, | ||
receiver.node.String(), | ||
) | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.