Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port over some test fixes #6261

Merged
merged 1 commit into from
Feb 19, 2019
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
15 changes: 15 additions & 0 deletions helper/testhelpers/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,18 @@ func WaitForNCoresSealed(t testing.T, cluster *vault.TestCluster, n int) {

t.Fatalf("%d cores were not sealed", n)
}

func WaitForActiveNode(t testing.T, cluster *vault.TestCluster) *vault.TestClusterCore {
for i := 0; i < 10; i++ {
for _, core := range cluster.Cores {
if standby, _ := core.Core.Standby(); !standby {
return core
}
}

time.Sleep(time.Second)
}

t.Fatalf("node did not become active")
return nil
}
5 changes: 4 additions & 1 deletion vault/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ type ClusterHandler interface {
CALookup(context.Context) (*x509.Certificate, error)

// Handoff is used to pass the connection lifetime off to
// the storage backend
// the handler
Handoff(context.Context, *sync.WaitGroup, chan struct{}, *tls.Conn) error
Stop() error
}
Expand Down Expand Up @@ -366,6 +366,7 @@ func (cl *ClusterListener) TLSConfig(ctx context.Context) (*tls.Config, error) {
}
}

cl.logger.Warn("no TLS certs found for ALPN", "ALPN", clientHello.SupportedProtos)
return nil, errors.New("unsupported protocol")
}

Expand All @@ -381,6 +382,7 @@ func (cl *ClusterListener) TLSConfig(ctx context.Context) (*tls.Config, error) {
}
}

cl.logger.Warn("no client information found")
return nil, errors.New("no client cert found")
}

Expand Down Expand Up @@ -412,6 +414,7 @@ func (cl *ClusterListener) TLSConfig(ctx context.Context) (*tls.Config, error) {
}
}

cl.logger.Warn("no TLS config found for ALPN", "ALPN", clientHello.SupportedProtos)
return nil, errors.New("unsupported protocol")
}

Expand Down
6 changes: 5 additions & 1 deletion vault/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"sync/atomic"

"github.com/hashicorp/errwrap"
"github.com/hashicorp/vault/helper/namespace"
Expand All @@ -30,7 +31,8 @@ type InitResult struct {
}

var (
initPTFunc = func(c *Core) func() { return nil }
initPTFunc = func(c *Core) func() { return nil }
initInProgress uint32
)

// Initialized checks if the Vault is already initialized
Expand Down Expand Up @@ -97,6 +99,8 @@ func (c *Core) generateShares(sc *SealConfig) ([]byte, [][]byte, error) {
// Initialize is used to initialize the Vault with the given
// configurations.
func (c *Core) Initialize(ctx context.Context, initParams *InitParams) (*InitResult, error) {
atomic.StoreUint32(&initInProgress, 1)
defer atomic.StoreUint32(&initInProgress, 0)
barrierConfig := initParams.BarrierConfig
recoveryConfig := initParams.RecoveryConfig

Expand Down
2 changes: 2 additions & 0 deletions vault/request_forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ func (rf *requestForwardingHandler) Handoff(ctx context.Context, shutdownWg *syn

// Stop stops the request forwarding server and closes connections.
func (rf *requestForwardingHandler) Stop() error {
// Give some time for existing RPCs to drain.
time.Sleep(clusterListenerAcceptDeadline)
close(rf.stopCh)
rf.fwRPCServer.Stop()
return nil
Expand Down
4 changes: 3 additions & 1 deletion vault/request_forwarding_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ func (s *forwardedRequestRPCServer) ForwardRequest(ctx context.Context, freq *fo
}
}

resp.LastRemoteWal = LastRemoteWAL(s.core)
// Performance standby nodes will use this value to do wait for WALs to ship
// in order to do a best-effort read after write gurantee
resp.LastRemoteWal = LastWAL(s.core)

return resp, nil
}
Expand Down