Fix: backwards compatibility for allocator default settings

When the allocator is not defined in the configuration, it will take defaults
and assume there is a "tags" informer. That is not the case. When not defined,
we assume it should allocate only by "freespace".
This commit is contained in:
Hector Sanjuan 2021-10-20 15:28:16 +02:00
parent 1dca6e0eca
commit 3f895df8cf

View File

@ -168,6 +168,13 @@ func createCluster(
informers = append(informers, tagsinf)
}
// For legacy compatibility we need to make the allocator
// automatically compatible with informers that have been loaded. For
// simplicity we assume that anyone that does not specify an allocator
// configuration (legacy configs), will be using "freespace"
if !cfgMgr.IsLoadedFromJSON(config.Allocator, cfgs.BalancedAlloc.ConfigKey()) {
cfgs.BalancedAlloc.AllocateBy = []string{"freespace"}
}
alloc, err := balanced.New(cfgs.BalancedAlloc)
checkErr("creating allocator", err)