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

Fix Google instance template creation for preemptible VM #4834

Merged

Conversation

erobert-c
Copy link

Hi there,

This commit should allow the creation of preemptible instance template in google compute engine. Currently, while trying to create such template, we get the following error:

Error applying plan:

1 error(s) occurred:

* google_compute_instance_template.preentibletemplate-test: Error creating instance: googleapi: Error 400: Invalid value for field 'resource.properties.scheduling.preemptible': 'true'.  Scheduling must have preemptible be false when AutomaticRestart is true., invalid

Here is a simple template to reproduce the issue

resource "google_compute_instance_template" "preentibletemplate-test" {
  name = "preemptible-template-test"
  machine_type = "n1-standard-2"
  scheduling {
    automatic_restart = false
    preemptible = true
  }
  disk {
    source_image = "${var.base_image}"
    boot = true
  }
  network_interface {
    network = "${var.subnet_id}"
  }
}

Tests results with make test TEST=./builtin/providers/google/ are still good.

Cheers

@phinze
Copy link
Contributor

phinze commented Feb 23, 2016

This LGTM - would like a double check from @lwander to be sure though.

forceSendFieldsScheduling = append(forceSendFieldsScheduling, "Preemptible")
if vp == true {
instanceProperties.Scheduling.OnHostMaintenance = "TERMINATE"
forceSendFieldsScheduling = append(forceSendFieldsScheduling, "OnHostMaintenance")
Copy link
Contributor

Choose a reason for hiding this comment

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

You allocate the capacity for this slice as 3, but you potentially add 4 items. This can cause runtime panic. I would recommend only placing "OnHostMaintenance" into ForceSendFields once, to avoid sending it twice.

@lwander
Copy link
Contributor

lwander commented Feb 23, 2016

Good catch and fix! Thanks for doing this @erobert-c; once you address the comments it's ready to be merged!

@erobert-c
Copy link
Author

Hi,

Thanks for the review, I'll fix those most probably beginning of next week.

@erobert-c erobert-c force-pushed the gce_instance_template_preemptible branch from 8e99989 to 92d5352 Compare March 8, 2016 16:23
@erobert-c
Copy link
Author

Hi @lwander,

I tried to integrate your feedbacks, squashed the commits and rebased on master. Don't hesitate to tell if you'd like me to change something else.

Cheers

@lwander
Copy link
Contributor

lwander commented Mar 9, 2016

LGTM!

lwander added a commit that referenced this pull request Mar 9, 2016
…ible

Fix Google instance template creation for preemptible VM
@lwander lwander merged commit b0d53a9 into hashicorp:master Mar 9, 2016
@ghost
Copy link

ghost commented Apr 27, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

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

Successfully merging this pull request may close these issues.

5 participants