Skip to content

Commit

Permalink
Move logs about incompatible instance types to debug (#415)
Browse files Browse the repository at this point in the history
Previously, the amount of logs generated when replacing a large
number of on-demand instances could be overwhelming since info about
each candidate instance type was logged. Now, we still log when an
instance type matches, but now all the logs about every instance type
that does not match will be at debug level.

This change was begun in https://github.com/AutoSpotting/AutoSpotting/pull/354/files#diff-fa23d3c4fb090da3bc9f71371d6e1d95R446.
  • Loading branch information
gabegorelick committed Feb 4, 2020
1 parent 30a4392 commit 985d675
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/autoscaling_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (a *autoScalingGroup) loadConfSpot() bool {
}
if newValue, done := a.loadBiddingPolicy(tagValue); done {
a.region.conf.BiddingPolicy = newValue
logger.Println("BiddingPolicy =", a.region.conf.BiddingPolicy)
debug.Println("BiddingPolicy =", a.region.conf.BiddingPolicy)
return done
}
return false
Expand Down
24 changes: 12 additions & 12 deletions core/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ func (i *instance) terminate() error {

func (i *instance) isPriceCompatible(spotPrice float64) bool {
if spotPrice == 0 {
logger.Printf("\tUnavailable in this Availability Zone")
debug.Printf("\tUnavailable in this Availability Zone")
return false
}

if spotPrice <= i.price {
return true
}

logger.Printf("\tNot price compatible")
debug.Printf("\tNot price compatible")
return false
}

Expand All @@ -239,7 +239,7 @@ func (i *instance) isClassCompatible(spotCandidate instanceTypeInformation) bool
spotCandidate.GPU >= current.GPU {
return true
}
logger.Println("\tNot class compatible (CPU/memory/GPU)")
debug.Println("\tNot class compatible (CPU/memory/GPU)")
return false
}

Expand All @@ -251,7 +251,7 @@ func (i *instance) isSameArch(other instanceTypeInformation) bool {
(isARM(thisCPU) && isARM(otherCPU))

if !ret {
logger.Println("\tInstance CPU architecture mismatch, current CPU architecture",
debug.Println("\tInstance CPU architecture mismatch, current CPU architecture",
thisCPU, "is incompatible with candidate CPU architecture", otherCPU)
}
return ret
Expand All @@ -277,7 +277,7 @@ func isARM(cpuName string) bool {

func (i *instance) isEBSCompatible(spotCandidate instanceTypeInformation) bool {
if spotCandidate.EBSThroughput < i.typeInfo.EBSThroughput {
logger.Println("\tEBS throughput insufficient:", spotCandidate.EBSThroughput, "<", i.typeInfo.EBSThroughput)
debug.Println("\tEBS throughput insufficient:", spotCandidate.EBSThroughput, "<", i.typeInfo.EBSThroughput)
return false
}
return true
Expand Down Expand Up @@ -311,7 +311,7 @@ func (i *instance) isStorageCompatible(spotCandidate instanceTypeInformation, at
spotCandidate.instanceStoreIsSSD == existing.instanceStoreIsSSD)) {
return true
}
logger.Println("\tNot storage compatible")
debug.Println("\tNot storage compatible")
return false
}

Expand All @@ -330,7 +330,7 @@ func (i *instance) isVirtualizationCompatible(spotVirtualizationTypes []string)
return true
}
}
logger.Println("\tNot virtualization compatible")
debug.Println("\tNot virtualization compatible")
return false
}

Expand Down Expand Up @@ -381,7 +381,7 @@ func (i *instance) getCompatibleSpotInstanceTypesListSortedAscendingByPrice(allo
candidate := i.region.instanceTypeInformation[k]

candidatePrice := i.calculatePrice(candidate)
logger.Println("Comparing current type", current.instanceType, "with price", i.price,
debug.Println("Comparing current type", current.instanceType, "with price", i.price,
"with candidate", candidate.instanceType, "with price", candidatePrice)

if i.isAllowed(candidate.instanceType, allowedList, disallowedList) &&
Expand All @@ -391,7 +391,7 @@ func (i *instance) getCompatibleSpotInstanceTypesListSortedAscendingByPrice(allo
i.isStorageCompatible(candidate, attachedVolumesNumber) &&
i.isVirtualizationCompatible(candidate.virtualizationTypes) {
acceptableInstanceTypes = append(acceptableInstanceTypes, acceptableInstance{candidate, candidatePrice})
logger.Println("\tMATCH FOUND, added", candidate.instanceType, "to launch candiates list")
logger.Println("\tMATCH FOUND, added", candidate.instanceType, "to launch candiates list for instance", i.InstanceId)
} else if candidate.instanceType != "" {
debug.Println("Non compatible option found:", candidate.instanceType, "at", candidatePrice, " - discarding")
}
Expand Down Expand Up @@ -460,16 +460,16 @@ func (i *instance) launchSpotReplacement() error {
func (i *instance) getPricetoBid(
baseOnDemandPrice float64, currentSpotPrice float64) float64 {

logger.Println("BiddingPolicy: ", i.region.conf.BiddingPolicy)
debug.Println("BiddingPolicy: ", i.region.conf.BiddingPolicy)

if i.region.conf.BiddingPolicy == DefaultBiddingPolicy {
logger.Println("Bidding base on demand price", baseOnDemandPrice)
logger.Println("Bidding base on demand price", baseOnDemandPrice, "to replace instance", i.InstanceId)
return baseOnDemandPrice
}

bufferPrice := math.Min(baseOnDemandPrice, currentSpotPrice*(1.0+i.region.conf.SpotPriceBufferPercentage/100.0))
logger.Println("Bidding buffer-based price of", bufferPrice, "based on current spot price of", currentSpotPrice,
"and buffer percentage of", i.region.conf.SpotPriceBufferPercentage)
"and buffer percentage of", i.region.conf.SpotPriceBufferPercentage, "to replace instance", i.InstanceId)
return bufferPrice
}

Expand Down
3 changes: 3 additions & 0 deletions core/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,9 @@ func TestGetPricetoBid(t *testing.T) {
name: "us-east-1",
conf: cfg,
},
Instance: &ec2.Instance{
InstanceId: aws.String("i-0000000"),
},
}

currentSpotPrice := tt.currentSpotPrice
Expand Down

0 comments on commit 985d675

Please sign in to comment.