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

Turn Spot VMs to GA on GCE. #5960

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ var (
"scheduling.0.preemptible",
"scheduling.0.node_affinities",
"scheduling.0.min_node_cpus",
<% unless version == 'ga' -%>
"scheduling.0.provisioning_model",
<% end -%>
}

shieldedInstanceConfigKeys = []string{
Expand Down Expand Up @@ -628,7 +626,6 @@ func resourceComputeInstance() *schema.Resource {
Optional: true,
AtLeastOneOf: schedulingKeys,
},
<% unless version == 'ga' -%>
"provisioning_model": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -637,7 +634,6 @@ func resourceComputeInstance() *schema.Resource {
AtLeastOneOf: schedulingKeys,
Description: `Whether the instance is spot. If this is set as SPOT.`,
},
<% end -%>
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ var (
"scheduling.0.preemptible",
"scheduling.0.node_affinities",
"scheduling.0.min_node_cpus",
<% unless version == 'ga' -%>
"scheduling.0.provisioning_model",
<% end -%>
}

shieldedInstanceTemplateConfigKeys = []string{
Expand Down Expand Up @@ -539,7 +537,6 @@ func resourceComputeInstanceTemplate() *schema.Resource {
AtLeastOneOf: schedulingInstTemplateKeys,
Description: `Minimum number of cpus for the instance.`,
},
<% unless version == 'ga' -%>
"provisioning_model": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -548,7 +545,6 @@ func resourceComputeInstanceTemplate() *schema.Resource {
AtLeastOneOf: schedulingInstTemplateKeys,
Description: `Whether the instance is spot. If this is set as SPOT.`,
},
<% end -%>
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,6 @@ func TestAccComputeInstanceTemplate_queueCount(t *testing.T) {
})
}

<% unless version == 'ga' -%>
func TestAccComputeInstanceTemplate_spot(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1109,7 +1108,6 @@ func TestAccComputeInstanceTemplate_spot(t *testing.T) {
},
})
}
<% end -%>

func testAccCheckComputeInstanceTemplateDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
Expand Down Expand Up @@ -1258,7 +1256,6 @@ func testAccCheckComputeInstanceTemplatePreemptible(instanceTemplate *compute.In
}
}

<% unless version == 'ga' -%>
func testAccCheckComputeInstanceTemplateProvisioningModel(instanceTemplate *compute.InstanceTemplate, provisioning_model string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if instanceTemplate.Properties.Scheduling.ProvisioningModel != provisioning_model {
Expand All @@ -1267,7 +1264,6 @@ func testAccCheckComputeInstanceTemplateProvisioningModel(instanceTemplate *comp
return nil
}
}
<% end -%>


func testAccCheckComputeInstanceTemplateAutomaticRestart(instanceTemplate *compute.InstanceTemplate, automaticRestart bool) resource.TestCheckFunc {
Expand Down Expand Up @@ -2731,7 +2727,6 @@ resource "google_compute_instance_template" "foobar" {
`, instanceTemplateName)
}

<% unless version == 'ga' -%>
func testAccComputeInstanceTemplate_spot(suffix string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
Expand Down Expand Up @@ -2771,6 +2766,4 @@ resource "google_compute_instance_template" "foobar" {
}
`, suffix)
}
<% end -%>


Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,6 @@ func TestAccComputeInstance_queueCount(t *testing.T) {
})
}

<% unless version == 'ga' -%>
func TestAccComputeInstance_spotVM(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -2271,7 +2270,6 @@ func TestAccComputeInstance_spotVM_update(t *testing.T) {
},
})
}
<% end -%>

func TestComputeInstance_networkIPCustomizedDiff(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -6238,7 +6236,6 @@ resource "google_compute_instance" "foobar" {
`, instance)
}

<% unless version == 'ga' -%>
func testAccComputeInstance_spotVM(instance string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
Expand Down Expand Up @@ -6270,6 +6267,4 @@ resource "google_compute_instance" "foobar" {
}
`, instance)
}
<% end -%>


Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,10 @@ func expandScheduling(v interface{}) (*compute.Scheduling, error) {
if v, ok := original["min_node_cpus"]; ok {
scheduling.MinNodeCpus = int64(v.(int))
}
<% unless version == 'ga' -%>
if v, ok := original["provisioning_model"]; ok {
scheduling.ProvisioningModel = v.(string)
scheduling.ForceSendFields = append(scheduling.ForceSendFields, "ProvisioningModel")
}
<% end -%>
return scheduling, nil
}

Expand All @@ -137,9 +135,7 @@ func flattenScheduling(resp *compute.Scheduling) []map[string]interface{} {
"on_host_maintenance": resp.OnHostMaintenance,
"preemptible": resp.Preemptible,
"min_node_cpus": resp.MinNodeCpus,
<% unless version == 'ga' -%>
"provisioning_model": resp.ProvisioningModel,
<% end -%>
}

if resp.AutomaticRestart != nil {
Expand Down Expand Up @@ -484,11 +480,9 @@ func schedulingHasChangeWithoutReboot(d *schema.ResourceData) bool {
return true
}

<% unless version == 'ga' -%>
if oScheduling["provisioning_model"] != newScheduling["provisioning_model"] {
return true
}
<% end -%>

return false
}
Expand Down
2 changes: 0 additions & 2 deletions mmv1/third_party/validator/compute_instance.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ func expandComputeInstance(project string, d TerraformResourceData, config *Conf
AutomaticRestart: googleapi.Bool(d.Get(prefix + ".automatic_restart").(bool)),
Preemptible: d.Get(prefix + ".preemptible").(bool),
OnHostMaintenance: d.Get(prefix + ".on_host_maintenance").(string),
<% unless version == 'ga' -%>
ProvisioningModel: d.Get(prefix + ".provisioning_model").(string),
<% end -%>
ForceSendFields: []string{"AutomaticRestart", "Preemptible"},
}
}
Expand Down