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

fixed issue with eks migration #1984

Merged
merged 1 commit into from
Jul 25, 2024
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
2 changes: 1 addition & 1 deletion cmd/vclusterctl/cmd/convert/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (cmd *configCmd) Run() error {
)

if cmd.distro == "" {
return fmt.Errorf("no distro given: please set \"--distro\" (IMPORTANT: distro must match the given config values)")
return fmt.Errorf("no distro given: please set \"--distro\" (IMPORTANT: distro must match the given config values, or be \"k8s\" if you are migrating from eks distro)")
}

if cmd.filePath != "" {
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func ValidateChanges(oldCfg, newCfg *Config) error {

// ValidateStoreAndDistroChanges checks whether migrating from one store to the other is allowed.
func ValidateStoreAndDistroChanges(currentStoreType, previousStoreType StoreType, currentDistro, previousDistro string) error {
if currentDistro != previousDistro {
if currentDistro != previousDistro && !(previousDistro == "eks" && currentDistro == K8SDistro) {
return fmt.Errorf("seems like you were using %s as a distro before and now have switched to %s, please make sure to not switch between vCluster distros", previousDistro, currentDistro)
}

Expand Down
21 changes: 7 additions & 14 deletions config/legacyconfig/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,30 @@ func MigrateLegacyConfig(distro, oldValues string) (string, error) {
if err != nil {
return "", fmt.Errorf("migrate legacy %s values: %w", distro, err)
}
case config.K8SDistro:
err = migrateK8sAndEKS(distro, oldValues, toConfig)
case config.K8SDistro, "eks":
err = migrateK8sAndEKS(oldValues, toConfig)
if err != nil {
return "", fmt.Errorf("migrate legacy %s values: %w", distro, err)
}
default:
if distro == "eks" {
return "", fmt.Errorf("eks distro is not supported anymore. Instead use the k8s distro with the eks images")
}

return "", fmt.Errorf("migrating distro %s is not supported", distro)
}

return config.Diff(fromConfig, toConfig)
}

func migrateK8sAndEKS(distro, oldValues string, newConfig *config.Config) error {
func migrateK8sAndEKS(oldValues string, newConfig *config.Config) error {
// unmarshal legacy config
oldConfig := &LegacyK8s{}
err := oldConfig.UnmarshalYAMLStrict([]byte(oldValues))
if err != nil {
return fmt.Errorf("unmarshal legacy config: %w", err)
}

// k8s specific
if distro == config.K8SDistro {
newConfig.ControlPlane.Distro.K8S.Enabled = true
convertAPIValues(oldConfig.API, &newConfig.ControlPlane.Distro.K8S.APIServer)
convertControllerValues(oldConfig.Controller, &newConfig.ControlPlane.Distro.K8S.ControllerManager)
convertSchedulerValues(oldConfig.Scheduler, &newConfig.ControlPlane.Distro.K8S.Scheduler)
}
newConfig.ControlPlane.Distro.K8S.Enabled = true
convertAPIValues(oldConfig.API, &newConfig.ControlPlane.Distro.K8S.APIServer)
convertControllerValues(oldConfig.Controller, &newConfig.ControlPlane.Distro.K8S.ControllerManager)
convertSchedulerValues(oldConfig.Scheduler, &newConfig.ControlPlane.Distro.K8S.Scheduler)

// convert etcd
err = convertEtcd(oldConfig.Etcd, newConfig)
Expand Down
Loading