From 5c7e306541e5825dd30aee6f175ccce5912284fa Mon Sep 17 00:00:00 2001 From: Pasquale Congiusti Date: Thu, 27 Apr 2023 15:56:13 +0200 Subject: [PATCH] Revert "fix(cmd): uninstall to wait the operator pod" This reverts commit 861f9831f4b4c3a8563a4821254b5f35102f876a. --- pkg/cmd/uninstall.go | 16 ---------------- pkg/util/watch/watch.go | 26 -------------------------- 2 files changed, 42 deletions(-) diff --git a/pkg/cmd/uninstall.go b/pkg/cmd/uninstall.go index 6b9731bd23..06b97db15e 100644 --- a/pkg/cmd/uninstall.go +++ b/pkg/cmd/uninstall.go @@ -20,7 +20,6 @@ package cmd import ( "context" "fmt" - "time" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -36,9 +35,7 @@ import ( v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" "github.com/apache/camel-k/v2/pkg/client" - "github.com/apache/camel-k/v2/pkg/platform" "github.com/apache/camel-k/v2/pkg/util/olm" - "github.com/apache/camel-k/v2/pkg/util/watch" ) func newCmdUninstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *uninstallCmdOptions) { @@ -159,19 +156,6 @@ func (o *uninstallCmdOptions) uninstall(cmd *cobra.Command, _ []string) error { return err } fmt.Fprintf(cmd.OutOrStdout(), "Camel K Operator removed from namespace %s\n", o.Namespace) - - // Let's wait the Pod has completed all the tasks before removing roles, as it may cause - // problems during the shutdown - - pod := platform.GetOperatorPod(o.Context, c, o.Namespace) - if pod != nil { - tctx, cancel := context.WithTimeout(o.Context, 15*time.Second) - defer cancel() - err := watch.WaitPodToTerminate(tctx, c, pod) - if err != nil { - return errors.Wrap(err, "error while waiting the operator pod to terminate gracefully") - } - } } if err = o.uninstallNamespaceRoles(o.Context, cmd, c); err != nil { diff --git a/pkg/util/watch/watch.go b/pkg/util/watch/watch.go index 32ee727883..e975ce8c87 100644 --- a/pkg/util/watch/watch.go +++ b/pkg/util/watch/watch.go @@ -23,7 +23,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/watch" v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" "github.com/apache/camel-k/v2/pkg/client" @@ -213,31 +212,6 @@ func HandleIntegrationPlatformEvents(ctx context.Context, c client.Client, p *v1 } } -// WaitPodToTerminate will wait for a given pod to teminate. -func WaitPodToTerminate(ctx context.Context, c client.Client, pod *corev1.Pod) error { - opts := metav1.ListOptions{ - TypeMeta: metav1.TypeMeta{}, - FieldSelector: fmt.Sprintf("metadata.name=%s", pod.Name), - } - watcher, err := c.CoreV1().Pods(pod.Namespace).Watch(ctx, opts) - if err != nil { - return err - } - - defer watcher.Stop() - - for { - select { - case event := <-watcher.ResultChan(): - if event.Type == watch.Deleted { - return nil - } - case <-ctx.Done(): - return nil - } - } -} - func isAllowed(lastEvent, event *corev1.Event, baseTime int64) bool { if lastEvent == nil { return true