WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
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
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
var Values string

var ErrInvalidConfig = errors.New("invalid config")
var ErrInvalidPrivateNodesConfig = errors.New("invalid private nodes config")

// NewDefaultConfig creates a new config based on the values.yaml, including all default values.
func NewDefaultConfig() (*Config, error) {
Expand Down Expand Up @@ -118,6 +119,18 @@ type PrivateNodes struct {
VPN PrivateNodesVPN `json:"vpn,omitempty"`
}

// UnmarshalJSON makes the schema change return a custom error for invalid private nodes config
func (p *PrivateNodes) UnmarshalJSON(data []byte) error {
type PrivateNodesAlias PrivateNodes
var alias PrivateNodesAlias
if err := json.Unmarshal(data, &alias); err != nil {
return fmt.Errorf("%w: %w", ErrInvalidPrivateNodesConfig, err)
}
// Copy the unmarshaled data
*p = PrivateNodes(alias)
return nil
}

type CloudControllerManager struct {
// Enabled defines if the embedded cloud controller manager should be enabled. This defaults to true, but can be disabled if you want to use
// an external cloud controller manager such as AWS or GCP. The cloud controller manager is responsible for setting the node's ip addresses as well
Expand Down
13 changes: 11 additions & 2 deletions pkg/cli/delete_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os/exec"
"strings"
"time"

"github.com/ghodss/yaml"
Expand Down Expand Up @@ -130,7 +131,15 @@ func DeleteHelm(ctx context.Context, platformClient platform.Client, options *De
vclusterConfig := &config.Config{}
err = yaml.Unmarshal(values, vclusterConfig)
if err != nil {
return err
privateNodesError := errors.Is(err, config.ErrInvalidPrivateNodesConfig) ||
strings.Contains(err.Error(), config.ErrInvalidPrivateNodesConfig.Error())
if privateNodesError {
cmd.log.Warnf("Failed to parse vcluster config from Helm values: %v. ", err)
cmd.log.Infof("Continuing with deletion...")
vclusterConfig = nil
} else {
return fmt.Errorf("failed to parse vcluster config from Helm values: %w", err)
}
}

// we have to delete the chart
Expand Down Expand Up @@ -203,7 +212,7 @@ func DeleteHelm(ctx context.Context, platformClient platform.Client, options *De
}

// if namespace sync is enabled, use cleanup handlers to handle namespace cleanup
if vclusterConfig.Sync.ToHost.Namespaces.Enabled {
if vclusterConfig != nil && vclusterConfig.Sync.ToHost.Namespaces.Enabled {
if err := CleanupSyncedNamespaces(ctx, cmd.Namespace, vClusterName, cmd.restConfig, cmd.kubeClient, cmd.log); err != nil {
return fmt.Errorf("run namespace cleanup: %w", err)
}
Expand Down
Loading