Skip to content

Commit 52853f8

Browse files
author
Jason Yellick
committed
[FAB-4420] Suppress benign channel create warning
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 <[email protected]>
1 parent c2b5f2d commit 52853f8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

common/policies/policy.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ type ManagerImpl struct {
132132
config *policyConfig
133133
pendingConfig map[interface{}]*policyConfig
134134
pendingLock sync.RWMutex
135+
136+
// SuppressSanityLogMessages when set to true will prevent the sanity checking log
137+
// messages. Useful for novel cases like channel templates
138+
SuppressSanityLogMessages bool
135139
}
136140

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

293-
if pm.parent == nil && pm.basePath == ChannelPrefix {
297+
if pm.parent == nil && pm.basePath == ChannelPrefix && !pm.SuppressSanityLogMessages {
294298
for _, policyName := range []string{ChannelReaders, ChannelWriters} {
295299
_, ok := pm.GetPolicy(policyName)
296300
if !ok {

orderer/multichain/manager.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/hyperledger/fabric/common/config"
2323
"github.com/hyperledger/fabric/common/configtx"
2424
configtxapi "github.com/hyperledger/fabric/common/configtx/api"
25+
"github.com/hyperledger/fabric/common/policies"
2526
"github.com/hyperledger/fabric/orderer/ledger"
2627
cb "github.com/hyperledger/fabric/protos/common"
2728
"github.com/hyperledger/fabric/protos/utils"
@@ -300,5 +301,17 @@ func (ml *multiLedger) NewChannelConfig(envConfigUpdate *cb.Envelope) (configtxa
300301
},
301302
}, msgVersion, epoch)
302303

303-
return configtx.NewManagerImpl(templateConfig, configtx.NewInitializer(), nil)
304+
initializer := configtx.NewInitializer()
305+
306+
// This is a very hacky way to disable the sanity check logging in the policy manager
307+
// for the template configuration, but it is the least invasive near a release
308+
pm, ok := initializer.PolicyManager().(*policies.ManagerImpl)
309+
if ok {
310+
pm.SuppressSanityLogMessages = true
311+
defer func() {
312+
pm.SuppressSanityLogMessages = false
313+
}()
314+
}
315+
316+
return configtx.NewManagerImpl(templateConfig, initializer, nil)
304317
}

0 commit comments

Comments
 (0)