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 2021/08/27 12:29:25 UTC

[camel-k] branch 2487-fix-reset created (now 560b640)

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

nferraro pushed a change to branch 2487-fix-reset
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


      at 560b640  Fix #2487: do not directly delete owned integrations on reset

This branch includes the following new commits:

     new 560b640  Fix #2487: do not directly delete owned integrations on reset

The 1 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.


[camel-k] 01/01: Fix #2487: do not directly delete owned integrations on reset

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a commit to branch 2487-fix-reset
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 560b640fd05eeb05d18237c0af9ae652797ea16b
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Fri Aug 27 14:28:59 2021 +0200

    Fix #2487: do not directly delete owned integrations on reset
---
 pkg/cmd/reset.go | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/pkg/cmd/reset.go b/pkg/cmd/reset.go
index 5831d85..9f717d7 100644
--- a/pkg/cmd/reset.go
+++ b/pkg/cmd/reset.go
@@ -25,6 +25,7 @@ import (
 	"github.com/apache/camel-k/pkg/client"
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
+	"k8s.io/apimachinery/pkg/runtime/schema"
 	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 )
 
@@ -100,6 +101,10 @@ func (o *resetCmdOptions) deleteAllIntegrations(c client.Client) (int, error) {
 	}
 	for _, i := range list.Items {
 		it := i
+		if isIntegrationOwned(it) {
+			// Deleting it directly is ineffective, deleting the controller will delete it
+			continue
+		}
 		if err := c.Delete(o.Context, &it); err != nil {
 			return 0, errors.Wrap(err, fmt.Sprintf("could not delete integration %s from namespace %s", it.Name, it.Namespace))
 		}
@@ -150,3 +155,16 @@ func (o *resetCmdOptions) resetIntegrationPlatform(c client.Client) error {
 	platform.Status = v1.IntegrationPlatformStatus{}
 	return c.Status().Update(o.Context, &platform)
 }
+
+func isIntegrationOwned(it v1.Integration) bool {
+	for _, ref := range it.OwnerReferences {
+		gv, err := schema.ParseGroupVersion(ref.APIVersion)
+		if err != nil {
+			continue
+		}
+		if gv.Group == v1.SchemeGroupVersion.Group && ref.BlockOwnerDeletion != nil && *ref.BlockOwnerDeletion {
+			return true
+		}
+	}
+	return false
+}