Skip to content

Commit 04e9a3f

Browse files
committed
[FAB-3664] Update chaincode.startuptimeout to duration
This CR updates the chaincode startup timeout from an integer to a time duration. This has been done for consistency with other timeouts defined for the peer and orderer. Change-Id: Ib896808b52f15e7320641302d5ed21ffbc2a6c62 Signed-off-by: Will Lahti <[email protected]>
1 parent 3f35491 commit 04e9a3f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

peer/node/start.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"os"
2424
"os/signal"
2525
"path/filepath"
26-
"strconv"
2726
"strings"
2827
"syscall"
2928
"time"
@@ -296,12 +295,13 @@ func registerChaincodeSupport(grpcServer *grpc.Server) {
296295
userRunsCC := chaincode.IsDevMode()
297296

298297
//get chaincode startup timeout
299-
tOut, err := strconv.Atoi(viper.GetString("chaincode.startuptimeout"))
300-
if err != nil { //what went wrong ?
301-
logger.Warning("could not retrieve timeout var...setting to 5secs")
302-
tOut = 5000
298+
ccStartupTimeout := viper.GetDuration("chaincode.startuptimeout")
299+
if ccStartupTimeout < time.Duration(5)*time.Second {
300+
logger.Warningf("Invalid chaincode startup timeout value %s (should be at least 5s); defaulting to 5s", ccStartupTimeout)
301+
ccStartupTimeout = time.Duration(5) * time.Second
302+
} else {
303+
logger.Debugf("Chaincode startup timeout value set to %s", ccStartupTimeout)
303304
}
304-
ccStartupTimeout := time.Duration(tOut) * time.Millisecond
305305

306306
ccSrv := chaincode.NewChaincodeSupport(peer.GetPeerEndpoint, userRunsCC, ccStartupTimeout)
307307

sampleconfig/core.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ chaincode:
297297
Dockerfile: |
298298
from $(DOCKER_NS)/fabric-javaenv:$(ARCH)-$(PROJECT_VERSION)
299299
300-
# timeout in millisecs for starting up a container and waiting for Register
300+
# timeout duration for starting up a container and waiting for Register
301301
# to come through. 1sec should be plenty for chaincode unit tests
302-
startuptimeout: 300000
302+
startuptimeout: 300s
303303

304304
# timeout in millisecs for invokes and initialize commands
305305
# this timeout is used by all chaincodes in all the channels including

0 commit comments

Comments
 (0)