nicolaferraro commented on a change in pull request #76: Context handling
improvement
URL: https://github.com/apache/camel-k/pull/76#discussion_r217885415
##########
File path: pkg/stub/action/integration/build.go
##########
@@ -53,44 +50,65 @@ func (action *buildAction) Handle(integration
*v1alpha1.Integration) error {
return err
}
-
if ctx != nil {
+ if ctx.Labels["camel.apache.org/context.type"] == "platform" {
+ // This is a platform context and as it is auto
generated it may get
+ // out of sync if the integration that has generated
it, has been
+ // amended to add/remove dependencies
+
+ //TODO: this is a very simple check, we may need to
provide a deps comparison strategy
+ if !StringSliceContains(ctx.Spec.Dependencies,
integration.Spec.Dependencies) {
+ // We need to re-generate a context or search
for a new one that
+ // satisfies integrations needs so let's remove
the association
+ // with a context
+ target := integration.DeepCopy()
+ target.Spec.Context = ""
+ return sdk.Update(target)
+ }
+ }
+
if ctx.Status.Phase == v1alpha1.IntegrationContextPhaseReady {
target := integration.DeepCopy()
target.Status.Image = ctx.Status.Image
+ target.Spec.Context = ctx.Name
target.Status.Phase = v1alpha1.IntegrationPhaseDeploying
return sdk.Update(target)
}
+ if integration.Spec.Context == "" {
+ // We need to set the context
+ target := integration.DeepCopy()
+ target.Spec.Context = ctx.Name
+ return sdk.Update(target)
+ }
+
return nil
}
- buildIdentifier := api.BuildIdentifier{
- Name: integration.Name,
- Qualifier: integration.Status.Digest,
+ platformCtxName := fmt.Sprintf("ctx-%s-%s", integration.Name,
integration.ResourceVersion)
Review comment:
I think platform contexts don't need to be named after integrations. They
can be shared among integrations and "must" be immutable, i.e. when a
integration change dependencies, a new context should be created, leaving the
old one to a "garbage collector". Wdyt?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services