You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/07/24 13:05:43 UTC
[GitHub] [camel-k] lburgazzoli opened a new pull request, #3480: fix: camel-k ignores changes to traits configured using annotations #3479
lburgazzoli opened a new pull request, #3480:
URL: https://github.com/apache/camel-k/pull/3480
<!-- Description -->
<!--
Enter your extended release note in the below block. If the PR requires
additional action from users switching to the new release, include the string
"action required". If no release note is required, write "NONE".
You can (optionally) mark this PR with labels "kind/bug" or "kind/feature" to make sure
the text is added to the right section of the release notes.
-->
**Release Note**
```release-note
NONE
```
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r929776637
##########
pkg/controller/integration/integration_controller.go:
##########
@@ -75,6 +77,109 @@ func newReconciler(mgr manager.Manager, c client.Client) reconcile.Reconciler {
)
}
+func integrationUpdateFunc(old *v1.Integration, it *v1.Integration) bool {
Review Comment:
the linter was complaining about complexity of the method so I created dedicated functions to make the method more readable.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] squakez commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
squakez commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r929759016
##########
pkg/controller/integration/integration_controller.go:
##########
@@ -75,6 +77,109 @@ func newReconciler(mgr manager.Manager, c client.Client) reconcile.Reconciler {
)
}
+func integrationUpdateFunc(old *v1.Integration, it *v1.Integration) bool {
Review Comment:
+1 for encapsulating these functions. However, I could not understand if there is any logic change in them or it was just the encapsulation which changed. Can you clarify?
##########
pkg/controller/integration/kits.go:
##########
@@ -82,6 +82,18 @@ func lookupKitsForIntegration(ctx context.Context, c ctrl.Reader, integration *v
return kits, nil
}
+// sameOrMatch returns whether the v1.IntegrationKit ios the one used by the v1.Integration or if it meets the
+// requirements of the v1.Integration.
+func sameOrMatch(kit *v1.IntegrationKit, integration *v1.Integration) (bool, error) {
+ if integration.Status.IntegrationKit != nil {
+ if integration.Status.IntegrationKit.Namespace == kit.Namespace && integration.Status.IntegrationKit.Name == kit.Name {
+ return true, nil
+ }
+ }
+
+ return integrationMatches(integration, kit)
Review Comment:
I've just fixed another possibly related issue here #3487. In that case it was failing because the `match` always returned false when an IntegrationKit was on error. Not sure if there is any check in the `integrationMatches` that is influencing the failure here, and if it makes sense to revisit it. I'd expect the `integrationMatches` to take care of those new added conditions as well.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
astefanutti commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r938663146
##########
pkg/trait/util.go:
##########
@@ -388,34 +388,43 @@ func KameletBindingsHaveSameTraits(i1 *v1alpha1.KameletBinding, i2 *v1alpha1.Kam
}
// IntegrationAndBindingSameTraits return if traits are the same.
+// The comparison happen for a subset of traits as during the trait processing, some traits may be
Review Comment:
nit: happen -> happens or "is done for the subset of traits defines on the binding"
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r930674351
##########
pkg/controller/integration/kits.go:
##########
@@ -82,6 +82,18 @@ func lookupKitsForIntegration(ctx context.Context, c ctrl.Reader, integration *v
return kits, nil
}
+// sameOrMatch returns whether the v1.IntegrationKit ios the one used by the v1.Integration or if it meets the
+// requirements of the v1.Integration.
+func sameOrMatch(kit *v1.IntegrationKit, integration *v1.Integration) (bool, error) {
Review Comment:
agree, see the other comments
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r929782933
##########
pkg/controller/integration/kits.go:
##########
@@ -82,6 +82,18 @@ func lookupKitsForIntegration(ctx context.Context, c ctrl.Reader, integration *v
return kits, nil
}
+// sameOrMatch returns whether the v1.IntegrationKit ios the one used by the v1.Integration or if it meets the
+// requirements of the v1.Integration.
+func sameOrMatch(kit *v1.IntegrationKit, integration *v1.Integration) (bool, error) {
+ if integration.Status.IntegrationKit != nil {
+ if integration.Status.IntegrationKit.Namespace == kit.Namespace && integration.Status.IntegrationKit.Name == kit.Name {
+ return true, nil
+ }
+ }
+
+ return integrationMatches(integration, kit)
Review Comment:
For what I understood, in the case the status of a kit should not influence the trigger as in fact every change to a kit should result in a reconcile being triggered. Then the integration controller should decide what to do so I guess your changes are improving also this case.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
astefanutti commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r936453260
##########
e2e/global/common/kamelet_binding_with_image_test.go:
##########
@@ -0,0 +1,120 @@
+//go:build integration
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package common
+
+import (
+ "github.com/onsi/gomega/gstruct"
+ "testing"
+
+ . "github.com/apache/camel-k/e2e/support"
+ . "github.com/onsi/gomega"
+
+ corev1 "k8s.io/api/core/v1"
+
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+)
+
+func TestBindingWithImage(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ operatorID := "camel-k-binding-image"
+ bindingID := "with-image-binding"
+
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+
+ from := corev1.ObjectReference{
+ Kind: "Kamelet",
+ Name: "my-own-timer-source",
+ APIVersion: v1alpha1.SchemeGroupVersion.String(),
+ }
+
+ to := corev1.ObjectReference{
+ Kind: "Kamelet",
+ Name: "my-own-log-sink",
+ APIVersion: v1alpha1.SchemeGroupVersion.String(),
+ }
+
+ emptyMap := map[string]string{}
+
+ annotations1 := map[string]string{
+ "trait.camel.apache.org/container.image": "docker.io/jmalloc/echo-server:0.3.2",
+ "trait.camel.apache.org/jvm.enabled": "false",
+ "trait.camel.apache.org/kamelets.enabled": "false",
+ "trait.camel.apache.org/dependencies.enabled": "false",
+ "test": "1",
+ }
+ annotations2 := map[string]string{
+ "trait.camel.apache.org/container.image": "docker.io/jmalloc/echo-server:0.3.3",
+ "trait.camel.apache.org/jvm.enabled": "false",
+ "trait.camel.apache.org/kamelets.enabled": "false",
+ "trait.camel.apache.org/dependencies.enabled": "false",
+ "test": "2",
+ }
+
+ t.Run("run with initial image", func(t *testing.T) {
+ expectedImage := annotations1["trait.camel.apache.org/container.image"]
+
+ RegisterTestingT(t)
+
+ Expect(BindKameletTo(ns, bindingID, annotations1, from, to, emptyMap, emptyMap)()).
+ To(Succeed())
+ Eventually(IntegrationGeneration(ns, bindingID)).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ Eventually(IntegrationAnnotations(ns, bindingID)).
+ Should(HaveKeyWithValue("test", "1"))
+ Eventually(IntegrationAnnotations(ns, bindingID)).
+ Should(HaveKeyWithValue("trait.camel.apache.org/container.image", expectedImage))
+ Eventually(IntegrationStatusImage(ns, bindingID)).
+ Should(Equal(expectedImage))
+
+ Eventually(IntegrationPodPhase(ns, bindingID), TestTimeoutLong).
+ Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPodImage(ns, bindingID)).
+ Should(Equal(expectedImage))
+ })
+
+ t.Run("run with new image", func(t *testing.T) {
+ expectedImage := annotations2["trait.camel.apache.org/container.image"]
+
+ RegisterTestingT(t)
+
+ Expect(BindKameletTo(ns, bindingID, annotations2, from, to, emptyMap, emptyMap)()).
+ To(Succeed())
+ Eventually(IntegrationGeneration(ns, bindingID)).
+ Should(gstruct.PointTo(BeNumerically("==", 1)))
+ Eventually(IntegrationAnnotations(ns, bindingID)).
Review Comment:
I'd suggest to create a _transform_ function, e.g.:
```go
func Annotations(object metav1.Object) map[string]string {
return object.GetAnnotations()
}
```
So it can be re-used for any object, and that can be used as:
```go
Eventually(Integration(ns, bindingID)).Should(WithTransform(Annotations, HaveKeyWithValue("test", "2")))
```
That would ultimately give:
```go
Eventually(Integration(ns, bindingID)).Should(WithTransform(Annotations, And(
HaveKeyWithValue("test", "2"))),
HaveKeyWithValue("trait.camel.apache.org/container.image", expectedImage)),
)
```
##########
pkg/controller/integration/integration_controller.go:
##########
@@ -75,6 +77,115 @@ func newReconciler(mgr manager.Manager, c client.Client) reconcile.Reconciler {
)
}
+func integrationUpdateFunc(old *v1.Integration, it *v1.Integration) bool {
+ // Observe the time to first readiness metric
+ previous := old.Status.GetCondition(v1.IntegrationConditionReady)
+ if next := it.Status.GetCondition(v1.IntegrationConditionReady); (previous == nil || previous.Status != corev1.ConditionTrue && (previous.FirstTruthyTime == nil || previous.FirstTruthyTime.IsZero())) &&
+ next != nil && next.Status == corev1.ConditionTrue && next.FirstTruthyTime != nil && !next.FirstTruthyTime.IsZero() &&
+ it.Status.InitializationTimestamp != nil {
+ duration := next.FirstTruthyTime.Time.Sub(it.Status.InitializationTimestamp.Time)
+ Log.WithValues("request-namespace", it.Namespace, "request-name", it.Name, "ready-after", duration.Seconds()).
+ ForIntegration(it).Infof("First readiness after %s", duration)
+ timeToFirstReadiness.Observe(duration.Seconds())
+ }
+
+ // If traits have changed, the reconciliation loop must kick in as
+ // traits may have impact
+ sameTraits, err := trait.IntegrationsHaveSameTraits(old, it)
+ if err != nil {
+ Log.ForIntegration(it).Error(
+ err,
+ "unable to determine if old and new resource have the same traits")
+ }
+ if !sameTraits {
+ return true
+ }
+
+ // Ignore updates to the integration status in which case metadata.Generation does not change,
+ // or except when the integration phase changes as it's used to transition from one phase
+ // to another.
+ return old.Generation != it.Generation ||
+ old.Status.Phase != it.Status.Phase
+}
+
+func integrationKitEnqueueRequestsFromMapFunc(c client.Client, kit *v1.IntegrationKit) []reconcile.Request {
+ var requests []reconcile.Request
+ if kit.Status.Phase != v1.IntegrationKitPhaseReady && kit.Status.Phase != v1.IntegrationKitPhaseError {
+ return requests
+ }
+
+ list := &v1.IntegrationList{}
+ // Do global search in case of global operator (it may be using a global platform)
+ var opts []ctrl.ListOption
+ if !platform.IsCurrentOperatorGlobal() {
+ opts = append(opts, ctrl.InNamespace(kit.Namespace))
+ }
+ if err := c.List(context.Background(), list, opts...); err != nil {
+ log.Error(err, "Failed to retrieve integration list")
+ return requests
+ }
+
+ for i := range list.Items {
+ integration := &list.Items[i]
+ log.Debug("Integration Controller: Assessing integration", "integration", integration.Name, "namespace", integration.Namespace)
Review Comment:
Probably not introduced by this PR, but seems better to re-used the scoped logger, e.g. `Log.Debug("Filtering integration from kit changes", ...)`.
##########
pkg/controller/integration/integration_controller.go:
##########
@@ -75,6 +77,115 @@ func newReconciler(mgr manager.Manager, c client.Client) reconcile.Reconciler {
)
}
+func integrationUpdateFunc(old *v1.Integration, it *v1.Integration) bool {
+ // Observe the time to first readiness metric
+ previous := old.Status.GetCondition(v1.IntegrationConditionReady)
+ if next := it.Status.GetCondition(v1.IntegrationConditionReady); (previous == nil || previous.Status != corev1.ConditionTrue && (previous.FirstTruthyTime == nil || previous.FirstTruthyTime.IsZero())) &&
+ next != nil && next.Status == corev1.ConditionTrue && next.FirstTruthyTime != nil && !next.FirstTruthyTime.IsZero() &&
+ it.Status.InitializationTimestamp != nil {
+ duration := next.FirstTruthyTime.Time.Sub(it.Status.InitializationTimestamp.Time)
+ Log.WithValues("request-namespace", it.Namespace, "request-name", it.Name, "ready-after", duration.Seconds()).
+ ForIntegration(it).Infof("First readiness after %s", duration)
+ timeToFirstReadiness.Observe(duration.Seconds())
+ }
+
+ // If traits have changed, the reconciliation loop must kick in as
+ // traits may have impact
+ sameTraits, err := trait.IntegrationsHaveSameTraits(old, it)
+ if err != nil {
+ Log.ForIntegration(it).Error(
+ err,
+ "unable to determine if old and new resource have the same traits")
+ }
+ if !sameTraits {
+ return true
+ }
+
+ // Ignore updates to the integration status in which case metadata.Generation does not change,
+ // or except when the integration phase changes as it's used to transition from one phase
+ // to another.
+ return old.Generation != it.Generation ||
+ old.Status.Phase != it.Status.Phase
+}
+
+func integrationKitEnqueueRequestsFromMapFunc(c client.Client, kit *v1.IntegrationKit) []reconcile.Request {
+ var requests []reconcile.Request
+ if kit.Status.Phase != v1.IntegrationKitPhaseReady && kit.Status.Phase != v1.IntegrationKitPhaseError {
+ return requests
+ }
+
+ list := &v1.IntegrationList{}
+ // Do global search in case of global operator (it may be using a global platform)
+ var opts []ctrl.ListOption
+ if !platform.IsCurrentOperatorGlobal() {
+ opts = append(opts, ctrl.InNamespace(kit.Namespace))
+ }
+ if err := c.List(context.Background(), list, opts...); err != nil {
+ log.Error(err, "Failed to retrieve integration list")
+ return requests
+ }
+
+ for i := range list.Items {
+ integration := &list.Items[i]
+ log.Debug("Integration Controller: Assessing integration", "integration", integration.Name, "namespace", integration.Namespace)
+
+ match, err := sameOrMatch(kit, integration)
+ if err != nil {
+ log.Errorf(err, "Error matching integration %q with kit %q", integration.Name, kit.Name)
Review Comment:
Maybe use `Log.ForIntegration(it).Error(...` for consistency.
##########
pkg/controller/kameletbinding/monitor.go:
##########
@@ -76,14 +77,25 @@ func (action *monitorAction) Handle(ctx context.Context, kameletbinding *v1alpha
operatorIDChanged := v1.GetOperatorIDAnnotation(kameletbinding) != "" &&
(v1.GetOperatorIDAnnotation(kameletbinding) != v1.GetOperatorIDAnnotation(&it))
+ sameTraits, err := trait.IntegrationAndBindingSameTraits(&it, kameletbinding)
+ if err != nil {
+ return nil, err
+ }
+
// Check if the integration needs to be changed
expected, err := CreateIntegrationFor(ctx, action.client, kameletbinding)
if err != nil {
return nil, err
}
- if !equality.Semantic.DeepDerivative(expected.Spec, it.Spec) || operatorIDChanged {
- action.L.Info("Monitor: KameletBinding needs a rebuild")
+ semanticEquality := equality.Semantic.DeepDerivative(expected.Spec, it.Spec)
+
+ if !semanticEquality || operatorIDChanged || !sameTraits {
+ action.L.Info(
+ "Monitor: KameletBinding needs a rebuild",
Review Comment:
`Monitor: KameletBinding needs a rebuild` -> `KameletBinding needs a rebuild`
##########
pkg/controller/kameletbinding/monitor.go:
##########
@@ -76,14 +77,25 @@ func (action *monitorAction) Handle(ctx context.Context, kameletbinding *v1alpha
operatorIDChanged := v1.GetOperatorIDAnnotation(kameletbinding) != "" &&
(v1.GetOperatorIDAnnotation(kameletbinding) != v1.GetOperatorIDAnnotation(&it))
+ sameTraits, err := trait.IntegrationAndBindingSameTraits(&it, kameletbinding)
+ if err != nil {
+ return nil, err
+ }
+
// Check if the integration needs to be changed
expected, err := CreateIntegrationFor(ctx, action.client, kameletbinding)
if err != nil {
return nil, err
}
- if !equality.Semantic.DeepDerivative(expected.Spec, it.Spec) || operatorIDChanged {
- action.L.Info("Monitor: KameletBinding needs a rebuild")
+ semanticEquality := equality.Semantic.DeepDerivative(expected.Spec, it.Spec)
+
+ if !semanticEquality || operatorIDChanged || !sameTraits {
+ action.L.Info(
+ "Monitor: KameletBinding needs a rebuild",
+ "semantic-equality", !semanticEquality,
+ "operatorid-changed", operatorIDChanged,
+ "traites-changed", !sameTraits)
Review Comment:
`traites-changed` -> `traits-changed`
##########
e2e/support/test_support.go:
##########
@@ -545,6 +545,26 @@ func IntegrationSpecReplicas(ns string, name string) func() *int32 {
}
}
+func IntegrationGeneration(ns string, name string) func() *int64 {
+ return func() *int64 {
+ it := Integration(ns, name)()
+ if it == nil {
+ return nil
+ }
+ return &it.Generation
+ }
+}
+
+func IntegrationStatusObserverGeneration(ns string, name string) func() *int64 {
Review Comment:
nit: `IntegrationStatusObserverGeneration` -> `IntegrationStatusObservedGeneration` or even `IntegrationObservedGeneration` as status can be made implicit.
##########
pkg/trait/util.go:
##########
@@ -29,17 +29,36 @@ import (
user "github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"github.com/scylladb/go-set/strset"
-
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/metadata"
"github.com/apache/camel-k/pkg/util"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/property"
)
+type Unstructured map[string]map[string]interface{}
Review Comment:
I'd suggest not to used `Unstructured` to avoid confusion with the eponymous type from k8s, maybe `Traits` or `TraitOptions`.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#issuecomment-1201056109
@tadayosi @christophd I see knative test failing but I'm unsure if they are related to this change or not. I may need some help to troubleshoot the failure
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
astefanutti commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r936504046
##########
pkg/trait/util.go:
##########
@@ -29,17 +29,36 @@ import (
user "github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"github.com/scylladb/go-set/strset"
-
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/metadata"
"github.com/apache/camel-k/pkg/util"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/property"
)
+type Unstructured map[string]map[string]interface{}
Review Comment:
Right, `Options` came also to my mind, so that sounds perfect to me :)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] tadayosi commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
tadayosi commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r930567487
##########
pkg/controller/integration/kits.go:
##########
@@ -82,6 +82,18 @@ func lookupKitsForIntegration(ctx context.Context, c ctrl.Reader, integration *v
return kits, nil
}
+// sameOrMatch returns whether the v1.IntegrationKit ios the one used by the v1.Integration or if it meets the
Review Comment:
typo: `ios` -> `is`
##########
pkg/controller/integration/kits.go:
##########
@@ -82,6 +82,18 @@ func lookupKitsForIntegration(ctx context.Context, c ctrl.Reader, integration *v
return kits, nil
}
+// sameOrMatch returns whether the v1.IntegrationKit ios the one used by the v1.Integration or if it meets the
+// requirements of the v1.Integration.
+func sameOrMatch(kit *v1.IntegrationKit, integration *v1.Integration) (bool, error) {
Review Comment:
I think this func is a necessary one to have, but also wonder if `integrationMatches()` should be aware of the traits in annotations as well. Currently `integrationMatches()` only compares `it.spec.traits` with `kit.spec.traits` but shouldn't it really compare the combination of annotations and spec.traits?
##########
pkg/trait/util.go:
##########
@@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask {
}
return nil
}
+
+// Equals return if traits set using annotations have changed.
+func Equals(oldObject metav1.Object, newObject metav1.Object) bool {
+ if len(oldObject.GetAnnotations()) != len(newObject.GetAnnotations()) {
+ return false
+ }
+
+ oldTraits := make(map[string]string)
+ newTraits := make(map[string]string)
+
+ for k, v := range oldObject.GetAnnotations() {
+ if strings.HasPrefix(k, "trait.camel.apache.org/") {
Review Comment:
we can use `camelv1.TraitAnnotationPrefix` here.
##########
pkg/trait/util.go:
##########
@@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask {
}
return nil
}
+
+// Equals return if traits set using annotations have changed.
+func Equals(oldObject metav1.Object, newObject metav1.Object) bool {
+ if len(oldObject.GetAnnotations()) != len(newObject.GetAnnotations()) {
+ return false
+ }
+
+ oldTraits := make(map[string]string)
+ newTraits := make(map[string]string)
+
+ for k, v := range oldObject.GetAnnotations() {
+ if strings.HasPrefix(k, "trait.camel.apache.org/") {
+ oldTraits[k] = v
+ }
+ }
+ for k, v := range newObject.GetAnnotations() {
+ if strings.HasPrefix(k, "trait.camel.apache.org/") {
Review Comment:
we can use `camelv1.TraitAnnotationPrefix` here.
##########
pkg/trait/util.go:
##########
@@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask {
}
return nil
}
+
+// Equals return if traits set using annotations have changed.
+func Equals(oldObject metav1.Object, newObject metav1.Object) bool {
Review Comment:
I first saw the function name and misunderstood it as comparing both annotations and spec.traits. It's only when I stared at the arg types that I understood the correct intent.
Apart from the function name, is it not needed to actually compare the traits under specs as well for where the func is invoked? Are changes to traits under spec handled in a different mechanics?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] tadayosi commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
tadayosi commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r930583574
##########
pkg/controller/integration/kits.go:
##########
@@ -82,6 +82,18 @@ func lookupKitsForIntegration(ctx context.Context, c ctrl.Reader, integration *v
return kits, nil
}
+// sameOrMatch returns whether the v1.IntegrationKit ios the one used by the v1.Integration or if it meets the
+// requirements of the v1.Integration.
+func sameOrMatch(kit *v1.IntegrationKit, integration *v1.Integration) (bool, error) {
Review Comment:
I think this func is a necessary one to have, but also wonder if `integrationMatches()` should be aware of the traits in annotations as well. Currently `integrationMatches()` only compares `it.spec.traits` with `kit.spec.traits` but shouldn't it really compare them using the combination of annotations and spec.traits?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r936503003
##########
pkg/trait/util.go:
##########
@@ -29,17 +29,36 @@ import (
user "github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"github.com/scylladb/go-set/strset"
-
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/metadata"
"github.com/apache/camel-k/pkg/util"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/property"
)
+type Unstructured map[string]map[string]interface{}
Review Comment:
what about just Options ? just because GoLand keep telling me that Trait is implicit by the package name :)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
astefanutti commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r938663146
##########
pkg/trait/util.go:
##########
@@ -388,34 +388,43 @@ func KameletBindingsHaveSameTraits(i1 *v1alpha1.KameletBinding, i2 *v1alpha1.Kam
}
// IntegrationAndBindingSameTraits return if traits are the same.
+// The comparison happen for a subset of traits as during the trait processing, some traits may be
Review Comment:
nit: happen -> happens or "is done for the subset of traits defined on the binding"
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r930673914
##########
pkg/trait/util.go:
##########
@@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask {
}
return nil
}
+
+// Equals return if traits set using annotations have changed.
+func Equals(oldObject metav1.Object, newObject metav1.Object) bool {
Review Comment:
Yes I think the current solution is suboptimal but with my outdated knowledge of the codebase I tried to be conservative.
I think the proper solution would be to always reason on a synthetic view of the trait as in fact we may have cases where two resources have the same traits but defined in a different way.
I'll try to work on something
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r931564222
##########
pkg/trait/util.go:
##########
@@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask {
}
return nil
}
+
+// Equals return if traits set using annotations have changed.
+func Equals(oldObject metav1.Object, newObject metav1.Object) bool {
Review Comment:
pushed a new version of the PR with better support for traits
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] tadayosi commented on pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
tadayosi commented on PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#issuecomment-1201188656
@lburgazzoli We've done a lot of efforts to stabilise the e2e tests and now they are reilable enough to keep all green before merging a pull req. The fact that `knative/yaks` fails 3 times out of 3 suggests it's likely some changes in this fix have caused it.
I'm not knowledgeable about the yaks test either but I'd start from replicating the automated test manually and see what's causing this error:
> error: timed out waiting for the condition on kameletbindings/timer-source-binding-display
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli merged pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli merged PR #3480:
URL: https://github.com/apache/camel-k/pull/3480
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#issuecomment-1195217535
@squakez @tadayosi @christophd can you ahve a look ? btw I'm not sure if that's the proper way to solve the issue but
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] tadayosi commented on a diff in pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
tadayosi commented on code in PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#discussion_r930581435
##########
pkg/trait/util.go:
##########
@@ -320,3 +321,26 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask {
}
return nil
}
+
+// Equals return if traits set using annotations have changed.
+func Equals(oldObject metav1.Object, newObject metav1.Object) bool {
Review Comment:
I first saw the function name and misunderstood it as comparing both annotations and spec.traits. It's only when I stared at the arg types that I understood the correct intent.
Apart from the function name, is it not needed to actually compare the traits under specs as well for where the func is invoked? Is it not necessary because changes to traits under spec are handled in a different mechanics?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#issuecomment-1203846381
> Few comments, otherwise LGTM 👍🏼.
Suggestions have been implemented, I guess the overall logging stuff may need to be improved
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on pull request #3480: fix: camel-k ignores changes to traits configured using annotations
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on PR #3480:
URL: https://github.com/apache/camel-k/pull/3480#issuecomment-1204497138
@christophd I may need some help trying to understand what the failure is about
kamelet-binding-http (kamelet-binding-http): Failure caused by InitializationError - Failed to run installation: exit status 1
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org