Skip to content

Commit

Permalink
gRPC: Use abstract unix sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Apr 23, 2020
1 parent 1b22e03 commit 4ea2199
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go/oasis-net-runner/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func runRoot(cmd *cobra.Command, args []string) error {
// Display information about where the client node socket is.
if len(net.Clients()) > 0 {
logger.Info("client node socket available",
"path", net.Clients()[0].SocketPath(),
"path", "unix:"+net.Clients()[0].SocketPath(),
)
}

Expand Down
4 changes: 3 additions & 1 deletion go/oasis-node/cmd/common/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package grpc

import (
"crypto/sha256"
"crypto/tls"
"errors"
"fmt"
Expand Down Expand Up @@ -68,7 +69,8 @@ func NewServerLocal(installWrapper bool) (*cmnGrpc.Server, error) {
if dataDir == "" {
return nil, errors.New("data directory must be set")
}
path := filepath.Join(dataDir, localSocketFilename)
p := filepath.Join(dataDir, localSocketFilename)
path := fmt.Sprintf("@%x", sha256.Sum256([]byte(p)))

config := &cmnGrpc.ServerConfig{
Name: "internal",
Expand Down
14 changes: 8 additions & 6 deletions go/oasis-node/cmd/common/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ func GetDefaultPushLabels(ti env.TestInstanceInfo) map[string]string {
labels[MetricsLabelGitBranch] = version.GitBranch
}
// Populate it with test-provided parameters.
ti.ParameterSet.VisitAll(func(f *flag.Flag) {
labels[EscapeLabelCharacters(f.Name)] = f.Value.String()
})
// Override any labels passed to oasis-test-runner via CLI.
for k, v := range flags.GetStringMapString(CfgMetricsLabels) {
labels[k] = v
if ti.ParameterSet != nil {
ti.ParameterSet.VisitAll(func(f *flag.Flag) {
labels[EscapeLabelCharacters(f.Name)] = f.Value.String()
})
// Override any labels passed to oasis-test-runner via CLI.
for k, v := range flags.GetStringMapString(CfgMetricsLabels) {
labels[k] = v
}
}

return labels
Expand Down
4 changes: 1 addition & 3 deletions go/oasis-test-runner/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package cmd

import (
"crypto/sha256"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -313,8 +312,7 @@ func runRoot(cmd *cobra.Command, args []string) error {
for i, v := range scs {
// If number of runs is greater than 1 or there are multiple parameter sets for test, maintain unique
// scenario datadir by appending unique run ID.
nameHash := sha256.Sum256([]byte(name))
n := fmt.Sprintf("%x", nameHash[0:4])
n := name
runID := run*len(scs) + i
if numRuns > 1 || len(scs) > 1 {
n = fmt.Sprintf("%s/%d", n, runID)
Expand Down
6 changes: 4 additions & 2 deletions go/oasis-test-runner/oasis/oasis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package oasis

import (
"crypto"
"crypto/sha256"
"fmt"
"io"
"math"
Expand Down Expand Up @@ -623,7 +624,7 @@ func (net *Network) startOasisNode(
tendermintDebugAddrBookLenient().
tendermintDebugAllowDuplicateIP()
}
if viper.GetString(metrics.CfgMetricsAddr) != "" {
if viper.IsSet(metrics.CfgMetricsAddr) {
extraArgs = extraArgs.appendNodeMetrics(node)
}
args := append([]string{}, subCmd...)
Expand Down Expand Up @@ -811,7 +812,8 @@ func nodeLogPath(dir *env.Dir) string {
}

func internalSocketPath(dir *env.Dir) string {
return filepath.Join(dir.String(), internalSocketFile)
p := filepath.Join(dir.String(), internalSocketFile)
return fmt.Sprintf("@%x", sha256.Sum256([]byte(p)))
}

func nodeIdentityKeyPath(dir *env.Dir) string {
Expand Down

0 comments on commit 4ea2199

Please sign in to comment.