Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix AssetManager startup retry #1484

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/assets/manager.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -73,7 +73,7 @@ type Manager interface {
RunOperation(ctx context.Context, op *core.PreparedOperation) (outputs fftypes.JSONObject, phase core.OpPhase, err error)

// Starts the namespace on each of the configured token plugins
Start(ctx context.Context) error
Start() error
}

type assetManager struct {
Expand Down Expand Up @@ -173,9 +173,9 @@ func (am *assetManager) GetTokenConnectors(ctx context.Context) []*core.TokenCon
return connectors
}

func (am *assetManager) Start(ctx context.Context) error {
f := database.TokenPoolQueryFactory.NewFilter(ctx).And()
pools, _, err := am.database.GetTokenPools(ctx, am.namespace, f)
func (am *assetManager) Start() error {
f := database.TokenPoolQueryFactory.NewFilter(am.ctx).And()
pools, _, err := am.database.GetTokenPools(am.ctx, am.namespace, f)
if err != nil {
return err
}
Expand All @@ -187,7 +187,7 @@ func (am *assetManager) Start(ctx context.Context) error {
activePools = append(activePools, pool)
}
}
err := plugin.StartNamespace(ctx, am.namespace, activePools)
err := plugin.StartNamespace(am.ctx, am.namespace, activePools)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/assets/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func TestStart(t *testing.T) {
txHelper, _ := txcommon.NewTransactionHelper(context.Background(), "ns1", mdi, mdm, cmi)
am, err := NewAssetManager(context.Background(), "ns1", "blockchain_plugin", mdi, map[string]tokens.Plugin{"magic-tokens": mti}, mim, msa, mbm, mpm, mm, mom, mcm, txHelper, cmi)
assert.NoError(t, err)
err = am.Start(context.Background())
err = am.Start()
assert.NoError(t, err)
}

Expand All @@ -211,7 +211,7 @@ func TestStartDBError(t *testing.T) {
txHelper, _ := txcommon.NewTransactionHelper(context.Background(), "ns1", mdi, mdm, cmi)
am, err := NewAssetManager(context.Background(), "ns1", "blockchain_plugin", mdi, map[string]tokens.Plugin{"magic-tokens": mti}, mim, msa, mbm, mpm, mm, mom, mcm, txHelper, cmi)
assert.NoError(t, err)
err = am.Start(context.Background())
err = am.Start()
assert.Regexp(t, "pop", err)
}

Expand Down Expand Up @@ -241,6 +241,6 @@ func TestStartError(t *testing.T) {
txHelper, _ := txcommon.NewTransactionHelper(context.Background(), "ns1", mdi, mdm, cmi)
am, err := NewAssetManager(context.Background(), "ns1", "blockchain_plugin", mdi, map[string]tokens.Plugin{"magic-tokens": mti}, mim, msa, mbm, mpm, mm, mom, mcm, txHelper, cmi)
assert.NoError(t, err)
err = am.Start(context.Background())
err = am.Start()
assert.Regexp(t, "pop", err)
}
6 changes: 3 additions & 3 deletions internal/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ func (or *orchestrator) Start() (err error) {
if err == nil {
or.txWriter.Start()
}
if err == nil {
err = or.assets.Start()
}

or.started = true
return err
Expand Down Expand Up @@ -544,9 +547,6 @@ func (or *orchestrator) initManagers(ctx context.Context) (err error) {
if err != nil {
return err
}
if err := or.assets.Start(ctx); err != nil {
return err
}
}

if or.defsender == nil {
Expand Down
14 changes: 2 additions & 12 deletions internal/orchestrator/orchestrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,6 @@ func TestInitMessagingComponentFail(t *testing.T) {
assert.Regexp(t, "FF10128", err)
}

func TestInitTokensFail(t *testing.T) {
or := newTestOrchestrator()
defer or.cleanup(t)
or.assets = nil
or.mom.On("RegisterHandler", mock.Anything, mock.Anything, mock.Anything)
or.mmp.On("ConfigureContract", mock.Anything).Return(nil)
or.mdi.On("GetTokenPools", mock.Anything, "ns", mock.Anything).Return([]*core.TokenPool{}, nil, nil)
or.mti.On("StartNamespace", mock.Anything, "ns", mock.Anything).Return(fmt.Errorf("pop"))
err := or.initManagers(context.Background())
assert.Regexp(t, "pop", err)
}

func TestInitEventsComponentFail(t *testing.T) {
or := newTestOrchestrator()
defer or.cleanup(t)
Expand Down Expand Up @@ -496,6 +484,7 @@ func TestStartStopOk(t *testing.T) {
or.msd.On("Start").Return(nil)
or.mom.On("Start").Return(nil)
or.mtw.On("Start").Return()
or.mam.On("Start").Return(nil)
or.mba.On("WaitStop").Return(nil)
or.mbm.On("WaitStop").Return(nil)
or.mdm.On("WaitStop").Return(nil)
Expand All @@ -518,6 +507,7 @@ func TestStartStopOk(t *testing.T) {
or.msd.On("Start").Return(nil)
or.mom.On("Start").Return(nil)
or.mtw.On("Start").Return()
or.mam.On("Start").Return(nil)
or.mba.On("WaitStop").Return(nil)
or.mbm.On("WaitStop").Return(nil)
or.mdm.On("WaitStop").Return(nil)
Expand Down
2 changes: 1 addition & 1 deletion mocks/apiservermocks/ffi_swagger_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 mocks/apiservermocks/server.go

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

16 changes: 10 additions & 6 deletions mocks/assetmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/batchmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/blockchaincommonmocks/firefly_subscriptions.go

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

2 changes: 1 addition & 1 deletion mocks/blockchainmocks/callbacks.go

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

8 changes: 6 additions & 2 deletions mocks/blockchainmocks/plugin.go

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

2 changes: 1 addition & 1 deletion mocks/broadcastmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/cachemocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/contractmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/coremocks/operation_callbacks.go

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

2 changes: 1 addition & 1 deletion mocks/databasemocks/callbacks.go

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

2 changes: 1 addition & 1 deletion mocks/databasemocks/plugin.go

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

2 changes: 1 addition & 1 deletion mocks/dataexchangemocks/callbacks.go

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

2 changes: 1 addition & 1 deletion mocks/dataexchangemocks/dx_event.go

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

2 changes: 1 addition & 1 deletion mocks/dataexchangemocks/plugin.go

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

2 changes: 1 addition & 1 deletion mocks/datamocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/definitionsmocks/handler.go

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

2 changes: 1 addition & 1 deletion mocks/definitionsmocks/sender.go

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

2 changes: 1 addition & 1 deletion mocks/eventmocks/event_manager.go

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

2 changes: 1 addition & 1 deletion mocks/eventsmocks/callbacks.go

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

2 changes: 1 addition & 1 deletion mocks/eventsmocks/plugin.go

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

2 changes: 1 addition & 1 deletion mocks/identitymanagermocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/identitymocks/callbacks.go

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

2 changes: 1 addition & 1 deletion mocks/identitymocks/plugin.go

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

2 changes: 1 addition & 1 deletion mocks/metricsmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/multipartymocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/namespacemocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/networkmapmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/operationmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/orchestratormocks/orchestrator.go

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

2 changes: 1 addition & 1 deletion mocks/privatemessagingmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/shareddownloadmocks/callbacks.go

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

2 changes: 1 addition & 1 deletion mocks/shareddownloadmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/sharedstoragemocks/callbacks.go

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

2 changes: 1 addition & 1 deletion mocks/sharedstoragemocks/plugin.go

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

2 changes: 1 addition & 1 deletion mocks/spieventsmocks/manager.go

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

2 changes: 1 addition & 1 deletion mocks/syncasyncmocks/bridge.go

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

2 changes: 1 addition & 1 deletion mocks/syncasyncmocks/sender.go

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

Loading
Loading