Skip to content

Commit

Permalink
[FAB-4420] Suppress benign channel create warning
Browse files Browse the repository at this point in the history
During channel creation, the orderer creates a template channel to apply
the channel creation request to.  This allows for the same signature
checking and validation path to be re-used that is used for config
updates.

However, the template config which the update is applied to is not a
truly valid 'fabric application config', because it does not define
/Channel/Application/Readers or /Channel/Application/Writers, although
it does define an application section.

This causes warnings to superfluously be printed suggesting that the
current config is likely incorrect.

This CR makes an admittedly hacky, but minimally invasive change to
suppress these log messages.

Change-Id: I06dc42a4185b1bf585869a8003436dc622e4606b
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Jun 7, 2017
1 parent c2b5f2d commit 52853f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion common/policies/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ type ManagerImpl struct {
config *policyConfig
pendingConfig map[interface{}]*policyConfig
pendingLock sync.RWMutex

// SuppressSanityLogMessages when set to true will prevent the sanity checking log
// messages. Useful for novel cases like channel templates
SuppressSanityLogMessages bool
}

// NewManagerImpl creates a new ManagerImpl with the given CryptoHelper
Expand Down Expand Up @@ -290,7 +294,7 @@ func (pm *ManagerImpl) CommitProposals(tx interface{}) {
pm.config = pendingConfig
delete(pm.pendingConfig, tx)

if pm.parent == nil && pm.basePath == ChannelPrefix {
if pm.parent == nil && pm.basePath == ChannelPrefix && !pm.SuppressSanityLogMessages {
for _, policyName := range []string{ChannelReaders, ChannelWriters} {
_, ok := pm.GetPolicy(policyName)
if !ok {
Expand Down
15 changes: 14 additions & 1 deletion orderer/multichain/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/hyperledger/fabric/common/config"
"github.com/hyperledger/fabric/common/configtx"
configtxapi "github.com/hyperledger/fabric/common/configtx/api"
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/orderer/ledger"
cb "github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/utils"
Expand Down Expand Up @@ -300,5 +301,17 @@ func (ml *multiLedger) NewChannelConfig(envConfigUpdate *cb.Envelope) (configtxa
},
}, msgVersion, epoch)

return configtx.NewManagerImpl(templateConfig, configtx.NewInitializer(), nil)
initializer := configtx.NewInitializer()

// This is a very hacky way to disable the sanity check logging in the policy manager
// for the template configuration, but it is the least invasive near a release
pm, ok := initializer.PolicyManager().(*policies.ManagerImpl)
if ok {
pm.SuppressSanityLogMessages = true
defer func() {
pm.SuppressSanityLogMessages = false
}()
}

return configtx.NewManagerImpl(templateConfig, initializer, nil)
}

0 comments on commit 52853f8

Please sign in to comment.