-
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
Changed google_compute_instance_group_manager target_size default to 0. #65
Changed google_compute_instance_group_manager target_size default to 0. #65
Conversation
Related: hashicorp/terraform#5694 tracks the ability to both have a default of 1 + allow 0 values for this field. |
@@ -256,7 +256,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) |
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.
This was removed because it could change with the autoscaler, right? If so mind adding a comment of that nature?
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 was getting set twice before, the other d.Set is just out of view here.
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.
boooo github
@@ -132,18 +132,18 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte | |||
return err | |||
} | |||
|
|||
// Get group size, default to 1 if not given | |||
var target_size int64 = 1 | |||
var targetSize int64 = 0 |
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.
targetSize := 0
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.
Go is convinced this is an int
, not int64
with that syntax; using targetSize := int64(0)
} | ||
|
||
// Build the parameter | ||
manager := &compute.InstanceGroupManager{ | ||
Name: d.Get("name").(string), | ||
BaseInstanceName: d.Get("base_instance_name").(string), | ||
InstanceTemplate: d.Get("instance_template").(string), | ||
TargetSize: target_size, | ||
TargetSize: targetSize, | ||
ForceSendFields: []string{"TargetSize"}, |
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.
might be nice to have a comment here like "Force send TargetSize to allow it to have a value of 0"
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.
@@ -382,23 +381,19 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte | |||
d.SetPartial("named_port") | |||
} | |||
|
|||
// If size changes trigger a resize | |||
// We won't ever see changes if target_size is unset |
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.
I'm not quite sure what this comment is trying to tell me
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.
Removed.
if err != nil { | ||
return fmt.Errorf("Error updating InstanceGroupManager: %s", err) | ||
} | ||
target_size := int64(d.Get("target_size").(int)) |
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.
targetSize
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.
func TestAccInstanceGroupManager_targetSizeZero(t *testing.T) { | ||
var manager compute.InstanceGroupManager | ||
|
||
template := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) |
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.
optional nit: templateName, igmName
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.
* `target_size` - (Optional) If not given at creation time, this defaults to 1. | ||
Do not specify this if you are managing the group with an autoscaler, as | ||
this will cause fighting. | ||
* `target_size` - (Optional, Default `0`) The target number of running instances for this managed |
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.
Do we normally put the default in that spot? I don't necessarily have a problem with it, but I think normally we just put it in the description.
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 use that style in a few places, I think I happened to have seen one of those right before writing this. Updated.
|
…nager-target-size Changed google_compute_instance_group_manager target_size default to 0.
…nager-target-size Changed google_compute_instance_group_manager target_size default to 0.
Fix typo in resource name, same as TPG hashicorp#2365
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! |
Set the default target_size to 0 so that target sizes of 0 don't get set as the old default of 1. Existing configurations won't change as a result of changing the default, since the field is computed.
This is not a breaking change for existing configurations; resources with no value set will stay at their current setting. Scripts that rely on the old default of 1 at creation time will need to be updated.
Fixes #13
@danawillow