From e876e6478ae81978d0b33fb73cb085a31beefcab Mon Sep 17 00:00:00 2001 From: Matthew Sykes Date: Wed, 19 Dec 2018 13:21:24 -0500 Subject: [PATCH] [FAB-13370] increase go env timeout from 10s to 1m kicking the refactor can down the road a bit by simply extending the timeout and adding a call stack to the error that is returned by runProgram. Change-Id: I0b52a87ceaa9f6afd1884024eedeea051545faa1 Signed-off-by: Matthew Sykes --- core/chaincode/exectransaction_test.go | 2 +- core/chaincode/platforms/golang/env.go | 2 +- core/chaincode/platforms/golang/list.go | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/core/chaincode/exectransaction_test.go b/core/chaincode/exectransaction_test.go index 81b3fd1c984..9dff616d1e9 100644 --- a/core/chaincode/exectransaction_test.go +++ b/core/chaincode/exectransaction_test.go @@ -655,7 +655,7 @@ func runChaincodeInvokeChaincode(t *testing.T, channel1 string, channel2 string, if err != nil { stopChaincode(ctxt, cccid1, chaincodeSupport) stopChaincode(ctxt, cccid2, chaincodeSupport) - t.Fatalf("Error initializing chaincode %s(%s)", chaincode2Name, err) + t.Fatalf("Error initializing chaincode %s(%+v)", chaincode2Name, err) return nextBlockNumber1, nextBlockNumber2 } nextBlockNumber1++ diff --git a/core/chaincode/platforms/golang/env.go b/core/chaincode/platforms/golang/env.go index 2f8cc4ed44a..85d561354c3 100644 --- a/core/chaincode/platforms/golang/env.go +++ b/core/chaincode/platforms/golang/env.go @@ -40,7 +40,7 @@ func getEnv() Env { func getGoEnv() (Env, error) { env := getEnv() - goenvbytes, err := runProgram(env, 10*time.Second, "go", "env") + goenvbytes, err := runProgram(env, time.Minute, "go", "env") if err != nil { return nil, err } diff --git a/core/chaincode/platforms/golang/list.go b/core/chaincode/platforms/golang/list.go index 91e7fa26243..40f23d36c0a 100644 --- a/core/chaincode/platforms/golang/list.go +++ b/core/chaincode/platforms/golang/list.go @@ -23,6 +23,8 @@ import ( "os/exec" "strings" "time" + + "github.com/pkg/errors" ) //runProgram non-nil Env, timeout (typically secs or millisecs), program name and args @@ -43,16 +45,10 @@ func runProgram(env Env, timeout time.Duration, pgm string, args ...string) ([]b if ctx.Err() == context.DeadlineExceeded { err = fmt.Errorf("timed out after %s", timeout) } - if err != nil { - return nil, - fmt.Errorf( - "command <%s %s>: failed with error: \"%s\"\n%s", - pgm, - strings.Join(args, " "), - err, - string(stdErr.Bytes())) + return nil, errors.Errorf("command <%s %s>: failed with error: \"%s\"\n%s", pgm, strings.Join(args, " "), err, stdErr) } + return out, nil } @@ -62,7 +58,7 @@ func list(env Env, template, pkg string) ([]string, error) { env = getEnv() } - lst, err := runProgram(env, 60*time.Second, "go", "list", "-f", template, pkg) + lst, err := runProgram(env, time.Minute, "go", "list", "-f", template, pkg) if err != nil { return nil, err }