You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2022/04/18 09:18:07 UTC

[camel-k] 04/12: fix(#3063): Avoids reassigning sync.Once

This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit e1a8388f3f438ff7c7b3d2469f0996bcd0b8e811
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Thu Mar 3 21:24:31 2022 +0000

    fix(#3063): Avoids reassigning sync.Once
    
    * Reassigning sync.Once causes unlocking of unlocked mutex error and
      recommended should not be done inside the function called by the
      sync.Once
    
    * Instead log the error and bail out as something is wrong with the
      kamelets and needs to be fixed.
    
    * Upgrades the kamelet branch to load compatible kamelets, ie. those that
      define with spec.template rather than spec.flow
---
 pkg/install/kamelets.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pkg/install/kamelets.go b/pkg/install/kamelets.go
index 6bd15f4f5..53cf29989 100644
--- a/pkg/install/kamelets.go
+++ b/pkg/install/kamelets.go
@@ -31,8 +31,8 @@ import (
 	"sync"
 	"sync/atomic"
 
+	gerrors "github.com/pkg/errors"
 	"golang.org/x/sync/errgroup"
-
 	k8serrors "k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/runtime"
 	"k8s.io/apimachinery/pkg/types"
@@ -103,7 +103,9 @@ func KameletCatalog(ctx context.Context, c client.Client, namespace string) erro
 						hasServerSideApply.Store(false)
 						err = nil
 					} else {
-						tryServerSideApply = sync.Once{}
+						// Unexpected error occurred
+						err = gerrors.Wrap(err, "Unexpected error occurred whilst validating kamelet")
+						log.Error(err, "Error occurred whilst loading kamelets")
 					}
 				} else {
 					hasServerSideApply.Store(true)