Skip to content

Commit

Permalink
Kusk uninstall fix (#1030)
Browse files Browse the repository at this point in the history
* wait on CRs to be removed before removing Kusk

Signed-off-by: jasmingacic <[email protected]>

* added 1 second timeout

Signed-off-by: jasmingacic <[email protected]>

Signed-off-by: jasmingacic <[email protected]>
  • Loading branch information
jasmingacic authored Dec 15, 2022
1 parent 681fbe1 commit 11166ef
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions cmd/kusk/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"time"

kuskv1 "github.com/kubeshop/kusk-gateway/api/v1alpha1"
"github.com/kubeshop/kusk-gateway/cmd/kusk/internal/errors"
Expand Down Expand Up @@ -101,6 +102,20 @@ var uninstallCmd = &cobra.Command{
}
apiSpinner.Success("Deleted APIs")
}
for {
if err := c.List(cmd.Context(), apis, &client.ListOptions{}); err != nil {
if err.Error() == `no matches for kind "API" in version "gateway.kusk.io/v1alpha1"` {
kuskui.PrintInfo("Kusk Custom Resource Definition API is not installed.")
} else {
reportError(err)
return err
}
}
if len(apis.Items) == 0 {
break
}
time.Sleep(1 * time.Second)
}

fleets := &kuskv1.EnvoyFleetList{}
if err := c.List(cmd.Context(), fleets, &client.ListOptions{}); err != nil {
Expand All @@ -123,6 +138,21 @@ var uninstallCmd = &cobra.Command{
envoyFleetSpinner.Success("Deleted EnvoyFleets")
}

for {
if err := c.List(cmd.Context(), fleets, &client.ListOptions{}); err != nil {
if err.Error() == `no matches for kind "EnvoyFleet" in version "gateway.kusk.io/v1alpha1"` {
kuskui.PrintInfo("Kusk Custom Resource Definition EnvoyFleet is not installed.")
} else {
reportError(err)
return err
}
}
if len(fleets.Items) == 0 {
break
}
time.Sleep(1 * time.Second)
}

staticRoutes := &kuskv1.StaticRouteList{}
if err := c.List(cmd.Context(), staticRoutes, &client.ListOptions{}); err != nil {
if err.Error() == `no matches for kind "StaticRoute" in version "gateway.kusk.io/v1alpha1"` {
Expand All @@ -144,6 +174,21 @@ var uninstallCmd = &cobra.Command{
staticRoutesSpinner.Success("Deleted StaticRoutes")
}

for {
if err := c.List(cmd.Context(), staticRoutes, &client.ListOptions{}); err != nil {
if err.Error() == `no matches for kind "StaticRoute" in version "gateway.kusk.io/v1alpha1"` {
kuskui.PrintInfo("Kusk Custom Resource Definition StaticRouote is not installed")
} else {
reportError(err)
return err
}
}
if len(staticRoutes.Items) == 0 {
break
}
time.Sleep(1 * time.Second)
}

kuskGatewaySpinner := utils.NewSpinner("Deleting Kusk Gateway...")

if err := deletek(dir); err != nil {
Expand Down

0 comments on commit 11166ef

Please sign in to comment.