-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 support for guest_accelerators (GPU) to google_compute_instance #330
Conversation
|
google/resource_compute_instance.go
Outdated
|
||
func flattenBetaScheduling(scheduling *computeBeta.Scheduling) []map[string]interface{} { | ||
result := make([]map[string]interface{}, 0, 1) | ||
schedulingMap := make(map[string]interface{}) |
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.
nit: you can put some of the items in the map initially:
schedulingMap := map[string]interface{}{
"on_host_maintenanace": scheduling.OnHostMaintenance
// etc.
}
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.
Done. I also fixed the flattenScheduling
method.
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.
It's awesome that you were able to get to google_compute_instance
so fast!
I noticed two small things when scanning through quickly, I was curious what the scope of the changes looked like!
google/resource_compute_instance.go
Outdated
d.Set("scheduling", scheduling) | ||
|
||
d.Set("scheduling", flattenBetaScheduling(instance.Scheduling)) | ||
d.Set("guest_accelerator", flattenGuestAccelerators(instance.Zone, instance.GuestAccelerators)) |
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.
(Line below) If we don't convert the self link to v1, we will cause diffs in resources that refer to this one; you can use the existing function I was using, or move to a StateFunc
.
In this case I'd probably do the former because it is already a big PR, and you can clean up all the old function usages at once in a separate PR when you have time.
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.
Done
@@ -260,6 +260,16 @@ The `scheduling` block supports: | |||
* `automatic_restart` - (Optional) Specifies if the instance should be | |||
restarted if it was terminated by Compute Engine (not a user). | |||
|
|||
--- | |||
|
|||
* `guest_accelerator` - (Optional, Beta) List of the type and count of accelerator cards attached to the instance. Structure documented below. |
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.
We should link to the Beta section of the provider docs whenever we write that a field is Beta; that way, users can easily discover what that means for them.
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.
Done
Thanks for reviewing this @rileykarson ! |
Waiting on @paddycarver to increase quota for the tesla-k80 GPU (default quota is 0) on our CI account before submitting. |
9c603d9
to
36150ab
Compare
Rebased with master. Re-ran the tests:
|
Ran under the CI account with the quota increased. Passed for me. Feel free to merge at will :) |
Add OAuth2 access_token and client config as credential options.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Fixes #212.
Related to #311
guest_accelerator is a beta feature. My first step was to convert google_compute_instance to a beta resource.
I upgraded the compute beta client to the latest version. The beta version we were currently using had fields in the Instance class where pointers for string and bool weren't used to differentiate between unset and default value (false or ""). For instance, some fields in the v1 client had "bool*" and now only had "bool" type. The latest beta version didn't have this problem and lined up with the v1 client.
@paddycarver We will need to add quota for GPU (default quota is 0) to the CI service account.
@danawillow