Skip to content

Commit

Permalink
[FAB-3348] chaincode should log build level
Browse files Browse the repository at this point in the history
Chaincode images may become stale and may not match fabric
runtime images. Cleaning of chaincode images will take care
of this but it will help trouble-shooting to know the build
level of the chaincode and if it matches the fabric build
level

Version information should be passed to the chaincode at the
time of building it so the chaincode can log it.

This results log :

2017-04-23 11:03:13.281 UTC [shim] SetupChaincodeLogging ->
   INFO 001 Chaincode (build level-1.0.0-snapshot-88ac3ba)
   starting up ...

Change-Id: I44dfb527ff0cb9039c80855c3e52ca3e9ba3e304
Signed-off-by: Srinivasan Muralidharan <muralisr@us.ibm.com>
  • Loading branch information
Srinivasan Muralidharan committed Apr 23, 2017
1 parent 88ac3ba commit 7fae4b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/chaincode/platforms/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ func generateDockerfile(platform Platform, cds *pb.ChaincodeDeploymentSpec, tls
// ----------------------------------------------------------------------------------------------------
// Then augment it with any general options
// ----------------------------------------------------------------------------------------------------
//append version so chaincode build version can be campared against peer build version
buf = append(buf, fmt.Sprintf("ENV CORE_CHAINCODE_BUILDLEVEL=%s", metadata.Version))

if tls {
const guestTLSPath = "/etc/hyperledger/fabric/peer.crt"

Expand Down
5 changes: 4 additions & 1 deletion core/chaincode/shim/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ func SetupChaincodeLogging() {
chaincodeLogger.Warningf("Error: %s for chaincode log level: %s", err, chaincodeLogLevelString)
}
}

//now that logging is setup, print build level. This will help making sure
//chaincode is matched with peer.
buildLevel := viper.GetString("chaincode.buildlevel")
chaincodeLogger.Infof("Chaincode (build level: %s) starting up ...", buildLevel)
}

// StartInProc is an entry point for system chaincodes bootstrap. It is not an
Expand Down

0 comments on commit 7fae4b4

Please sign in to comment.