Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error handling #1859

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/k3d/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
"app.kubernetes.io/instance",
"argo",
"argo",
600,
1200,
)
if err != nil {
log.Error().Msgf("Error finding argo workflows Deployment: %s", err)
Expand All @@ -1376,11 +1376,6 @@ func runK3d(cmd *cobra.Command, args []string) error {
return err
}

// Mark cluster install as complete
telemetry.SendEvent(segClient, telemetry.ClusterInstallCompleted, "")
viper.Set("kubefirst-checks.cluster-install-complete", true)
viper.WriteConfig()

// Set flags used to track status of active options
helpers.SetClusterStatusFlags(k3d.CloudProvider, config.GitProvider)

Expand Down Expand Up @@ -1417,6 +1412,11 @@ func runK3d(cmd *cobra.Command, args []string) error {
log.Error().Err(err).Msg("")
}

// Mark cluster install as complete
telemetry.SendEvent(segClient, telemetry.ClusterInstallCompleted, "")
viper.Set("kubefirst-checks.cluster-install-complete", true)
viper.WriteConfig()

log.Info().Msg("kubefirst installation complete")
log.Info().Msg("welcome to your new kubefirst platform running in K3d")
time.Sleep(time.Second * 1) // allows progress bars to finish
Expand Down
14 changes: 9 additions & 5 deletions cmd/k3d/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"
"time"

"github.com/kubefirst/kubefirst/internal/progress"
"github.com/kubefirst/runtime/pkg"
gitlab "github.com/kubefirst/runtime/pkg/gitlab"
"github.com/kubefirst/runtime/pkg/helpers"
Expand All @@ -30,11 +31,13 @@ func destroyK3d(cmd *cobra.Command, args []string) error {

// Determine if there are active installs
gitProvider := viper.GetString("flags.git-provider")
clusterName := viper.GetString("flags.cluster-name")
gitProtocol := viper.GetString("flags.git-protocol")
// _, err := helpers.EvalDestroy(k3d.CloudProvider, gitProvider)
// if err != nil {
// return err
// }

if clusterName == "" {
fmt.Printf("Your kubefirst platform running has been already destroyed.")
progress.Progress.Quit()
}

// Check for existing port forwards before continuing
err := k8s.CheckForExistingPortForwards(9000)
Expand All @@ -49,7 +52,6 @@ func destroyK3d(cmd *cobra.Command, args []string) error {

log.Info().Msg("destroying kubefirst platform running in k3d")

clusterName := viper.GetString("flags.cluster-name")
atlantisWebhookURL := fmt.Sprintf("%s/events", viper.GetString("ngrok.host"))

// Switch based on git provider, set params
Expand Down Expand Up @@ -240,6 +242,7 @@ func destroyK3d(cmd *cobra.Command, args []string) error {
viper.Set("kbot", "")
viper.Set("kubefirst-checks", "")
viper.Set("kubefirst", "")
viper.Set("flags", "")
viper.WriteConfig()
}

Expand All @@ -251,6 +254,7 @@ func destroyK3d(cmd *cobra.Command, args []string) error {
}
time.Sleep(time.Millisecond * 200) // allows progress bars to finish
fmt.Printf("Your kubefirst platform running in %s has been destroyed.", k3d.CloudProvider)
progress.Progress.Quit()

return nil
}
7 changes: 7 additions & 0 deletions internal/utilities/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ func ExportCluster(cluster apiTypes.Cluster, kcfg *k8s.KubernetesClient) error {
cluster.Status = "provisioned"
cluster.InProgress = false

if viper.GetBool("kubefirst-checks.secret-export-state") {
return nil
}

time.Sleep(time.Second * 10)

payload, err := json.Marshal(cluster)
Expand All @@ -223,5 +227,8 @@ func ExportCluster(cluster apiTypes.Cluster, kcfg *k8s.KubernetesClient) error {
return errors.New(fmt.Sprintf("unable to save secret to management cluster. %s", err))
}

viper.Set("kubefirst-checks.secret-export-state", true)
viper.WriteConfig()

return nil
}