Skip to content

Commit 40eed60

Browse files
author
Todd Lyons
committedDec 28, 2017
Interactive cli arg framework
Just builds, haven't tested yet.
1 parent 96bff22 commit 40eed60

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
 

‎cmd/kops/rollingupdatecluster.go

+6
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ type RollingUpdateOptions struct {
129129
// BastionInterval is the minimum time to wait after stopping a bastion. This does not include drain and validate time.
130130
BastionInterval time.Duration
131131

132+
// Interactive rolling-update prompts user to continue after each instances is updated.
133+
Interactive bool
134+
132135
ClusterName string
133136

134137
// InstanceGroups is the list of instance groups to rolling-update;
@@ -146,6 +149,7 @@ func (o *RollingUpdateOptions) InitDefaults() {
146149
o.MasterInterval = 5 * time.Minute
147150
o.NodeInterval = 4 * time.Minute
148151
o.BastionInterval = 5 * time.Minute
152+
o.Interactive = false
149153

150154
o.PostDrainDelay = 90 * time.Second
151155
o.ValidationTimeout = 5 * time.Minute
@@ -171,6 +175,7 @@ func NewCmdRollingUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command {
171175
cmd.Flags().DurationVar(&options.MasterInterval, "master-interval", options.MasterInterval, "Time to wait between restarting masters")
172176
cmd.Flags().DurationVar(&options.NodeInterval, "node-interval", options.NodeInterval, "Time to wait between restarting nodes")
173177
cmd.Flags().DurationVar(&options.BastionInterval, "bastion-interval", options.BastionInterval, "Time to wait between restarting bastions")
178+
cmd.Flags().BoolVarP(&options.Interactive, "interactive", "i", options.Interactive, "Prompt to continue after each instance is updated")
174179
cmd.Flags().StringSliceVar(&options.InstanceGroups, "instance-group", options.InstanceGroups, "List of instance groups to update (defaults to all if not specified)")
175180

176181
if featureflag.DrainAndValidateRollingUpdate.Enabled() {
@@ -363,6 +368,7 @@ func RunRollingUpdateCluster(f *util.Factory, out io.Writer, options *RollingUpd
363368
MasterInterval: options.MasterInterval,
364369
NodeInterval: options.NodeInterval,
365370
BastionInterval: options.BastionInterval,
371+
Interactive: options.Interactive,
366372
Force: options.Force,
367373
Cloud: cloud,
368374
K8sClient: k8sClient,

‎pkg/instancegroups/instancegroups.go

+9
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ func NewRollingUpdateInstanceGroup(cloud fi.Cloud, cloudGroup *cloudinstances.Cl
6565
}, nil
6666
}
6767

68+
func PromptInteractive(upgradedHost string) {
69+
glog.Infof("Pausing after finished %q", upgradedHost)
70+
return
71+
}
72+
6873
// TODO: Temporarily increase size of ASG?
6974
// TODO: Remove from ASG first so status is immediately updated?
7075
// TODO: Batch termination, like a rolling-update
@@ -169,6 +174,9 @@ func (r *RollingUpdateInstanceGroup) RollingUpdate(rollingUpdateData *RollingUpd
169174

170175
glog.Warningf("Cluster validation failed after removing instance, proceeding since fail-on-validate is set to false: %v", err)
171176
}
177+
if rollingUpdateData.Interactive {
178+
PromptInteractive(nodeName)
179+
}
172180
}
173181
}
174182

@@ -247,6 +255,7 @@ func (r *RollingUpdateInstanceGroup) DeleteInstance(u *cloudinstances.CloudInsta
247255
}
248256
}
249257

258+
nodeName = u.Node.Name
250259
return nil
251260

252261
}

‎pkg/instancegroups/rollingupdate.go

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ type RollingUpdateCluster struct {
3939
NodeInterval time.Duration
4040
// BastionInterval is the amount of time to wait after stopping a bastion instance
4141
BastionInterval time.Duration
42+
// Interactive prompts user to continue after each instance is updated
43+
Interactive bool
4244

4345
Force bool
4446

0 commit comments

Comments
 (0)
Please sign in to comment.