Skip to content

Commit b43c9cb

Browse files
committed
Add required MinimalAction parameter to UpdatePolicy
1 parent 407fb1f commit b43c9cb

File tree

12 files changed

+58
-28
lines changed

12 files changed

+58
-28
lines changed

pkg/model/gcemodel/autoscalinggroup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e
313313
Lifecycle: b.Lifecycle,
314314
Zone: s(zone),
315315
TargetSize: fi.PtrTo(int64(targetSize)),
316-
UpdatePolicy: &gcetasks.UpdatePolicy{Type: "OPPORTUNISTIC"},
316+
UpdatePolicy: &gcetasks.UpdatePolicy{MinimalAction: "REPLACE", Type: "OPPORTUNISTIC"},
317317
BaseInstanceName: s(ig.ObjectMeta.Name),
318318
InstanceTemplate: instanceTemplate,
319319
ListManagedInstancesResults: "PAGINATED",

tests/integration/update_cluster/ha_gce/kubernetes.tf

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-ha-gce-exa
498498
name = "a-master-us-test1-a-ha-gce-example-com"
499499
target_size = 1
500500
update_policy {
501-
type = "OPPORTUNISTIC"
501+
minimal_action = "REPLACE"
502+
type = "OPPORTUNISTIC"
502503
}
503504
version {
504505
instance_template = google_compute_instance_template.master-us-test1-a-ha-gce-example-com.self_link
@@ -512,7 +513,8 @@ resource "google_compute_instance_group_manager" "a-nodes-ha-gce-example-com" {
512513
name = "a-nodes-ha-gce-example-com"
513514
target_size = 1
514515
update_policy {
515-
type = "OPPORTUNISTIC"
516+
minimal_action = "REPLACE"
517+
type = "OPPORTUNISTIC"
516518
}
517519
version {
518520
instance_template = google_compute_instance_template.nodes-ha-gce-example-com.self_link
@@ -526,7 +528,8 @@ resource "google_compute_instance_group_manager" "b-master-us-test1-b-ha-gce-exa
526528
name = "b-master-us-test1-b-ha-gce-example-com"
527529
target_size = 1
528530
update_policy {
529-
type = "OPPORTUNISTIC"
531+
minimal_action = "REPLACE"
532+
type = "OPPORTUNISTIC"
530533
}
531534
version {
532535
instance_template = google_compute_instance_template.master-us-test1-b-ha-gce-example-com.self_link
@@ -540,7 +543,8 @@ resource "google_compute_instance_group_manager" "b-nodes-ha-gce-example-com" {
540543
name = "b-nodes-ha-gce-example-com"
541544
target_size = 1
542545
update_policy {
543-
type = "OPPORTUNISTIC"
546+
minimal_action = "REPLACE"
547+
type = "OPPORTUNISTIC"
544548
}
545549
version {
546550
instance_template = google_compute_instance_template.nodes-ha-gce-example-com.self_link
@@ -554,7 +558,8 @@ resource "google_compute_instance_group_manager" "c-master-us-test1-c-ha-gce-exa
554558
name = "c-master-us-test1-c-ha-gce-example-com"
555559
target_size = 1
556560
update_policy {
557-
type = "OPPORTUNISTIC"
561+
minimal_action = "REPLACE"
562+
type = "OPPORTUNISTIC"
558563
}
559564
version {
560565
instance_template = google_compute_instance_template.master-us-test1-c-ha-gce-example-com.self_link
@@ -568,7 +573,8 @@ resource "google_compute_instance_group_manager" "c-nodes-ha-gce-example-com" {
568573
name = "c-nodes-ha-gce-example-com"
569574
target_size = 0
570575
update_policy {
571-
type = "OPPORTUNISTIC"
576+
minimal_action = "REPLACE"
577+
type = "OPPORTUNISTIC"
572578
}
573579
version {
574580
instance_template = google_compute_instance_template.nodes-ha-gce-example-com.self_link

tests/integration/update_cluster/many-addons-gce/kubernetes.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-ex
426426
name = "a-master-us-test1-a-minimal-example-com"
427427
target_size = 1
428428
update_policy {
429-
type = "OPPORTUNISTIC"
429+
minimal_action = "REPLACE"
430+
type = "OPPORTUNISTIC"
430431
}
431432
version {
432433
instance_template = google_compute_instance_template.master-us-test1-a-minimal-example-com.self_link
@@ -440,7 +441,8 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-example-com" {
440441
name = "a-nodes-minimal-example-com"
441442
target_size = 1
442443
update_policy {
443-
type = "OPPORTUNISTIC"
444+
minimal_action = "REPLACE"
445+
type = "OPPORTUNISTIC"
444446
}
445447
version {
446448
instance_template = google_compute_instance_template.nodes-minimal-example-com.self_link

tests/integration/update_cluster/minimal_gce/kubernetes.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
402402
name = "a-master-us-test1-a-minimal-gce-example-com"
403403
target_size = 1
404404
update_policy {
405-
type = "OPPORTUNISTIC"
405+
minimal_action = "REPLACE"
406+
type = "OPPORTUNISTIC"
406407
}
407408
version {
408409
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-example-com.self_link
@@ -416,7 +417,8 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-example-co
416417
name = "a-nodes-minimal-gce-example-com"
417418
target_size = 2
418419
update_policy {
419-
type = "OPPORTUNISTIC"
420+
minimal_action = "REPLACE"
421+
type = "OPPORTUNISTIC"
420422
}
421423
version {
422424
instance_template = google_compute_instance_template.nodes-minimal-gce-example-com.self_link

tests/integration/update_cluster/minimal_gce_dns-none/kubernetes.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
466466
name = "a-master-us-test1-a-minimal-gce-example-com"
467467
target_size = 1
468468
update_policy {
469-
type = "OPPORTUNISTIC"
469+
minimal_action = "REPLACE"
470+
type = "OPPORTUNISTIC"
470471
}
471472
version {
472473
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-example-com.self_link
@@ -480,7 +481,8 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-example-co
480481
name = "a-nodes-minimal-gce-example-com"
481482
target_size = 2
482483
update_policy {
483-
type = "OPPORTUNISTIC"
484+
minimal_action = "REPLACE"
485+
type = "OPPORTUNISTIC"
484486
}
485487
version {
486488
instance_template = google_compute_instance_template.nodes-minimal-gce-example-com.self_link

tests/integration/update_cluster/minimal_gce_ilb/kubernetes.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
435435
name = "a-master-us-test1-a-minimal-gce-ilb-example-com"
436436
target_size = 1
437437
update_policy {
438-
type = "OPPORTUNISTIC"
438+
minimal_action = "REPLACE"
439+
type = "OPPORTUNISTIC"
439440
}
440441
version {
441442
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-ilb-example-com.self_link
@@ -449,7 +450,8 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-ilb-exampl
449450
name = "a-nodes-minimal-gce-ilb-example-com"
450451
target_size = 2
451452
update_policy {
452-
type = "OPPORTUNISTIC"
453+
minimal_action = "REPLACE"
454+
type = "OPPORTUNISTIC"
453455
}
454456
version {
455457
instance_template = google_compute_instance_template.nodes-minimal-gce-ilb-example-com.self_link

tests/integration/update_cluster/minimal_gce_ilb_longclustername/kubernetes.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
435435
name = "a-master-us-test1-a-minimal-gce-with-a-very-very-very-ve-j0fh8f"
436436
target_size = 1
437437
update_policy {
438-
type = "OPPORTUNISTIC"
438+
minimal_action = "REPLACE"
439+
type = "OPPORTUNISTIC"
439440
}
440441
version {
441442
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-with-a-very-very-very-very-very-long-name-example-com.self_link
@@ -449,7 +450,8 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-with-a-ver
449450
name = "a-nodes-minimal-gce-with-a-very-very-very-very-very-long-qk78uj"
450451
target_size = 2
451452
update_policy {
452-
type = "OPPORTUNISTIC"
453+
minimal_action = "REPLACE"
454+
type = "OPPORTUNISTIC"
453455
}
454456
version {
455457
instance_template = google_compute_instance_template.nodes-minimal-gce-with-a-very-very-very-very-very-long-name-example-com.self_link

tests/integration/update_cluster/minimal_gce_longclustername/kubernetes.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
402402
name = "a-master-us-test1-a-minimal-gce-with-a-very-very-very-ve-j0fh8f"
403403
target_size = 1
404404
update_policy {
405-
type = "OPPORTUNISTIC"
405+
minimal_action = "REPLACE"
406+
type = "OPPORTUNISTIC"
406407
}
407408
version {
408409
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-with-a-very-very-very-very-very-long-name-example-com.self_link
@@ -416,7 +417,8 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-with-a-ver
416417
name = "a-nodes-minimal-gce-with-a-very-very-very-very-very-long-qk78uj"
417418
target_size = 2
418419
update_policy {
419-
type = "OPPORTUNISTIC"
420+
minimal_action = "REPLACE"
421+
type = "OPPORTUNISTIC"
420422
}
421423
version {
422424
instance_template = google_compute_instance_template.nodes-minimal-gce-with-a-very-very-very-very-very-long-name-example-com.self_link

tests/integration/update_cluster/minimal_gce_plb/kubernetes.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
459459
target_pools = [google_compute_target_pool.api-minimal-gce-plb-example-com.self_link]
460460
target_size = 1
461461
update_policy {
462-
type = "OPPORTUNISTIC"
462+
minimal_action = "REPLACE"
463+
type = "OPPORTUNISTIC"
463464
}
464465
version {
465466
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-plb-example-com.self_link
@@ -473,7 +474,8 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-plb-exampl
473474
name = "a-nodes-minimal-gce-plb-example-com"
474475
target_size = 2
475476
update_policy {
476-
type = "OPPORTUNISTIC"
477+
minimal_action = "REPLACE"
478+
type = "OPPORTUNISTIC"
477479
}
478480
version {
479481
instance_template = google_compute_instance_template.nodes-minimal-gce-plb-example-com.self_link

tests/integration/update_cluster/minimal_gce_private/kubernetes.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
402402
name = "a-master-us-test1-a-minimal-gce-private-example-com"
403403
target_size = 1
404404
update_policy {
405-
type = "OPPORTUNISTIC"
405+
minimal_action = "REPLACE"
406+
type = "OPPORTUNISTIC"
406407
}
407408
version {
408409
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-private-example-com.self_link
@@ -416,7 +417,8 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-private-ex
416417
name = "a-nodes-minimal-gce-private-example-com"
417418
target_size = 2
418419
update_policy {
419-
type = "OPPORTUNISTIC"
420+
minimal_action = "REPLACE"
421+
type = "OPPORTUNISTIC"
420422
}
421423
version {
422424
instance_template = google_compute_instance_template.nodes-minimal-gce-private-example-com.self_link

upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (e *InstanceGroupManager) Find(c *fi.CloudupContext) (*InstanceGroupManager
6464
actual.Zone = fi.PtrTo(lastComponent(r.Zone))
6565
actual.BaseInstanceName = &r.BaseInstanceName
6666
actual.TargetSize = &r.TargetSize
67-
actual.UpdatePolicy = &UpdatePolicy{Type: r.UpdatePolicy.Type}
67+
actual.UpdatePolicy = &UpdatePolicy{MinimalAction: r.UpdatePolicy.MinimalAction, Type: r.UpdatePolicy.Type}
6868
actual.InstanceTemplate = &InstanceTemplate{ID: fi.PtrTo(lastComponent(r.InstanceTemplate))}
6969
actual.ListManagedInstancesResults = r.ListManagedInstancesResults
7070

@@ -97,12 +97,17 @@ func (_ *InstanceGroupManager) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Ins
9797
return err
9898
}
9999

100+
updatePolicy := &compute.InstanceGroupManagerUpdatePolicy{
101+
MinimalAction: e.UpdatePolicy.MinimalAction,
102+
Type: e.UpdatePolicy.Type,
103+
}
104+
100105
i := &compute.InstanceGroupManager{
101106
Name: *e.Name,
102107
Zone: *e.Zone,
103108
BaseInstanceName: *e.BaseInstanceName,
104109
TargetSize: *e.TargetSize,
105-
UpdatePolicy: &compute.InstanceGroupManagerUpdatePolicy{Type: e.UpdatePolicy.Type},
110+
UpdatePolicy: updatePolicy,
106111
InstanceTemplate: instanceTemplateURL,
107112
ListManagedInstancesResults: e.ListManagedInstancesResults,
108113
}
@@ -189,7 +194,8 @@ type terraformInstanceGroupManager struct {
189194
}
190195

191196
type terraformUpdatePolicy struct {
192-
Type string `cty:"type"`
197+
MinimalAction string `cty:"minimal_action"`
198+
Type string `cty:"type"`
193199
}
194200

195201
type terraformVersion struct {
@@ -205,7 +211,8 @@ func (_ *InstanceGroupManager) RenderTerraform(t *terraform.TerraformTarget, a,
205211
ListManagedInstancesResults: e.ListManagedInstancesResults,
206212
}
207213
tf.UpdatePolicy = &terraformUpdatePolicy{
208-
Type: e.UpdatePolicy.Type,
214+
MinimalAction: e.UpdatePolicy.MinimalAction,
215+
Type: e.UpdatePolicy.Type,
209216
}
210217
tf.Version = &terraformVersion{
211218
InstanceTemplate: e.InstanceTemplate.TerraformLink(),

upup/pkg/fi/cloudup/gcetasks/updatepolicy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import "k8s.io/kops/upup/pkg/fi"
2020

2121
// UpdatePolicy represents a GCE instance group manager UpdatePolicy
2222
type UpdatePolicy struct {
23-
Type string
23+
MinimalAction string
24+
Type string
2425
}
2526

2627
var _ fi.CloudupHasDependencies = &UpdatePolicy{}

0 commit comments

Comments
 (0)