From 16e059cd33121802d105981d7319e77371870ff4 Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 20 Nov 2024 16:44:56 +0000 Subject: [PATCH 1/8] Fix reindexing token pool created events when creation and active are different steps Signed-off-by: Enrique Lacal --- internal/events/token_pool_created.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/events/token_pool_created.go b/internal/events/token_pool_created.go index 2fb4c1ea2..67a3faf5f 100644 --- a/internal/events/token_pool_created.go +++ b/internal/events/token_pool_created.go @@ -131,12 +131,24 @@ func (em *eventManager) loadFromOperation(ctx context.Context, pool *tokens.Toke return nil, nil } + activateOp, _ := em.txHelper.FindOperationInTransaction(ctx, pool.TX.ID, core.OpTypeTokenActivatePool) + if activateOp != nil { + log.L(ctx).Debugf("There was a separate operation to active the pool for tx=%s status=%s", pool.TX.ID, core.OpTypeTokenActivatePool) + } + stagedPool, err = txcommon.RetrieveTokenPoolCreateInputs(ctx, op) if err != nil || stagedPool.ID == nil || stagedPool.Namespace == "" || stagedPool.Name == "" { log.L(ctx).Errorf("Error loading pool info for transaction '%s' (%s) - ignoring: %v", pool.TX.ID, err, op.Input) return nil, nil } + // If we have successfully activated the pool + // Then set the pool published to true + // As it won't be in the initial payload + if activateOp != nil && activateOp.Status == core.OpStatusSucceeded { + stagedPool.Published = true + } + if err = addPoolDetailsFromPlugin(stagedPool, pool); err != nil { log.L(ctx).Errorf("Error processing pool for transaction '%s' (%s) - ignoring", pool.TX.ID, err) return nil, nil From 7ec035d8b0c14da8ebe79a8a79445f6a3336e97a Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 20 Nov 2024 16:59:18 +0000 Subject: [PATCH 2/8] Ignore if same ID for token pool creation event on re-index Signed-off-by: Enrique Lacal --- internal/definitions/handler_tokenpool.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/definitions/handler_tokenpool.go b/internal/definitions/handler_tokenpool.go index 048f59cef..ad66e3696 100644 --- a/internal/definitions/handler_tokenpool.go +++ b/internal/definitions/handler_tokenpool.go @@ -92,6 +92,11 @@ func (dh *definitionHandler) handleTokenPoolDefinition(ctx context.Context, stat } } + if existing.ID.Equals(pool.ID) { + log.L(ctx).Warnf("Received duplicate event for token pool creation with ID=%s, ignoring and carrying on for token connector: %s", pool.ID, pool.Connector) + break + } + // Any other conflict - reject return HandlerResult{Action: core.ActionReject, CustomCorrelator: correlator}, i18n.NewError(ctx, coremsgs.MsgDefRejectedConflict, "token pool", pool.ID, existing.ID) } From cfa66ce81f78f5bfc0db9ec02f1008fcaa65ca0d Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 20 Nov 2024 17:00:18 +0000 Subject: [PATCH 3/8] Slightly update the error message Signed-off-by: Enrique Lacal --- internal/definitions/handler_tokenpool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/definitions/handler_tokenpool.go b/internal/definitions/handler_tokenpool.go index ad66e3696..8e2d38d38 100644 --- a/internal/definitions/handler_tokenpool.go +++ b/internal/definitions/handler_tokenpool.go @@ -93,7 +93,7 @@ func (dh *definitionHandler) handleTokenPoolDefinition(ctx context.Context, stat } if existing.ID.Equals(pool.ID) { - log.L(ctx).Warnf("Received duplicate event for token pool creation with ID=%s, ignoring and carrying on for token connector: %s", pool.ID, pool.Connector) + log.L(ctx).Warnf("Received duplicate token pool creation with ID=%s, ignoring and carrying on for token connector: %s", pool.ID, pool.Connector) break } From 276bc7be55db17a3a5a907f8bd544176b15637a4 Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 20 Nov 2024 17:03:16 +0000 Subject: [PATCH 4/8] remove changes in loading operation with token pool activation Signed-off-by: Enrique Lacal --- internal/events/token_pool_created.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/internal/events/token_pool_created.go b/internal/events/token_pool_created.go index 67a3faf5f..2fb4c1ea2 100644 --- a/internal/events/token_pool_created.go +++ b/internal/events/token_pool_created.go @@ -131,24 +131,12 @@ func (em *eventManager) loadFromOperation(ctx context.Context, pool *tokens.Toke return nil, nil } - activateOp, _ := em.txHelper.FindOperationInTransaction(ctx, pool.TX.ID, core.OpTypeTokenActivatePool) - if activateOp != nil { - log.L(ctx).Debugf("There was a separate operation to active the pool for tx=%s status=%s", pool.TX.ID, core.OpTypeTokenActivatePool) - } - stagedPool, err = txcommon.RetrieveTokenPoolCreateInputs(ctx, op) if err != nil || stagedPool.ID == nil || stagedPool.Namespace == "" || stagedPool.Name == "" { log.L(ctx).Errorf("Error loading pool info for transaction '%s' (%s) - ignoring: %v", pool.TX.ID, err, op.Input) return nil, nil } - // If we have successfully activated the pool - // Then set the pool published to true - // As it won't be in the initial payload - if activateOp != nil && activateOp.Status == core.OpStatusSucceeded { - stagedPool.Published = true - } - if err = addPoolDetailsFromPlugin(stagedPool, pool); err != nil { log.L(ctx).Errorf("Error processing pool for transaction '%s' (%s) - ignoring", pool.TX.ID, err) return nil, nil From 5d0db288baeb5e1a81972ba003308a2fa26ec89f Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 20 Nov 2024 17:04:19 +0000 Subject: [PATCH 5/8] update copyright Signed-off-by: Enrique Lacal --- internal/assets/token_pool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/assets/token_pool.go b/internal/assets/token_pool.go index 36c88d4fd..fcf7790d5 100644 --- a/internal/assets/token_pool.go +++ b/internal/assets/token_pool.go @@ -1,4 +1,4 @@ -// Copyright © 2023 Kaleido, Inc. +// Copyright © 2024 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // From 283aa7032cae06ca7863a25c249bc68a8c382d15 Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 20 Nov 2024 17:05:12 +0000 Subject: [PATCH 6/8] update dockerfile postgres version Signed-off-by: Enrique Lacal --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 412091271..be0a44314 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,7 @@ ARG UI_TAG ARG UI_RELEASE RUN apk add --update --no-cache \ sqlite=3.44.2-r0 \ - postgresql16-client=16.4-r0 \ + postgresql16-client-16.5-r0 \ curl=8.9.1-r1 \ jq=1.7.1-r0 WORKDIR /firefly From 7d7ae2fd40315886b04cbc872f7b74b1f527bf03 Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 20 Nov 2024 17:09:26 +0000 Subject: [PATCH 7/8] undo dockerfile change Signed-off-by: Enrique Lacal --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index be0a44314..412091271 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,7 @@ ARG UI_TAG ARG UI_RELEASE RUN apk add --update --no-cache \ sqlite=3.44.2-r0 \ - postgresql16-client-16.5-r0 \ + postgresql16-client=16.4-r0 \ curl=8.9.1-r1 \ jq=1.7.1-r0 WORKDIR /firefly From 290ea03e0b19e2fe0f17a1cd7546feb4548c66ab Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 20 Nov 2024 17:13:39 +0000 Subject: [PATCH 8/8] One more copyright missing Signed-off-by: Enrique Lacal --- internal/definitions/handler_tokenpool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/definitions/handler_tokenpool.go b/internal/definitions/handler_tokenpool.go index 8e2d38d38..a6a01fb79 100644 --- a/internal/definitions/handler_tokenpool.go +++ b/internal/definitions/handler_tokenpool.go @@ -1,4 +1,4 @@ -// Copyright © 2023 Kaleido, Inc. +// Copyright © 2024 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 //