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

Rolling update support for instance group manager #1137

Merged
merged 3 commits into from Mar 15, 2018

Conversation

Projects
None yet
5 participants
@ishashchuk
Contributor

ishashchuk commented Feb 28, 2018

Addresses 51

Supports beta functionality for rolling updates.

When rolling_update is selected as update_strategy, it requires "rolling_update_policy" block.
I'm storing rolling_update_policy block locally, and not applying it to computeBeta.InstanceGroupManager. There is no way to make an update call for this block on the InstanceGroupManager. It is only updated when the patch call for the instances is made. That's the reason I'm storing it locally and only applying it on the update calls that are changing the instance template. That allows us to change rolling_update_policy arguments post creating InstanceGroupManager and making sure that they will be applied at the next patch call.

Once I get feedback on this, I will add similar support to region_instance_group_manager

@apenney

This comment has been minimized.

Show comment
Hide comment
@apenney

apenney Mar 1, 2018

@ishashchuk I don't have any code feedback, I just wanted to thank you for tackling this (as we'll be early adopters of it, soon as it's merged).

apenney commented Mar 1, 2018

@ishashchuk I don't have any code feedback, I just wanted to thank you for tackling this (as we'll be early adopters of it, soon as it's merged).

@amoiseiev

This comment has been minimized.

Show comment
Hide comment
@amoiseiev

amoiseiev Mar 8, 2018

@paddycarver friendly reminder :)

amoiseiev commented Mar 8, 2018

@paddycarver friendly reminder :)

@ndmckinley ndmckinley self-requested a review Mar 12, 2018

@ndmckinley

I'm storing rolling_update_policy block locally, and not applying it to computeBeta.InstanceGroupManager. There is no way to make an update call for this block on the InstanceGroupManager. It is only updated when the patch call for the instances is made. That's the reason I'm storing it locally and only applying it on the update calls that are changing the instance template.

I like this... but I wonder, what happens if someone:

  • creates the resource with RESTART
  • changes it to ROLLING_UPDATE
  • does an update
  • changes it back to RESTART
  • does another update

In that case, would this code act correctly? It seems like it wouldn't send a PATCH request to remove the strategy, but I might be off.

Show outdated Hide outdated google/resource_compute_instance_group_manager.go
@@ -184,6 +241,12 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte
return err
}
_, ok := d.GetOk("rolling_update_policy")

This comment has been minimized.

@ndmckinley

ndmckinley Mar 12, 2018

Collaborator

Nit: Seems like it'd be neater as part of the if block below.

@ndmckinley

ndmckinley Mar 12, 2018

Collaborator

Nit: Seems like it'd be neater as part of the if block below.

Show outdated Hide outdated google/resource_compute_instance_group_manager.go
@@ -380,6 +443,11 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte
d.Partial(true)
_, ok := d.GetOk("rolling_update_policy")

This comment has been minimized.

@ndmckinley

ndmckinley Mar 12, 2018

Collaborator

same comment - include in the if statement if possible.

@ndmckinley

ndmckinley Mar 12, 2018

Collaborator

same comment - include in the if statement if possible.

@ishashchuk

This comment has been minimized.

Show comment
Hide comment
@ishashchuk

ishashchuk Mar 13, 2018

Contributor

I like this... but I wonder, what happens if someone:

  • creates the resource with RESTART
  • changes it to ROLLING_UPDATE
  • does an update
  • changes it back to RESTART
  • does another update

In that case, would this code act correctly? It seems like it wouldn't send a PATCH request to remove the strategy, but I might be off.

@ndmckinley
There is no need to remove the strategy, since it only matters on PATCH requests. PATCH request is using a different API endpoint(clientComputeBeta.InstanceGroupManagers.Patch) and is only used when the resource is set to ROLLING_UPDATE. And we will always get the most up-to-date strategy from the config, because we are passing it explicitly on template change

When resource is set to RESTART, config.clientCompute.InstanceGroupManagers.RecreateInstances is used and that endpoint doesn't care about update_strategy attributes. It reboots all the machines at the same time.

Contributor

