Skip to content

Commit

Permalink
ondemandpct ignored when spot pools not supported by the provider (or…
Browse files Browse the repository at this point in the history
…acle)
  • Loading branch information
lpuskas authored and matyix committed Aug 1, 2018
1 parent 77480c8 commit aaacace
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkg/recommender/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ func (e *Engine) RecommendCluster(provider string, region string, req ClusterRec
}
log.Debugf("recommended vms for [%s]: count:[%d] , values: [%#v]", attr, len(filteredVms), filteredVms)

//todo add request validation for interdependent request fields, eg: onDemandPct is always 100 when spot
// instances are not available for provider
if provider == "oracle" {
log.Warnf("onDemand percentage in the request ignored for provider [%s]", provider)
req.OnDemandPct = 100
}
nps, err := e.RecommendNodePools(attr, filteredVms, values, req)
if err != nil {
return nil, fmt.Errorf("error while recommending node pools for attr: [%s], cause: [%s]", attr, err.Error())
Expand Down Expand Up @@ -535,10 +541,13 @@ func (e *Engine) RecommendNodePools(attr string, vms []VirtualMachine, values []

nps = append(nps, onDemandPool)

// retain only the nodes that are available as spot instances
vms = e.filterSpots(vms)
if len(vms) == 0 {
return nil, errors.New("no vms suitable for spot pools")
// if spot price pools requested
if req.OnDemandPct < 100 {
// retain only the nodes that are available as spot instances
vms = e.filterSpots(vms)
if len(vms) == 0 {
return nil, errors.New("no vms suitable for spot pools")
}
}

// vms are sorted by attribute value
Expand Down
1 change: 1 addition & 0 deletions pkg/recommender/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (e *Engine) includesFilter(vm VirtualMachine, req ClusterRecommendationReq)

// filterSpots selects vm-s that potentially can be part of "spot" node pools
func (e *Engine) filterSpots(vms []VirtualMachine) []VirtualMachine {
log.Debugf("selecting spot instances for recommending spot pools")
fvms := make([]VirtualMachine, 0)
for _, vm := range vms {
if vm.AvgPrice != 0 {
Expand Down

0 comments on commit aaacace

Please sign in to comment.