Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/tarmak/ssh/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (t *Tunnel) Start() error {
var err error

// ensure there is connectivity to the bastion
args := append(t.sshCommand, "-N", "bastion", "/bin/true")
args := append(t.sshCommand, "bastion", "/bin/true")
cmd := exec.Command(args[0], args[1:len(args)]...)

t.log.Debugf("check SSH connection to bastion cmd=%s", cmd.Args)
Expand Down
14 changes: 10 additions & 4 deletions pkg/tarmak/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
VaultStateUnsealed
VaultStateUnintialised
VaultStateErr
vaultTunnelCreationTimeoutSeconds = 100
)

const (
Expand Down Expand Up @@ -107,22 +108,27 @@ func (v *Vault) TunnelFromFQDNs(vaultInternalFQDNs []string, vaultCA string) (in
return
}

if health.Standby == false && health.Sealed == false {
if health.Standby == false && health.Sealed == false && health.Initialized == true {
activeNode <- pos

}

}(pos)
}

activePos := <-activeNode
var activePos int
select {
case activePos = <-activeNode:
v.log.Debug("active channel position recieved")
case <-time.After(vaultTunnelCreationTimeoutSeconds * time.Second):
return nil, fmt.Errorf("failed to retrieve active channel position")
}

go func(activePos int) {

// wait for all tunnel attempts
wg.Wait()

// stop tunnels
// stop non-active tunnels
for pos, _ := range tunnels {
if pos == activePos {
continue
Expand Down