ishashchuk commented Mar 13, 2018

I like this... but I wonder, what happens if someone:

  • creates the resource with RESTART
  • changes it to ROLLING_UPDATE
  • does an update
  • changes it back to RESTART
  • does another update

In that case, would this code act correctly? It seems like it wouldn't send a PATCH request to remove the strategy, but I might be off.

@ndmckinley
There is no need to remove the strategy, since it only matters on PATCH requests. PATCH request is using a different API endpoint(clientComputeBeta.InstanceGroupManagers.Patch) and is only used when the resource is set to ROLLING_UPDATE. And we will always get the most up-to-date strategy from the config, because we are passing it explicitly on template change

When resource is set to RESTART, config.clientCompute.InstanceGroupManagers.RecreateInstances is used and that endpoint doesn't care about update_strategy attributes. It reboots all the machines at the same time.

@ndmckinley

This comment has been minimized.

Show comment
Hide comment
@ndmckinley

ndmckinley Mar 13, 2018

Collaborator

Ah! That's quite nice, then, neat trick. I think (but am not 100% sure) that I'd like it to be set during Create as well as during Update, then, because in the event that someone creates a resource with Terraform then runs a ROLLING_UPDATE manually or using some other tool, I think the most sensible behavior is to default to what they specified in Terraform. Does that seem right to you?

Collaborator

ndmckinley commented Mar 13, 2018

Ah! That's quite nice, then, neat trick. I think (but am not 100% sure) that I'd like it to be set during Create as well as during Update, then, because in the event that someone creates a resource with Terraform then runs a ROLLING_UPDATE manually or using some other tool, I think the most sensible behavior is to default to what they specified in Terraform. Does that seem right to you?

@ishashchuk

This comment has been minimized.

Show comment
Hide comment
@ishashchuk

ishashchuk Mar 14, 2018

Contributor

@ndmckinley
I don't think there is much value in setting update_strategy on CREATE, because most of the tools are either expect the user to provide those values, or use their own defaults.

In UI, the values for ROLLING RESTART/REPLACE are pre-populated with defaults, which means that the values instantiated on terraform create won't be respected

Running gcloud beta compute instance-groups managed rolling-action without specifying strategy, use their own defaults too without respecting anything that was previously set on instance manager

Contributor

ishashchuk commented Mar 14, 2018

@ndmckinley
I don't think there is much value in setting update_strategy on CREATE, because most of the tools are either expect the user to provide those values, or use their own defaults.

In UI, the values for ROLLING RESTART/REPLACE are pre-populated with defaults, which means that the values instantiated on terraform create won't be respected

Running gcloud beta compute instance-groups managed rolling-action without specifying strategy, use their own defaults too without respecting anything that was previously set on instance manager

@ndmckinley

This comment has been minimized.

Show comment
Hide comment
@ndmckinley

ndmckinley Mar 14, 2018

Collaborator

Fair enough - can you add a comment to that effect? Just that and I'll be ready to merge.

Collaborator

ndmckinley commented Mar 14, 2018

Fair enough - can you add a comment to that effect? Just that and I'll be ready to merge.

@ishashchuk

This comment has been minimized.

Show comment
Hide comment
@ishashchuk

ishashchuk Mar 15, 2018

Contributor

Should be good to go

Contributor

ishashchuk commented Mar 15, 2018

Should be good to go

@ndmckinley

This comment has been minimized.

Show comment
Hide comment
@ndmckinley

ndmckinley Mar 15, 2018

Collaborator

Perfect. I'm running the tests now, and I expect to merge in an hour or so assuming no problems.

Collaborator

ndmckinley commented Mar 15, 2018

Perfect. I'm running the tests now, and I expect to merge in an hour or so assuming no problems.

@ndmckinley ndmckinley merged commit 14f1431 into terraform-providers:master Mar 15, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

ashish-amarnath pushed a commit to ashish-amarnath/terraform-provider-google that referenced this pull request Mar 20, 2018

@ishashchuk ishashchuk deleted the wayfair:ishashchuk_rollingRestarts branch Mar 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment