Skip to content

Commit

Permalink
[FAB-9338] Increase def timeout with empty config
Browse files Browse the repository at this point in the history
Change-Id: Ib2dea7e9244522eee2334fac289948ab31fbcf00
Signed-off-by: Baha Shaaban <[email protected]>
  • Loading branch information
Baha Shaaban committed Apr 5, 2018
1 parent 0a27dbc commit 1231625
Show file tree
Hide file tree
Showing 27 changed files with 305 additions and 410 deletions.
6 changes: 3 additions & 3 deletions pkg/client/channel/chclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func New(channelProvider context.ChannelProvider, opts ...ClientOption) (*Client
return nil, errors.WithMessage(err, "failed to create channel context")
}

greylistProvider := greylist.New(channelContext.EndpointConfig().TimeoutOrDefault(fab.DiscoveryGreylistExpiry))
greylistProvider := greylist.New(channelContext.EndpointConfig().Timeout(fab.DiscoveryGreylistExpiry))

if channelContext.ChannelService() == nil {
return nil, errors.New("channel service not initialized")
Expand Down Expand Up @@ -155,7 +155,7 @@ func (cc *Client) createReqContext(txnOpts *requestOptions) (reqContext.Context,

//setting default timeouts when not provided
if txnOpts.Timeouts[fab.Execute] == 0 {
txnOpts.Timeouts[fab.Execute] = cc.context.EndpointConfig().TimeoutOrDefault(fab.Execute)
txnOpts.Timeouts[fab.Execute] = cc.context.EndpointConfig().Timeout(fab.Execute)
}

reqCtx, cancel := contextImpl.NewRequest(cc.context, contextImpl.WithTimeout(txnOpts.Timeouts[fab.Execute]),
Expand Down Expand Up @@ -236,7 +236,7 @@ func (cc *Client) addDefaultTimeout(ctx context.Client, timeOutType fab.TimeoutT

if txnOpts.Timeouts[timeOutType] == 0 {
//InvokeHandler relies on Execute timeout
return append(options, WithTimeout(fab.Execute, cc.context.EndpointConfig().TimeoutOrDefault(timeOutType))), nil
return append(options, WithTimeout(fab.Execute, cc.context.EndpointConfig().Timeout(timeOutType))), nil
}
return options, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/channel/chclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ func TestDiscoveryGreylist(t *testing.T) {
assert.EqualValues(t, status.NoPeersFound.ToInt32(), s.Code, "expected No Peers Found status on greylist")
assert.Equal(t, 1, testPeer1.ProcessProposalCalls, "expected peer 1 to be greylisted")
// Wait for greylist expiry
time.Sleep(chClient.context.EndpointConfig().TimeoutOrDefault(fab.DiscoveryGreylistExpiry))
time.Sleep(chClient.context.EndpointConfig().Timeout(fab.DiscoveryGreylistExpiry))
testPeer1.ProcessProposalCalls = 0
testPeer1.Error = status.New(status.EndorserServerStatus, int32(common.Status_SERVICE_UNAVAILABLE), "test", nil)
// Try again
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (c *Client) createRequestContext(opts *requestOptions) (reqContext.Context,
}

if opts.Timeouts[fab.PeerResponse] == 0 {
opts.Timeouts[fab.PeerResponse] = c.ctx.EndpointConfig().TimeoutOrDefault(fab.PeerResponse)
opts.Timeouts[fab.PeerResponse] = c.ctx.EndpointConfig().Timeout(fab.PeerResponse)
}

return contextImpl.NewRequest(c.ctx, contextImpl.WithTimeout(opts.Timeouts[fab.PeerResponse]), contextImpl.WithParent(opts.ParentContext))
Expand Down
8 changes: 4 additions & 4 deletions pkg/client/resmgmt/resmgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ func (rc *Client) createRequestContext(opts requestOptions, defaultTimeoutType f
rc.resolveTimeouts(&opts)

if opts.Timeouts[defaultTimeoutType] == 0 {
opts.Timeouts[defaultTimeoutType] = rc.ctx.EndpointConfig().TimeoutOrDefault(defaultTimeoutType)
opts.Timeouts[defaultTimeoutType] = rc.ctx.EndpointConfig().Timeout(defaultTimeoutType)
}

return contextImpl.NewRequest(rc.ctx, contextImpl.WithTimeout(opts.Timeouts[defaultTimeoutType]), contextImpl.WithParent(opts.ParentContext))
Expand All @@ -945,14 +945,14 @@ func (rc *Client) resolveTimeouts(opts *requestOptions) {
}

if opts.Timeouts[fab.ResMgmt] == 0 {
opts.Timeouts[fab.ResMgmt] = rc.ctx.EndpointConfig().TimeoutOrDefault(fab.ResMgmt)
opts.Timeouts[fab.ResMgmt] = rc.ctx.EndpointConfig().Timeout(fab.ResMgmt)
}

if opts.Timeouts[fab.OrdererResponse] == 0 {
opts.Timeouts[fab.OrdererResponse] = rc.ctx.EndpointConfig().TimeoutOrDefault(fab.OrdererResponse)
opts.Timeouts[fab.OrdererResponse] = rc.ctx.EndpointConfig().Timeout(fab.OrdererResponse)
}

if opts.Timeouts[fab.PeerResponse] == 0 {
opts.Timeouts[fab.PeerResponse] = rc.ctx.EndpointConfig().TimeoutOrDefault(fab.PeerResponse)
opts.Timeouts[fab.PeerResponse] = rc.ctx.EndpointConfig().Timeout(fab.PeerResponse)
}
}
1 change: 0 additions & 1 deletion pkg/common/providers/fab/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ type CommManager interface {

//EndpointConfig contains endpoint network configurations
type EndpointConfig interface {
TimeoutOrDefault(TimeoutType) time.Duration
Timeout(TimeoutType) time.Duration
MSPID(org string) (string, error)
PeerMSPID(name string) (string, error)
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/providers/test/mockfab/mockconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func DefaultMockConfig(mockCtrl *gomock.Controller) *MockEndpointConfig {
config.EXPECT().TLSCACertPool(GoodCert).Return(CertPool, nil).AnyTimes()
config.EXPECT().TLSCACertPool(BadCert).Return(CertPool, errors.New(ErrorMessage)).AnyTimes()
config.EXPECT().TLSCACertPool().Return(CertPool, nil).AnyTimes()
config.EXPECT().TimeoutOrDefault(fab.EndorserConnection).Return(time.Second * 5).AnyTimes()
config.EXPECT().Timeout(fab.EndorserConnection).Return(time.Second * 5).AnyTimes()
config.EXPECT().TLSClientCerts().Return([]tls.Certificate{TLSCert}, nil).AnyTimes()

return config
Expand All @@ -51,7 +51,7 @@ func BadTLSClientMockConfig(mockCtrl *gomock.Controller) *MockEndpointConfig {
config.EXPECT().TLSCACertPool(GoodCert).Return(CertPool, nil).AnyTimes()
config.EXPECT().TLSCACertPool(BadCert).Return(CertPool, errors.New(ErrorMessage)).AnyTimes()
config.EXPECT().TLSCACertPool().Return(CertPool, nil).AnyTimes()
config.EXPECT().TimeoutOrDefault(fab.EndorserConnection).Return(time.Second * 5).AnyTimes()
config.EXPECT().Timeout(fab.EndorserConnection).Return(time.Second * 5).AnyTimes()
config.EXPECT().TLSClientCerts().Return(nil, errors.Errorf(ErrorMessage)).AnyTimes()

return config
Expand Down
12 changes: 0 additions & 12 deletions pkg/common/providers/test/mockfab/mockfab.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func NewRequest(client context.Client, options ...ReqContextOptions) (reqContext
} else if timeoutOverride := requestTimeoutOverride(parentContext, reqCtxOpts.timeoutType); timeoutOverride > 0 {
timeout = timeoutOverride
} else {
timeout = client.EndpointConfig().TimeoutOrDefault(reqCtxOpts.timeoutType)
timeout = client.EndpointConfig().Timeout(reqCtxOpts.timeoutType)
}

ctx := reqContext.WithValue(parentContext, reqContextCommManager, client.InfraProvider().CommManager())
Expand Down
28 changes: 0 additions & 28 deletions pkg/core/config/testdata/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,10 @@ client:
logging:
level: info

# Global configuration for peer, event service and orderer timeouts
peer:
timeout:
response: 40s
connection: 3s
discovery:
# Expiry period for discovery service greylist filter
# The channel client will greylist peers that are found to be offline
# to prevent re-selecting them in subsequent retries.
# This interval will define how long a peer is greylisted
greylistExpiry: 5s
eventService:
# Event service type (deliver|eventhub) - default: eventhub
# NOTE: This is temporary until the SDK starts making use of channel capabilities
type: eventhub
timeout:
connection: 3s
registrationResponse: 10s
orderer:
timeout:
connection: 3s
response: 10s
global:
timeout:
query: 45s
execute: 60s
resmgmt: 60s
cache:
connectionIdle: 30s
eventServiceIdle: 2m
channelConfig: 60s
channelMembership: 30s

# Root of the MSP directories with keys and certs.
cryptoconfig:
Expand Down
28 changes: 0 additions & 28 deletions pkg/core/config/testdata/config_test_embedded_pems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,10 @@ client:
logging:
level: info

# Global configuration for peer, event service and orderer timeouts
peer:
timeout:
response: 40s
connection: 3s
discovery:
# Expiry period for discovery service greylist filter
# The channel client will greylist peers that are found to be offline
# to prevent re-selecting them in subsequent retries.
# This interval will define how long a peer is greylisted
greylistExpiry: 5s
eventService:
# Event service type (deliver|eventhub) - default: eventhub
# NOTE: This is temporary until the SDK starts making use of channel capabilities
type: eventhub
timeout:
connection: 3s
registrationResponse: 10s
orderer:
timeout:
connection: 3s
response: 10s
global:
timeout:
query: 45s
execute: 60s
resmgmt: 60s
cache:
connectionIdle: 30s
eventServiceIdle: 2m
channelConfig: 60s
channelMembership: 30s

# Needed to load users crypto keys and certs.
# cryptoconfig:
Expand Down
27 changes: 3 additions & 24 deletions pkg/core/config/testdata/config_test_pem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,10 @@ client:
logging:
level: info

# Global configuration for peer, event service and orderer timeouts
peer:
timeout:
response: 10s
connection: 3s
discovery:
greylistExpiry: 5s
eventService:
timeout:
connection: 3s
registrationResponse: 3s
orderer:
timeout:
connection: 3s
response: 5s
global:
timeout:
query: 45s
execute: 60s
resmgmt: 60s
cache:
connectionIdle: 30s
eventServiceIdle: 2m
channelConfig: 60s
channelMembership: 30s
# Event service type (deliver|eventhub) - default: eventhub
# NOTE: This is temporary until the SDK starts making use of channel capabilities
type: eventhub

# Needed to load users crypto keys and certs.
cryptoconfig:
Expand Down
54 changes: 27 additions & 27 deletions pkg/core/config/testdata/config_test_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,37 @@ client:
level: info

# Global configuration for peer, event service and orderer timeouts
peer:
timeout:
response: 40s
connection: 3s
discovery:
# Expiry period for discovery service greylist filter
# The channel client will greylist peers that are found to be offline
# to prevent re-selecting them in subsequent retries.
# This interval will define how long a peer is greylisted
greylistExpiry: 5s
# peer:
# timeout:
# connection: 10s
# response: 180s
# discovery:
# # Expiry period for discovery service greylist filter
# # The channel client will greylist peers that are found to be offline
# # to prevent re-selecting them in subsequent retries.
# # This interval will define how long a peer is greylisted
# greylistExpiry: 10s
eventService:
# Event service type (deliver|eventhub) - default: eventhub
# NOTE: This is temporary until the SDK starts making use of channel capabilities
type: eventhub
timeout:
connection: 3s
registrationResponse: 10s
orderer:
timeout:
connection: 3s
response: 10s
global:
timeout:
query: 45s
execute: 60s
resmgmt: 60s
cache:
connectionIdle: 30s
eventServiceIdle: 2m
channelConfig: 60s
channelMembership: 30s
# timeout:
# connection: 15s
# registrationResponse: 15s
# orderer:
# timeout:
# connection: 15s
# response: 15s
# global:
# timeout:
# query: 180s
# execute: 180s
# resmgmt: 180s
# cache:
# connectionIdle: 30s
# eventServiceIdle: 2m
# channelConfig: 30m
# channelMembership: 30s

# Root of the MSP directories with keys and certs.
cryptoconfig:
Expand Down
56 changes: 32 additions & 24 deletions pkg/core/config/testdata/template/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,39 @@ client:
logging:
level: info

# Global configuration for peer, event service and orderer timeouts
peer:
timeout:
response: 10s
connection: 3s
discovery:
greylistExpiry: 5s
# Global configuration for peer, event service and orderer timeouts
# if this this section is omitted, then default values will be used (same values as below)
# peer:
# timeout:
# connection: 10s
# response: 180s
# discovery:
# # Expiry period for discovery service greylist filter
# # The channel client will greylist peers that are found to be offline
# # to prevent re-selecting them in subsequent retries.
# # This interval will define how long a peer is greylisted
# greylistExpiry: 10s
eventService:
timeout:
connection: 3s
registrationResponse: 3s
orderer:
timeout:
connection: 3s
response: 5s
global:
timeout:
query: 45s
execute: 60s
resmgmt: 60s
cache:
connectionIdle: 30s
eventServiceIdle: 2m
channelConfig: 60s
channelMembership: 30s
# Event service type (deliver|eventhub) - default: deliver
# NOTE: This is temporary until the SDK starts making use of channel capabilities
type: deliver
# timeout:
# connection: 15s
# registrationResponse: 15s
# orderer:
# timeout:
# connection: 15s
# response: 15s
# global:
# timeout:
# query: 180s
# execute: 180s
# resmgmt: 180s
# cache:
# connectionIdle: 30s
# eventServiceIdle: 2m
# channelConfig: 30m
# channelMembership: 30s

# Needed to load users crypto keys and certs.
cryptoconfig:
Expand Down
Loading

0 comments on commit 1231625

Please sign in to comment.