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 2020/02/14 08:22:28 UTC

[GitHub] [camel-k] nicolaferraro opened a new pull request #1274: Refactoring traits to allow addons and add master trait (as addon)

nicolaferraro opened a new pull request #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274
 
 
   <!-- Description -->
   
   Fix #1234
   Needs https://github.com/apache/camel-k-runtime/pull/242
   
   This removes the trait static lists and allow to dynamically define traits also in other packages. This added the possibility to define an "addons" package. Currently addons are always loaded, but technically they can be easily disabled at both build time or runtime.
   
   The idea is, for the future, to include addons for other external projects, so that Camel K can leverage them to auto-configure the integrations.
   Examples of traits that are best placed in the addon package are:
   - Camel non-core features: like Master, Cron
   - Knative
   - Keda (#1107)
   - Connectors (idea still maturing, making sure that Camel K can configure connections e.g. to a Kafka [Strimzi] instance, automatically injecting certificates and authentication credentials in the integration)
   
   About the **master component**: it's using the `camel-k-runtime-master` module, which embeds `camel-kubernetes` to do leader election.
   
   It's enabled by default when someone uses a route like:
   
   ```
   from("master:listener:telegram:bots")...
   ```
   
   So that that route is started only once, no matter how many `replicas` you set in the integration (works also with auto-scaling integrations).
   
   By default, each integration has its own lock domain (i.e. configmap), but configuration can be tweaked to let two different integrations share the same lock if needed.
   
   
   <!--
   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
   Camel master component is automatically configured to do leader election using Kubernetes resources
   ```
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] lburgazzoli commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#discussion_r379312725
 
 

 ##########
 File path: pkg/trait/trait_types.go
 ##########
 @@ -95,40 +95,49 @@ type Trait interface {
 
 	// RequiresIntegrationPlatform indicates that the trait cannot work without an integration platform set
 	RequiresIntegrationPlatform() bool
+
+	// IsAllowedInProfile tels if the trait supports the given profile
+	IsAllowedInProfile(v1.TraitProfile) bool
+
+	// Order is the order in which the trait should be executed in the normal flow
+	Order() int
 }
 
 /* Base trait */
 
-func newBaseTrait(id string) BaseTrait {
+// NewBaseTrait --
+func NewBaseTrait(id string, order int) BaseTrait {
 
 Review comment:
   Wonder if we should have some constants that could help choosing the right value for the `order` field

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro commented on issue #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
nicolaferraro commented on issue #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#issuecomment-589568425
 
 
   Let's merge this.. GH actions are flacky today..

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] heiko-braun commented on issue #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
heiko-braun commented on issue #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#issuecomment-586151393
 
 
   I am curious, you are talking about `leader election`. Can you elaborate on that? How does it related to the addons idea? 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
nicolaferraro commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#discussion_r379808315
 
 

 ##########
 File path: pkg/trait/trait_types.go
 ##########
 @@ -95,40 +95,49 @@ type Trait interface {
 
 	// RequiresIntegrationPlatform indicates that the trait cannot work without an integration platform set
 	RequiresIntegrationPlatform() bool
+
+	// IsAllowedInProfile tels if the trait supports the given profile
+	IsAllowedInProfile(v1.TraitProfile) bool
+
+	// Order is the order in which the trait should be executed in the normal flow
+	Order() int
 }
 
 /* Base trait */
 
-func newBaseTrait(id string) BaseTrait {
+// NewBaseTrait --
+func NewBaseTrait(id string, order int) BaseTrait {
 
 Review comment:
   I've opted for defining some relevant constants that addons may need (I've though to the cases mentioned above), but still use numbers for the core. Have a look.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro commented on issue #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
nicolaferraro commented on issue #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#issuecomment-586154069
 
 
   > I am curious, you are talking about `leader election`. Can you elaborate on that? How does it related to the addons idea?
   
   Not directly related. There was the need to move some logic out of the core, and it was easier for me to do this kind of refactoring it while developing a new trait (master).
   
   The leader election is part of the camel master component. The why/how is explained here: https://www.nicolaferraro.me/2017/10/17/creating-clustered-singleton-services-on-kubernetes/
   
   That example was for spring-boot and required some configuration to work. In Camel K now it works out-of-the-box (just use a `master:...` endpoint).

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro merged pull request #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
nicolaferraro merged pull request #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro edited a comment on issue #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
nicolaferraro edited a comment on issue #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#issuecomment-586154069
 
 
   > I am curious, you are talking about `leader election`. Can you elaborate on that? How does it related to the addons idea?
   
   Not directly related. There was the need to move some logic out of the core, and it was easier for me to do this kind of refactoring while developing a new trait (master).
   
   The leader election is part of the camel master component. The why/how is explained here: https://www.nicolaferraro.me/2017/10/17/creating-clustered-singleton-services-on-kubernetes/
   
   That example was for spring-boot and required some configuration to work. In Camel K now it works out-of-the-box (just use a `master:...` endpoint).

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
nicolaferraro commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#discussion_r379315244
 
 

 ##########
 File path: pkg/trait/trait_types.go
 ##########
 @@ -95,40 +95,49 @@ type Trait interface {
 
 	// RequiresIntegrationPlatform indicates that the trait cannot work without an integration platform set
 	RequiresIntegrationPlatform() bool
+
+	// IsAllowedInProfile tels if the trait supports the given profile
+	IsAllowedInProfile(v1.TraitProfile) bool
+
+	// Order is the order in which the trait should be executed in the normal flow
+	Order() int
 }
 
 /* Base trait */
 
-func newBaseTrait(id string) BaseTrait {
+// NewBaseTrait --
+func NewBaseTrait(id string, order int) BaseTrait {
 
 Review comment:
   I was thinking the same, but couldn't find a good strategy since we have so many 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] lburgazzoli commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#discussion_r379820706
 
 

 ##########
 File path: pkg/trait/trait_types.go
 ##########
 @@ -95,40 +95,49 @@ type Trait interface {
 
 	// RequiresIntegrationPlatform indicates that the trait cannot work without an integration platform set
 	RequiresIntegrationPlatform() bool
+
+	// IsAllowedInProfile tels if the trait supports the given profile
+	IsAllowedInProfile(v1.TraitProfile) bool
+
+	// Order is the order in which the trait should be executed in the normal flow
+	Order() int
 }
 
 /* Base trait */
 
-func newBaseTrait(id string) BaseTrait {
+// NewBaseTrait --
+func NewBaseTrait(id string, order int) BaseTrait {
 
 Review comment:
   LGTM, so as future step we could think to generalize this pattern as is exactly the same we are using for the builder so we should probably come up with a sort of a finite step machine 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] lburgazzoli commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)

Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on a change in pull request #1274: Refactoring traits to allow addons and add master trait (as addon)
URL: https://github.com/apache/camel-k/pull/1274#discussion_r379820706
 
 

 ##########
 File path: pkg/trait/trait_types.go
 ##########
 @@ -95,40 +95,49 @@ type Trait interface {
 
 	// RequiresIntegrationPlatform indicates that the trait cannot work without an integration platform set
 	RequiresIntegrationPlatform() bool
+
+	// IsAllowedInProfile tels if the trait supports the given profile
+	IsAllowedInProfile(v1.TraitProfile) bool
+
+	// Order is the order in which the trait should be executed in the normal flow
+	Order() int
 }
 
 /* Base trait */
 
-func newBaseTrait(id string) BaseTrait {
+// NewBaseTrait --
+func NewBaseTrait(id string, order int) BaseTrait {
 
 Review comment:
   LGTM, so as future step we could think to generalize this pattern as is exactly the same we are using for the builder so we should probably come up with a sort of a reusable finite step machine framework

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services