This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 1a4099305346fc74f920cf5a865401b58e0618c3 Author: nferraro <ni.ferr...@gmail.com> AuthorDate: Tue Sep 18 17:38:19 2018 +0200 Speedup deploy when building a new context --- pkg/apis/camel/v1alpha1/types.go | 2 -- pkg/apis/camel/v1alpha1/types_support.go | 10 ++++++++++ pkg/stub/action/context/build.go | 33 +++++++++++++++++++++++++++++++- pkg/stub/action/integration/deploy.go | 3 +++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/pkg/apis/camel/v1alpha1/types.go b/pkg/apis/camel/v1alpha1/types.go index fd21328..90effe8 100644 --- a/pkg/apis/camel/v1alpha1/types.go +++ b/pkg/apis/camel/v1alpha1/types.go @@ -127,8 +127,6 @@ const ( // IntegrationContextPhaseBuilding -- IntegrationContextPhaseBuilding IntegrationContextPhase = "Building" - // IntegrationContextPhaseDeploying -- - IntegrationContextPhaseDeploying IntegrationContextPhase = "Deploying" // IntegrationContextPhaseReady -- IntegrationContextPhaseReady IntegrationContextPhase = "Ready" // IntegrationContextPhaseError -- diff --git a/pkg/apis/camel/v1alpha1/types_support.go b/pkg/apis/camel/v1alpha1/types_support.go index b202aa3..39eb11d 100644 --- a/pkg/apis/camel/v1alpha1/types_support.go +++ b/pkg/apis/camel/v1alpha1/types_support.go @@ -39,6 +39,16 @@ func (spec ConfigurationSpec) String() string { // // ********************************** +// NewIntegrationList -- +func NewIntegrationList() IntegrationList { + return IntegrationList{ + TypeMeta: metav1.TypeMeta{ + APIVersion: SchemeGroupVersion.String(), + Kind: IntegrationKind, + }, + } +} + // NewIntegrationContext -- func NewIntegrationContext(namespace string, name string) IntegrationContext { return IntegrationContext{ diff --git a/pkg/stub/action/context/build.go b/pkg/stub/action/context/build.go index ca9b44b..249cf71 100644 --- a/pkg/stub/action/context/build.go +++ b/pkg/stub/action/context/build.go @@ -19,6 +19,7 @@ package action import ( "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/operator-framework/operator-sdk/pkg/sdk" "github.com/sirupsen/logrus" @@ -29,6 +30,7 @@ import ( "github.com/apache/camel-k/pkg/build" ) +// NewIntegrationContextBuildAction creates a new build handling action for the context func NewIntegrationContextBuildAction(ctx context.Context, namespace string) IntegrationContextAction { return &integrationContextBuildAction{ buildManager: build.NewManager(ctx, namespace), @@ -68,8 +70,37 @@ func (action *integrationContextBuildAction) Handle(context *v1alpha1.Integratio target := context.DeepCopy() target.Status.Image = buildResult.Image target.Status.Phase = v1alpha1.IntegrationContextPhaseReady - return sdk.Update(target) + if err := sdk.Update(target); err != nil { + return err + } + if err := action.informIntegrations(target); err != nil { + return err + } } return nil } + +// informIntegrations triggers the processing of all integrations waiting for this context to be built +func (action *integrationContextBuildAction) informIntegrations(context *v1alpha1.IntegrationContext) error { + list := v1alpha1.NewIntegrationList() + err := sdk.List(context.Namespace, &list, sdk.WithListOptions(&metav1.ListOptions{})) + if err != nil { + return err + } + for _, integration := range list.Items { + if integration.Spec.Context != context.Name { + continue + } + + if integration.Annotations == nil { + integration.Annotations = make(map[string]string) + } + integration.Annotations["camel.apache.org/context.digest"] = context.Status.Digest + err = sdk.Update(&integration) + if err != nil { + return err + } + } + return nil +} diff --git a/pkg/stub/action/integration/deploy.go b/pkg/stub/action/integration/deploy.go index b8adb43..99545f6 100644 --- a/pkg/stub/action/integration/deploy.go +++ b/pkg/stub/action/integration/deploy.go @@ -151,6 +151,9 @@ func getDeploymentFor(ctx *v1alpha1.IntegrationContext, integration *v1alpha1.In // has been changed environment["CAMEL_K_DIGEST"] = integration.Status.Digest + // optimizations + environment["AB_JOLOKIA_OFF"] = "true" + labels := map[string]string{ "camel.apache.org/integration": integration.Name, }