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

provider/google: Fixed instance group manager to allow 0 instance #13492

Closed
wants to merge 3 commits into from

Conversation

tmshn
Copy link
Contributor

@tmshn tmshn commented Apr 9, 2017

Problem solved

As pointed in #5690, even if you configure the google_compute_instance_group_manager with target_size = 0, that is ignored on the resulting resource (both on first creation or update).

This PR will fix this.

Discussion point

To fix this, I added GetOkAllowZero method to the ResourceData, which is wanted in #5694 (note: #993 is also relevant PR).
But actually, I don't understand whole code of the Terraform, so I don't know if this is the good way of achieving it.
Also, naming of the method can be questioned.

@@ -144,6 +144,7 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte
BaseInstanceName: d.Get("base_instance_name").(string),
InstanceTemplate: d.Get("instance_template").(string),
TargetSize: target_size,
ForceSendFields: []string{"Name", "BaseInstanceName", "InstanceTemplate", "TargetSize"},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is required, otherwise TargetSize: 0 will be dropped when request is made to the Google API.
See googleapis/google-api-go-client#197 for the detail.

@@ -256,7 +257,6 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf
d.Set("named_port", flattenNamedPorts(manager.NamedPorts))
d.Set("fingerprint", manager.Fingerprint)
d.Set("instance_group", manager.InstanceGroup)
d.Set("target_size", manager.TargetSize)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the duplicated line; target_size is set on the 5 lines above.


Key: "from_port",
Value: 0,
Ok: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes from GetOk.


Key: "ports",
Value: []interface{}{},
Ok: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes from GetOk.


Key: "availability_zone",
Value: "",
Ok: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes from GetOk.

@tmshn
Copy link
Contributor Author

tmshn commented Apr 19, 2017

Hello, can someone review this & #13493 pulls?

@paddycarver
Copy link
Contributor

Hey @tmshn! Thanks so much for the PR and your interest in contributing to Terraform, it's really appreciated. This is actually a long-running, complicated, and out of my depth issue. In particular, there have historically been challenges with representing unset values in diffs that make the behavior of GetOk more tricky than it first appears. For background, see #5694.

There's a lot going on this PR, and it spans two different areas of expertise (the GCP provider and the core Terraform code). Because of that, it's unlikely to get a review in its current form, just because no one person on the team has the context and domain knowledge in both those areas of the codebase to be able to give it the attention and thought it deserves.

I think the best way forward for this is:

  • I'll close this PR out.
  • Open a separate PR that just contains the core changes necessary (the schema package changes) and one of our experts in core can review it.
  • Once that's merged, use the new functionality to open a second PR containing just the stuff in the google package, which one of our GCP provider maintainers can then review.

Hopefully that sounds OK. I definitely don't want to discourage you from contributing or from trying to tackle this problem, but it's going to be hard to tackle both the provider-level changes and the schema-level changes in a single PR.

@tmshn
Copy link
Contributor Author

tmshn commented Apr 21, 2017

@paddycarver I got it, thanks for the advice! I'll open the new and smaller-scoped pull requests.

@ghost
Copy link

ghost commented Apr 13, 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 13, 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.

3 participants