You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2018/12/07 11:21:31 UTC
[camel-k] branch master updated: builder: wake up event loop when
the container image buils is done to seep up deployment time
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new 8fed404 builder: wake up event loop when the container image buils is done to seep up deployment time
8fed404 is described below
commit 8fed4047b388a5331bd83d9b318a053eaba17e95
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Fri Dec 7 10:54:55 2018 +0100
builder: wake up event loop when the container image buils is done to seep up deployment time
---
pkg/builder/builder_steps.go | 42 ++++++++++++++++++++++++++----
pkg/builder/kaniko/kaniko.go | 2 +-
pkg/builder/s2i/s2i.go | 2 +-
pkg/stub/action/context/build.go | 2 +-
pkg/stub/action/integration/build_image.go | 2 +-
pkg/trait/builder.go | 2 ++
6 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/pkg/builder/builder_steps.go b/pkg/builder/builder_steps.go
index a32502e..bc14032 100644
--- a/pkg/builder/builder_steps.go
+++ b/pkg/builder/builder_steps.go
@@ -364,9 +364,9 @@ func FindBestImage(images []PublishedImage, dependencies []string, artifacts []v
return bestImage, bestImageCommonLibs
}
-// Notify --
-func Notify(ctx *Context) error {
- c := v1alpha1.IntegrationContext{
+// NotifyIntegrationContext --
+func NotifyIntegrationContext(ctx *Context) error {
+ target := v1alpha1.IntegrationContext{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.IntegrationContextKind,
APIVersion: v1alpha1.SchemeGroupVersion.String(),
@@ -377,11 +377,43 @@ func Notify(ctx *Context) error {
},
}
- if err := sdk.Get(&c); err != nil {
+ if err := sdk.Get(&target); err != nil {
return err
}
- t := c.DeepCopy()
+ t := target.DeepCopy()
+ if t.Annotations == nil {
+ t.Annotations = make(map[string]string)
+ }
+
+ // Add a random ID to trigger update
+ t.Annotations["camel.apache.org/build.id"] = xid.New().String()
+
+ if err := sdk.Update(t); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// NotifyIntegration --
+func NotifyIntegration(ctx *Context) error {
+ target := v1alpha1.Integration{
+ TypeMeta: metav1.TypeMeta{
+ Kind: v1alpha1.IntegrationKind,
+ APIVersion: v1alpha1.SchemeGroupVersion.String(),
+ },
+ ObjectMeta: metav1.ObjectMeta{
+ Namespace: ctx.Namespace,
+ Name: ctx.Request.Meta.Name,
+ },
+ }
+
+ if err := sdk.Get(&target); err != nil {
+ return err
+ }
+
+ t := target.DeepCopy()
if t.Annotations == nil {
t.Annotations = make(map[string]string)
}
diff --git a/pkg/builder/kaniko/kaniko.go b/pkg/builder/kaniko/kaniko.go
index a9b4a0c..4b2d826 100644
--- a/pkg/builder/kaniko/kaniko.go
+++ b/pkg/builder/kaniko/kaniko.go
@@ -27,7 +27,7 @@ var DefaultSteps = []builder.Step{
builder.NewStep("build/compute-dependencies", builder.ProjectBuildPhase, builder.ComputeDependencies),
builder.NewStep("packager", builder.ApplicationPackagePhase, builder.StandardPackager),
builder.NewStep("publisher/kaniko", builder.ApplicationPublishPhase, Publisher),
- builder.NewStep("notify", builder.NotifyPhase, builder.Notify),
+ builder.NewStep("notify/context", builder.NotifyPhase, builder.NotifyIntegrationContext),
}
// BuildDir is the directory where to build artifacts (shared with the Kaniko pod)
diff --git a/pkg/builder/s2i/s2i.go b/pkg/builder/s2i/s2i.go
index 4d50797..df68f3f 100644
--- a/pkg/builder/s2i/s2i.go
+++ b/pkg/builder/s2i/s2i.go
@@ -25,5 +25,5 @@ var DefaultSteps = []builder.Step{
builder.NewStep("build/compute-dependencies", builder.ProjectBuildPhase, builder.ComputeDependencies),
builder.NewStep("packager/incremental", builder.ApplicationPackagePhase, builder.IncrementalPackager),
builder.NewStep("publisher/s2i", builder.ApplicationPublishPhase, Publisher),
- builder.NewStep("notify", builder.NotifyPhase, builder.Notify),
+ builder.NewStep("notify/context", builder.NotifyPhase, builder.NotifyIntegrationContext),
}
diff --git a/pkg/stub/action/context/build.go b/pkg/stub/action/context/build.go
index b3e9226..35901fe 100644
--- a/pkg/stub/action/context/build.go
+++ b/pkg/stub/action/context/build.go
@@ -79,7 +79,7 @@ func (action *buildAction) Handle(context *v1alpha1.IntegrationContext) error {
target := context.DeepCopy()
target.Status.Phase = v1alpha1.IntegrationContextPhaseError
- logrus.Info("Context ", target.Name, " transitioning to state ", target.Status.Phase)
+ logrus.Infof("Context %s transitioning to state %s, reason: %s", target.Name, target.Status.Phase, res.Error.Error())
// remove the build from cache
defer b.Purge(r)
diff --git a/pkg/stub/action/integration/build_image.go b/pkg/stub/action/integration/build_image.go
index a30e4bf..d205ebc 100644
--- a/pkg/stub/action/integration/build_image.go
+++ b/pkg/stub/action/integration/build_image.go
@@ -112,7 +112,7 @@ func (action *buildImageAction) Handle(integration *v1alpha1.Integration) error
target := integration.DeepCopy()
target.Status.Phase = v1alpha1.IntegrationPhaseError
- logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)
+ logrus.Infof("Integration %s transitioning to state %s, reason: %s", target.Name, target.Status.Phase, res.Error.Error())
// remove the build from cache
defer b.Purge(r)
diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go
index 84702cb..545067e 100644
--- a/pkg/trait/builder.go
+++ b/pkg/trait/builder.go
@@ -65,11 +65,13 @@ func (*builderTrait) apply(e *Environment) error {
e.Steps = []builder.Step{
builder.NewStep("packager", builder.ApplicationPackagePhase, builder.StandardPackager),
builder.NewStep("publisher/s2i", builder.ApplicationPublishPhase, s2i.Publisher),
+ builder.NewStep("notify/integration", builder.NotifyPhase, builder.NotifyIntegration),
}
} else if platform.SupportsKanikoPublishStrategy(e.Platform) {
e.Steps = []builder.Step{
builder.NewStep("packager", builder.ApplicationPackagePhase, builder.StandardPackager),
builder.NewStep("publisher/kaniko", builder.ApplicationPublishPhase, kaniko.Publisher),
+ builder.NewStep("notify/integration", builder.NotifyPhase, builder.NotifyIntegration),
}
}
}