Skip to content
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

Allow specifying accelerators in cluster node_config (#1067) #1115

Merged
merged 3 commits into from
Feb 24, 2018

Conversation

dhague
Copy link
Contributor

@dhague dhague commented Feb 21, 2018

Fixes #1067

@dhague
Copy link
Contributor Author

dhague commented Feb 21, 2018

Tagging @ndmckinley for expedited review :-)

@nat-henderson nat-henderson self-requested a review February 21, 2018 18:28
accels := v.([]interface{})
guestAccelerators := make([]*container.AcceleratorConfig, 0, len(accels))
for _, raw := range accels {
data := raw.(map[string]interface{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you could make accels a []map[string]interface{}, which would mean you'd only have to do one of these casts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making accels a []map[string]interface{} leads to an error:

panic: interface conversion: interface {} is []interface {}, not []map[string]interface {}

goroutine 297 [running]:
github.com/terraform-providers/terraform-provider-google/google.expandNodeConfig(0x16797c0, 0xc4205361c0, 0xb)
	/home/i056593/Code/go/src/github.com/terraform-providers/terraform-provider-google/google/node_config.go:154 +0x12e0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, all right, that makes sense.

continue
}
guestAccelerators = append(guestAccelerators, &container.AcceleratorConfig{
AcceleratorCount: int64(data["count"].(int)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to do data["count"].(int64) - why do it this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using data["count"].(int64) leads to an error:

panic: interface conversion: interface {} is int, not int64

goroutine 296 [running]:
github.com/terraform-providers/terraform-provider-google/google.expandNodeConfig(0x16797c0, 0xc42035a040, 0xb)
	/home/i056593/Code/go/src/github.com/terraform-providers/terraform-provider-google/google/node_config.go:162 +0x12b4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check: resource.ComposeTestCheckFunc(
testAccCheckContainerNodePoolMatches("google_container_node_pool.np_with_gpu"),
),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - can you stick an ImportState step on there so we know that accelerated node pools can be imported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be the only ImportState in this file - why introduce it for just this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've talked to Hashicorp about best practices recently, and so it's a new thing we're doing with new tests.

guest_accelerator = [{
type="nvidia-tesla-k80"
count=1
}]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add the details of this structure to the documentation below here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@nat-henderson
Copy link
Contributor

Go ahead and add that test and it'll be good to merge.

@dhague
Copy link
Contributor Author

dhague commented Feb 23, 2018

ImportState test added & passing - looking OK?

@nat-henderson
Copy link
Contributor

Running the tests now, and then I'll merge it.

@nat-henderson
Copy link
Contributor

Some difficulties with the test environment but it should only be another few hours. Monday at the latest.

@nat-henderson
Copy link
Contributor

Aha, great, tests pass now. Merging.

@nat-henderson nat-henderson merged commit 5b0d8d4 into hashicorp:master Feb 24, 2018
@dhague
Copy link
Contributor Author

dhague commented Feb 24, 2018

Awesome - thanks!

@dhague dhague deleted the fix-1067 branch February 24, 2018 16:13
chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
@ghost
Copy link

ghost commented Mar 29, 2020

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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow specifying accelerators in cluster node_config
2 participants