You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2018/12/07 11:21:28 UTC

[GitHub] nicolaferraro closed pull request #269: builder: wake up event loop when the container image buils is done to seep up deployment time

nicolaferraro closed pull request #269: builder: wake up event loop when the container image buils is done to seep up deployment time
URL: https://github.com/apache/camel-k/pull/269
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pkg/builder/builder_steps.go b/pkg/builder/builder_steps.go
index 4a24e026..7c8939c3 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 a9b4a0c2..4b2d826c 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 4d507978..df68f3ff 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 b3e9226a..35901feb 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 a30e4bfe..d205ebc3 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 84702cb5..545067eb 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),
 			}
 		}
 	}


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services