Skip to content

Commit 1b597c5

Browse files
committed
chore: sync config/*.go and values.schema.json to vCluster version v0.25.1-rc.1
1 parent 11174c8 commit 1b597c5

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

config/config.go

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -335,29 +335,49 @@ func (c *Config) IsConfiguredForSleepMode() bool {
335335
}
336336

337337
// ValidateChanges checks for disallowed config changes.
338-
// Currently only certain backingstore changes are allowed but no distro change.
339338
func ValidateChanges(oldCfg, newCfg *Config) error {
340-
oldDistro, newDistro := oldCfg.Distro(), newCfg.Distro()
341-
oldBackingStore, newBackingStore := oldCfg.BackingStoreType(), newCfg.BackingStoreType()
342-
343-
return ValidateStoreAndDistroChanges(newBackingStore, oldBackingStore, newDistro, oldDistro)
339+
if err := ValidateDistroChanges(newCfg.Distro(), oldCfg.Distro()); err != nil {
340+
return err
341+
}
342+
if err := ValidateStoreChanges(newCfg.BackingStoreType(), oldCfg.BackingStoreType()); err != nil {
343+
return err
344+
}
345+
return nil
344346
}
345347

346-
// ValidateStoreAndDistroChanges checks whether migrating from one store to the other is allowed.
347-
func ValidateStoreAndDistroChanges(currentStoreType, previousStoreType StoreType, currentDistro, previousDistro string) error {
348-
if currentDistro != previousDistro && !(previousDistro == "eks" && currentDistro == K8SDistro) && !(previousDistro == K3SDistro && currentDistro == K8SDistro) {
349-
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)
348+
// ValidateStoreChanges checks whether migrating from one store to the other is allowed.
349+
func ValidateStoreChanges(currentStoreType, previousStoreType StoreType) error {
350+
if currentStoreType == previousStoreType {
351+
return nil
350352
}
351353

352-
if currentStoreType != previousStoreType {
353-
if currentStoreType != StoreTypeDeployedEtcd && currentStoreType != StoreTypeEmbeddedEtcd {
354-
return fmt.Errorf("seems like you were using %s as a store before and now have switched to %s, please make sure to not switch between vCluster stores", previousStoreType, currentStoreType)
354+
switch currentStoreType {
355+
case StoreTypeDeployedEtcd:
356+
fallthrough
357+
case StoreTypeEmbeddedEtcd:
358+
// switching from external ETCD, deploy ETCD, or embedded (SQLite) to deployed or embedded ETCD is valid
359+
if previousStoreType == StoreTypeExternalEtcd || previousStoreType == StoreTypeDeployedEtcd || previousStoreType == StoreTypeEmbeddedDatabase {
360+
return nil
355361
}
356-
if previousStoreType != StoreTypeExternalEtcd && previousStoreType != StoreTypeDeployedEtcd && previousStoreType != StoreTypeEmbeddedDatabase {
357-
return fmt.Errorf("seems like you were using %s as a store before and now have switched to %s, please make sure to not switch between vCluster stores", previousStoreType, currentStoreType)
362+
case StoreTypeExternalDatabase:
363+
// switching from embedded to external ETCD is allowed because of a bug that labeled store types as embedded but used
364+
// external info if provided when the external "enabled" flag was not used. Now, using the "enabled" flag is required or
365+
// SQLite is used. The exception to allow this switch is necessary so they can toggle the "enabled" flag if the cluster
366+
// was previously using external. Otherwise, after upgrade the vCluster will start using a fresh SQLite database.
367+
if previousStoreType == StoreTypeEmbeddedDatabase {
368+
return nil
358369
}
370+
default:
359371
}
372+
return fmt.Errorf("seems like you were using %s as a store before and now have switched to %s,"+
373+
" please make sure to not switch between vCluster stores", previousStoreType, currentStoreType)
374+
}
360375

376+
// ValidateDistroChanges checks whether migrating from one distro to the other is allowed.
377+
func ValidateDistroChanges(currentDistro, previousDistro string) error {
378+
if currentDistro != previousDistro && !(previousDistro == "eks" && currentDistro == K8SDistro) && !(previousDistro == K3SDistro && currentDistro == K8SDistro) {
379+
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)
380+
}
361381
return nil
362382
}
363383

0 commit comments

Comments
 (0)