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 2021/03/23 11:39:10 UTC
[camel-k] branch master updated (81ee26d -> b4fd815)
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.
from 81ee26d Updated CHANGELOG.md
new bae752f chore(s2i): Set owner reference for BuildConfig and ImageStream resources
new b4fd815 chore(ci): Remove extra shared mount
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/knative.yml | 1 -
pkg/builder/s2i.go | 48 ++++++++++++++++++++++++++++++++++++-------
2 files changed, 41 insertions(+), 8 deletions(-)
[camel-k] 01/02: chore(s2i): Set owner reference for BuildConfig
and ImageStream resources
Posted by as...@apache.org.
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 bae752f8b172f692f11b04ddc2012ddd74aa7e03
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Mon Mar 22 10:51:57 2021 +0100
chore(s2i): Set owner reference for BuildConfig and ImageStream resources
---
pkg/builder/s2i.go | 48 +++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 7 deletions(-)
diff --git a/pkg/builder/s2i.go b/pkg/builder/s2i.go
index 9273533..93058b9 100644
--- a/pkg/builder/s2i.go
+++ b/pkg/builder/s2i.go
@@ -29,9 +29,11 @@ import (
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/util/json"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
+ ctrlutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
buildv1 "github.com/openshift/api/build/v1"
imagev1 "github.com/openshift/api/image/v1"
@@ -54,7 +56,7 @@ var _ Task = &s2iTask{}
func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
status := v1.BuildStatus{}
- bc := buildv1.BuildConfig{
+ bc := &buildv1.BuildConfig{
TypeMeta: metav1.TypeMeta{
APIVersion: buildv1.GroupVersion.String(),
Kind: "BuildConfig",
@@ -82,17 +84,28 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
},
}
- err := t.c.Delete(ctx, &bc)
+ err := t.c.Delete(ctx, bc)
if err != nil && !apierrors.IsNotFound(err) {
return status.Failed(errors.Wrap(err, "cannot delete build config"))
}
- err = t.c.Create(ctx, &bc)
+ // Set the build controller as owner reference
+ owner := t.getControllerReference()
+ if owner == nil {
+ // Default to the Build if no controller reference is present
+ owner = t.build
+ }
+
+ if err := ctrlutil.SetOwnerReference(owner, bc, t.c.GetScheme()); err != nil {
+ return status.Failed(errors.Wrapf(err, "cannot set owner reference on BuildConfig: %s", bc.Name))
+ }
+
+ err = t.c.Create(ctx, bc)
if err != nil {
return status.Failed(errors.Wrap(err, "cannot create build config"))
}
- is := imagev1.ImageStream{
+ is := &imagev1.ImageStream{
TypeMeta: metav1.TypeMeta{
APIVersion: imagev1.GroupVersion.String(),
Kind: "ImageStream",
@@ -109,12 +122,16 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
},
}
- err = t.c.Delete(ctx, &is)
+ err = t.c.Delete(ctx, is)
if err != nil && !apierrors.IsNotFound(err) {
return status.Failed(errors.Wrap(err, "cannot delete image stream"))
}
- err = t.c.Create(ctx, &is)
+ if err := ctrlutil.SetOwnerReference(owner, is, t.c.GetScheme()); err != nil {
+ return status.Failed(errors.Wrapf(err, "cannot set owner reference on ImageStream: %s", is.Name))
+ }
+
+ err = t.c.Create(ctx, is)
if err != nil {
return status.Failed(errors.Wrap(err, "cannot create image stream"))
}
@@ -185,7 +202,7 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
return status.Failed(err)
}
- err = t.c.Get(ctx, ctrl.ObjectKeyFromObject(&is), &is)
+ err = t.c.Get(ctx, ctrl.ObjectKeyFromObject(is), is)
if err != nil {
return status.Failed(err)
}
@@ -198,3 +215,20 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
return status
}
+
+func (t *s2iTask) getControllerReference() metav1.Object {
+ var owner metav1.Object
+ for _, ref := range t.build.GetOwnerReferences() {
+ if ref.Controller != nil && *ref.Controller {
+ o := &unstructured.Unstructured{}
+ o.SetNamespace(t.build.Namespace)
+ o.SetName(ref.Name)
+ o.SetUID(ref.UID)
+ o.SetAPIVersion(ref.APIVersion)
+ o.SetKind(ref.Kind)
+ owner = o
+ break
+ }
+ }
+ return owner
+}
[camel-k] 02/02: chore(ci): Remove extra shared mount
Posted by as...@apache.org.
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 b4fd815fb5271c2ae9f5dc900cd27f67ffc6938d
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Mon Mar 22 21:33:03 2021 +0100
chore(ci): Remove extra shared mount
---
.github/workflows/knative.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml
index 69976d5..4850eaf 100644
--- a/.github/workflows/knative.yml
+++ b/.github/workflows/knative.yml
@@ -61,7 +61,6 @@ jobs:
echo "Final status:"
df -h
- sudo mount --make-shared /
- name: Set up JDK 11
uses: AdoptOpenJDK/install-jdk@v1
with: