You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2019/10/03 12:30:53 UTC

[camel-k] 02/02: fix #915: set right permissions on kaniko workspace

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 91a5a5a98df6506c83fba2a4faae5fac02b0513d
Author: nferraro <ni...@gmail.com>
AuthorDate: Thu Oct 3 11:27:10 2019 +0200

    fix #915: set right permissions on kaniko workspace
---
 pkg/controller/build/schedule_pod.go               | 15 +++++++++++++++
 pkg/controller/integrationplatform/kaniko_cache.go |  7 ++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/pkg/controller/build/schedule_pod.go b/pkg/controller/build/schedule_pod.go
index 282f91c..b3b3dcd 100644
--- a/pkg/controller/build/schedule_pod.go
+++ b/pkg/controller/build/schedule_pod.go
@@ -170,6 +170,21 @@ func newBuildPod(build *v1alpha1.Build, operatorImage string) *corev1.Pod {
 			},
 		}
 
+		// In case the kaniko cache has not run, the /workspace dir needs to have the right permissions set
+		pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{
+			Name:            "prepare-kaniko-workspace",
+			Image:           "busybox",
+			ImagePullPolicy: corev1.PullIfNotPresent,
+			Command:         []string{"/bin/sh", "-c"},
+			Args:            []string{"chmod -R a+rwx /workspace"},
+			VolumeMounts: []corev1.VolumeMount{
+				{
+					Name:      "camel-k-builder",
+					MountPath: "/workspace",
+				},
+			},
+		})
+
 		// Use affinity only when the operator is present in the namespaced
 		if build.Namespace == platform.GetOperatorNamespace() {
 			// Co-locate with the builder pod for sharing the host path volume as the current
diff --git a/pkg/controller/integrationplatform/kaniko_cache.go b/pkg/controller/integrationplatform/kaniko_cache.go
index e12dea1..3470663 100644
--- a/pkg/controller/integrationplatform/kaniko_cache.go
+++ b/pkg/controller/integrationplatform/kaniko_cache.go
@@ -72,11 +72,8 @@ func createKanikoCacheWarmerPod(ctx context.Context, client client.Client, platf
 					Name:            "create-kaniko-cache",
 					Image:           "busybox",
 					ImagePullPolicy: corev1.PullIfNotPresent,
-					Command: []string{
-						"mkdir",
-						"-p",
-						"/workspace/cache",
-					},
+					Command:         []string{"/bin/sh", "-c"},
+					Args:            []string{"mkdir -p /workspace/cache && chmod -R a+rwx /workspace"},
 					VolumeMounts: []corev1.VolumeMount{
 						{
 							Name:      "camel-k-builder",