zregvart commented on a change in pull request #2823:
URL: https://github.com/apache/camel-k/pull/2823#discussion_r765243801
##########
File path: pkg/install/kamelets.go
##########
@@ -50,7 +52,15 @@ const (
defaultKameletDir = "/kamelets/"
)
-var hasServerSideApply = true
+var (
+ log = logf.Log
+
+ hasServerSideApply atomic.Value
Review comment:
```suggestion
hasServerSideApply atomic.Value
hasServerSideApplyWrite sync.Mutex
```
##########
File path: pkg/install/kamelets.go
##########
@@ -121,13 +131,14 @@ func applyKamelet(ctx context.Context, c client.Client,
path string, namespace s
kamelet.GetLabels()[v1alpha1.KameletBundledLabel] = "true"
kamelet.GetLabels()[v1alpha1.KameletReadOnlyLabel] = "true"
- if hasServerSideApply {
+ if v := hasServerSideApply.Load(); v.(bool) {
Review comment:
```suggestion
if v := hasServerSideApply.Load(); v == nil || v.(bool) {
if v == nil {
hasServerSideApplyWrite.Lock()
defer hasServerSideApplyWrite.Unlock()
}
```
##########
File path: pkg/install/kamelets.go
##########
@@ -121,13 +131,14 @@ func applyKamelet(ctx context.Context, c client.Client,
path string, namespace s
kamelet.GetLabels()[v1alpha1.KameletBundledLabel] = "true"
kamelet.GetLabels()[v1alpha1.KameletReadOnlyLabel] = "true"
- if hasServerSideApply {
+ if v := hasServerSideApply.Load(); v.(bool) {
err := serverSideApply(ctx, c, kamelet)
switch {
case err == nil:
return nil
Review comment:
```suggestion
if v == nil {
hasServerSideApply.Store(true)
}
return nil
```
##########
File path: pkg/install/kamelets.go
##########
@@ -27,6 +27,7 @@ import (
"path"
"path/filepath"
"strings"
+ "sync/atomic"
Review comment:
```suggestion
"sync/atomic"
"sync"
```
##########
File path: pkg/install/kamelets.go
##########
@@ -50,7 +52,15 @@ const (
defaultKameletDir = "/kamelets/"
)
-var hasServerSideApply = true
+var (
+ log = logf.Log
+
+ hasServerSideApply atomic.Value
+)
+
+func init() {
+ hasServerSideApply.Store(true)
+}
Review comment:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]