in pkg/api/platformapi/allocatorapi/vacate.go [52:98]
func Vacate(params *VacateParams) error {
if err := params.Validate(); err != nil {
return err
}
var emptyTimeout pool.Timeout
if params.PoolTimeout == emptyTimeout {
params.PoolTimeout = pool.DefaultTimeout
}
p, err := pool.NewPool(pool.Params{
Size: params.Concurrency,
Run: VacateClusterInPool,
Timeout: params.PoolTimeout,
Writer: params.Output,
})
if err != nil {
return err
}
// Errors reported here are returned by a dry-run execution of the move api (validation-only flag is used)
// and we don't want to stop the real vacate.
// Instead we are returning the validateOnlyErr with the actual vacate validateOnlyErr at the end of the function
leftovers, hasWork, validateOnlyErr := moveAllocators(params, p)
if err := p.Start(); err != nil {
return err
}
// If the queue was full prior to starting it, there might be some
// leftovers, ranging until the leftovers are inexistent as the pool
// clears out the work items.
for len(leftovers) > 0 {
leftovers, _ = p.Add(leftovers...)
}
var merr = multierror.NewPrefixed("vacate error")
unpackMultierror(merr, validateOnlyErr)
// Wait until all of the items have been processed and unpack the errors
// from the pooled vacate calls tos the multierror.
if err := waitVacateCompletion(p, hasWork); err != nil {
unpackMultierror(merr, err)
}
return multierror.WithFormat(merr.ErrorOrNil(), params.OutputFormat)
}