-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Spot/On-demand price to table-wide output irrespective of the price filters #106
Conversation
…ce filters * Minor clean-up
* remove the importing of un-used Lightsail packages, as [requested by @bwagner](aws#78 (comment)) * move non-standard lib imports to their own stanza, as [requested by @bwagner](aws#78 (comment)) Signed-off-by: Mike Ball <[email protected]>
This was requested by @bwagner here: aws#78 (comment) Signed-off-by: Mike Ball <[email protected]>
Per code review from @bwagner, this renames various methods and fields to be `*CacheUTC` rather than `*CachedUTC`: aws#78 (comment)
Signed-off-by: Mike Ball <[email protected]>
Previously, `selector` was incorrectly using the old `LastSpotCachedUTC` method name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking nice! Thanks for picking this up! I haven't checked it out and taken it for a test drive yet, but the code looks good.
Looks like |
This is now fixed, as the Pricing client is always initialized to us-east-1. Signed-off-by: Mike Ball <[email protected]>
Per [code review feedback](aws#106 (comment)), the error checking should appear within the `range pricingOutput.PriceList`. Signed-off-by: Mike Ball <[email protected]>
This issue is now resolved. Signed-off-by: Mike Ball <[email protected]>
Signed-off-by: Mike Ball <[email protected]>
This protects against panics like the following, for example: ``` --- FAIL: TestFilter_X8664_AMD64 (0.00s) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x153ec41] goroutine 153 [running]: testing.tRunner.func1.2({0x1613ee0, 0x1cdfe70}) /usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1209 +0x24e testing.tRunner.func1() /usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1212 +0x218 panic({0x1613ee0, 0x1cdfe70}) /usr/local/Cellar/go/1.17.2/libexec/src/runtime/panic.go:1038 +0x215 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector.Selector.rawFilter.func1(0x100e6e7, 0x68) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector.go:192 +0x241 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector_test.mockedEC2.DescribeInstanceTypesPages(...) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector_test.go:70 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector.Selector.rawFilter({{_, _}, {_, _}, {_}}, {0x0, 0x0, 0x0, 0xc0003854a0, 0x0, ...}) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector.go:184 +0x5c2 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector.Selector.FilterWithOutput({{_, _}, {_, _}, {_}}, {0x0, 0x0, 0x0, 0xc0003854a0, 0x0, ...}, ...) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector.go:116 +0xc5 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector.Selector.Filter({{_, _}, {_, _}, {_}}, {0x0, 0x0, 0x0, 0xc0003854a0, 0x0, ...}) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector.go:98 +0xcc github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector_test.TestFilter_X8664_AMD64(0xc0002de820) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector_test.go:583 +0x14e testing.tRunner(0xc00059b520, 0x177e1b0) /usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1259 +0x102 created by testing.(*T).Run /usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1306 +0x35a exit status 2 ``` Signed-off-by: Mike Ball <[email protected]>
This seeks to make the specifics of test failures a bit more clear. Signed-off-by: Mike Ball <[email protected]>
This addresses the following: ``` $ make unit-test go test -bench=. /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector//... -v -coverprofile=coverage.out -covermode=atomic -outputdir=/Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector//build go: updates to go.mod needed; to update it: go mod tidy make: *** [unit-test] Error 1 ``` Signed-off-by: Mike Ball <[email protected]>
looks like some unit-tests are failing having to do with pricing:
|
By populating the `lastOnDemandCacheUTC` and `lastSpotCacheUTC` fields with non-`nil` values, the `Filter` tests exercise relevant code paths. Note that this doesn't change @krishna-birla's original implementation (see PR aws#78) or vision; it only ensures the tests pass. Signed-off-by: Mike Ball <[email protected]>
itf := selector.Selector{ | ||
EC2: ec2Mock, | ||
EC2Pricing: &ec2PricingMock{ | ||
GetOndemandInstanceTypeCostResp: 0.0104, | ||
lastOnDemandCacheUTC: &now, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝️ By ensuring the *CacheUTC
field(s) are populated with a non-nil
value, the tests exercise relevant code paths in selector.rawFilter
.
It looks like something isn't working quite right. I pulled the code down today and did a table-wide run and no prices were output. I haven't had a chance to dive any deeper.
|
@bwagner5 Thanks for looking. It appears to work for me using a fresh binary compiled via
|
You're right, I was definitely the one confused :) I guess I was testing an old binary before... anyways LGTM! Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
This seeks to address issue #71 . It features the original changes submitted by @krishna-birla in the unmerged (and perhaps abandoned?) PR #78 , but also layers in the outstanding changes requested by @bwagner5 in code review.
Note, however, that it doesn't yet tackle this potential issue pointed out by @krishna-birla, nor does it dramatically change @krishna-birla's original implementation.
...this is currently a draft PR to surface visibility among theamazon-ec2-instance-selector
maintainers and perhaps get some early feedback on what remaining work is necessary to get this to a mergeable state.Thanks!
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.