AutoSpotting icon indicating copy to clipboard operation
AutoSpotting copied to clipboard

Delay fetching spot prices until they're needed?

Open phils opened this issue 8 years ago • 1 comments

Issue type

  • Bug Report

Build number

build261

Environment

  • ap-southeast-2
  • VPC

Summary

I notice that whenever the lambda function runs it fetches the spot prices at the start. In many cases, I think the script will never use these figures. Could it instead wait until spot prices are needed before fetching them?

Apologies if I've misunderstood how this works. See example run below where nothing was performed by the script.

Actual results

2017-02-26T04:21:06.346Z fdd55eb8-fbda-11e6-8ad5-c55c55a8fc70 Starting autospotting agent, build261
2017/02/26 04:21:06 main.go:82: Scanning for available AWS regions
2017/02/26 04:21:06 main.go:65: Enabled to run in ap-southeast-2, processing region.
2017/02/26 04:21:06 region.go:65: Creating connections to the required AWS services in ap-southeast-2
2017/02/26 04:21:06 connections.go:24: Creating Service connections in ap-southeast-2
2017/02/26 04:21:06 connections.go:41: Created service connections in ap-southeast-2
2017/02/26 04:21:06 region.go:69: Scanning for enabled AutoScaling groups in ap-southeast-2
2017/02/26 04:21:07 region.go:250: Processing page 1 of DescribeTagsPages for ap-southeast-2
2017/02/26 04:21:07 region.go:252: ap-southeast-2 has enabled ASG: blah-asg
2017/02/26 04:21:07 region.go:284: Processing page 1 of DescribeAutoScalingGroupsPages for ap-southeast-2
2017/02/26 04:21:07 region.go:76: Scanning full instance information in ap-southeast-2
2017/02/26 04:21:07 spot_price.go:24: ap-southeast-2 Requesting spot prices
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.2xlarge in ap-southeast-2a skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.2xlarge in ap-southeast-2c skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.2xlarge in ap-southeast-2b skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.8xlarge in ap-southeast-2a skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.8xlarge in ap-southeast-2c skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.8xlarge in ap-southeast-2b skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.large in ap-southeast-2c skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.large in ap-southeast-2b skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.4xlarge in ap-southeast-2c skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.4xlarge in ap-southeast-2b skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.16xlarge in ap-southeast-2a skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.16xlarge in ap-southeast-2c skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.16xlarge in ap-southeast-2b skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.xlarge in ap-southeast-2a skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.xlarge in ap-southeast-2c skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.xlarge in ap-southeast-2b skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.large in ap-southeast-2a skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:223: ap-southeast-2 Instance data missing for i3.4xlarge in ap-southeast-2a skipping because this region is currently not supported
2017/02/26 04:21:08 region.go:81: Scanning instances in ap-southeast-2
2017/02/26 04:21:09 region.go:87: Processing enabled AutoScaling groups in ap-southeast-2
2017/02/26 04:21:09 autoscaling.go:172: Finding spot instance requests created for blah-asg
2017/02/26 04:21:09 autoscaling.go:233: Spot instance requests were previously created for blah-asg
2017/02/26 04:21:09 autoscaling.go:245: Adding instances to blah-asg
2017/02/26 04:21:09 autoscaling.go:139: No default value for on-demand instances specified, skipping.
2017/02/26 04:21:09 autoscaling.go:734: blah-asg Counting already running on demand instances
2017/02/26 04:21:09 autoscaling.go:750: blah-asg Found 0 on-demand instances running on a total of 2
2017/02/26 04:21:09 autoscaling.go:151: Currently OnDemand running equals to the required number, skipping run
2017-02-26T04:21:09.707Z fdd55eb8-fbda-11e6-8ad5-c55c55a8fc70 Execution completed, nothing left to do
END RequestId: fdd55eb8-fbda-11e6-8ad5-c55c55a8fc70

phils avatar Feb 26 '17 04:02 phils

This is indeed requesting the spot prices before they are actually needed and it is wasteful 99% of the time when the no instances need to be replaced.

This is definitely doable but bandwidth is cheap enough for this to be a minor issue that I don't plan to fix anytime soon.

But if it is important enough for you, I will gladly accept a PR with a fix.

cristim avatar Feb 26 '17 06:02 cristim