fix: bypass deletion error if k3s is the configured scheduler and it isn't installed
This commit is contained in:
@@ -1142,6 +1142,7 @@ func installHelm(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isKubernetesAvailable returns an error if kubernetes api is not available
|
||||||
func isKubernetesAvailable() error {
|
func isKubernetesAvailable() error {
|
||||||
client, err := NewKubernetesClient()
|
client, err := NewKubernetesClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1155,6 +1156,7 @@ func isKubernetesAvailable() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isK3sInstalled returns an error if k3s is not installed
|
||||||
func isK3sInstalled() error {
|
func isK3sInstalled() error {
|
||||||
if !common.FileExists("/usr/local/bin/k3s") {
|
if !common.FileExists("/usr/local/bin/k3s") {
|
||||||
return fmt.Errorf("k3s binary is not available")
|
return fmt.Errorf("k3s binary is not available")
|
||||||
@@ -1167,6 +1169,11 @@ func isK3sInstalled() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isK3sKubernetes returns true if the current kubernetes cluster is configured to be k3s
|
||||||
|
func isK3sKubernetes() bool {
|
||||||
|
return getKubeconfigPath() == KubeConfigPath
|
||||||
|
}
|
||||||
|
|
||||||
func isPodReady(ctx context.Context, clientset KubernetesClient, podName, namespace string) wait.ConditionWithContextFunc {
|
func isPodReady(ctx context.Context, clientset KubernetesClient, podName, namespace string) wait.ConditionWithContextFunc {
|
||||||
return func(ctx context.Context) (bool, error) {
|
return func(ctx context.Context) (bool, error) {
|
||||||
fmt.Printf(".")
|
fmt.Printf(".")
|
||||||
|
|||||||
@@ -1159,6 +1159,24 @@ func TriggerSchedulerPostDelete(scheduler string, appName string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataErr := common.RemoveAppDataDirectory("logs", appName)
|
||||||
|
propertyErr := common.PropertyDestroy("logs", appName)
|
||||||
|
|
||||||
|
if dataErr != nil {
|
||||||
|
return dataErr
|
||||||
|
}
|
||||||
|
|
||||||
|
if propertyErr != nil {
|
||||||
|
return propertyErr
|
||||||
|
}
|
||||||
|
|
||||||
|
if isK3sKubernetes() {
|
||||||
|
if err := isK3sInstalled(); err != nil {
|
||||||
|
common.LogWarn("k3s is not installed, skipping")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := isKubernetesAvailable(); err != nil {
|
if err := isKubernetesAvailable(); err != nil {
|
||||||
return fmt.Errorf("kubernetes api not available: %w", err)
|
return fmt.Errorf("kubernetes api not available: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user