From 11eaacd53ec6b4c26b0535a9434fd61b7399c420 Mon Sep 17 00:00:00 2001 From: Jesse Haka Date: Wed, 8 Apr 2020 13:52:25 +0300 Subject: [PATCH] validationtimes -> validationcount --- cmd/kops/rollingupdatecluster.go | 10 +++++----- docs/cli/kops_rolling-update_cluster.md | 2 +- pkg/instancegroups/instancegroups.go | 6 +++--- pkg/instancegroups/rollingupdate.go | 4 ++-- pkg/instancegroups/rollingupdate_test.go | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/kops/rollingupdatecluster.go b/cmd/kops/rollingupdatecluster.go index dc4770965d..321f2faf54 100644 --- a/cmd/kops/rollingupdatecluster.go +++ b/cmd/kops/rollingupdatecluster.go @@ -121,8 +121,8 @@ type RollingUpdateOptions struct { // ValidationTimeout is the timeout for validation to succeed after the drain and pause ValidationTimeout time.Duration - // ValidateTimes is the amount of time that a cluster needs to be validated after single node update - ValidateTimes int32 + // ValidateCount is the amount of time that a cluster needs to be validated after single node update + ValidateCount int32 // MasterInterval is the minimum time to wait after stopping a master node. This does not include drain and validate time. MasterInterval time.Duration @@ -161,7 +161,7 @@ func (o *RollingUpdateOptions) InitDefaults() { o.PostDrainDelay = 5 * time.Second o.ValidationTimeout = 15 * time.Minute - o.ValidateTimes = 2 + o.ValidateCount = 2 } func NewCmdRollingUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command { @@ -181,7 +181,7 @@ func NewCmdRollingUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command { cmd.Flags().BoolVar(&options.CloudOnly, "cloudonly", options.CloudOnly, "Perform rolling update without confirming progress with k8s") cmd.Flags().DurationVar(&options.ValidationTimeout, "validation-timeout", options.ValidationTimeout, "Maximum time to wait for a cluster to validate") - cmd.Flags().Int32Var(&options.ValidateTimes, "validate-times", options.ValidateTimes, "Amount of times that a cluster needs to be validated after single node update") + cmd.Flags().Int32Var(&options.ValidateCount, "validate-count", options.ValidateCount, "Amount of times that a cluster needs to be validated after single node update") cmd.Flags().DurationVar(&options.MasterInterval, "master-interval", options.MasterInterval, "Time to wait between restarting masters") cmd.Flags().DurationVar(&options.NodeInterval, "node-interval", options.NodeInterval, "Time to wait between restarting nodes") cmd.Flags().DurationVar(&options.BastionInterval, "bastion-interval", options.BastionInterval, "Time to wait between restarting bastions") @@ -338,7 +338,7 @@ func RunRollingUpdateCluster(f *util.Factory, out io.Writer, options *RollingUpd ClusterName: options.ClusterName, PostDrainDelay: options.PostDrainDelay, ValidationTimeout: options.ValidationTimeout, - ValidateTimes: options.ValidateTimes, + ValidateCount: options.ValidateCount, ValidateSucceeded: 0, // TODO should we expose this to the UI? ValidateTickDuration: 30 * time.Second, diff --git a/docs/cli/kops_rolling-update_cluster.md b/docs/cli/kops_rolling-update_cluster.md index 2f868030b4..06724f3e57 100644 --- a/docs/cli/kops_rolling-update_cluster.md +++ b/docs/cli/kops_rolling-update_cluster.md @@ -80,7 +80,7 @@ kops rolling-update cluster [flags] --master-interval duration Time to wait between restarting masters (default 15s) --node-interval duration Time to wait between restarting nodes (default 15s) --post-drain-delay duration Time to wait after draining each node (default 5s) - --validate-times int32 Amount of times that a cluster needs to be validated after single node update (default 2) + --validate-count int32 Amount of times that a cluster needs to be validated after single node update (default 2) --validation-timeout duration Maximum time to wait for a cluster to validate (default 15m0s) -y, --yes Perform rolling update immediately, without --yes rolling-update executes a dry-run ``` diff --git a/pkg/instancegroups/instancegroups.go b/pkg/instancegroups/instancegroups.go index 077c1849c4..e247690047 100644 --- a/pkg/instancegroups/instancegroups.go +++ b/pkg/instancegroups/instancegroups.go @@ -430,10 +430,10 @@ func (c *RollingUpdateCluster) validateClusterWithDuration(duration time.Duratio func (c *RollingUpdateCluster) tryValidateCluster(duration time.Duration) bool { result, err := c.ClusterValidator.Validate() - if err == nil && len(result.Failures) == 0 && c.ValidateTimes > 0 { + if err == nil && len(result.Failures) == 0 && c.ValidateCount > 0 { c.ValidateSucceeded++ - if c.ValidateSucceeded < c.ValidateTimes { - klog.Infof("Cluster validated; revalidating %d time(s) to make sure it does not flap.", c.ValidateTimes-c.ValidateSucceeded) + if c.ValidateSucceeded < c.ValidateCount { + klog.Infof("Cluster validated; revalidating %d time(s) to make sure it does not flap.", c.ValidateCount-c.ValidateSucceeded) return false } } diff --git a/pkg/instancegroups/rollingupdate.go b/pkg/instancegroups/rollingupdate.go index 1ca4332261..6484366d2a 100644 --- a/pkg/instancegroups/rollingupdate.go +++ b/pkg/instancegroups/rollingupdate.go @@ -64,8 +64,8 @@ type RollingUpdateCluster struct { // ValidateTickDuration is the amount of time to wait between cluster validation attempts ValidateTickDuration time.Duration - // ValidateTimes is the amount of time that a cluster needs to be validated after single node update - ValidateTimes int32 + // ValidateCount is the amount of time that a cluster needs to be validated after single node update + ValidateCount int32 // ValidateSucceeded is the amount of times that a cluster validate is succeeded already ValidateSucceeded int32 diff --git a/pkg/instancegroups/rollingupdate_test.go b/pkg/instancegroups/rollingupdate_test.go index 2f905efd7d..8a24bc03ce 100644 --- a/pkg/instancegroups/rollingupdate_test.go +++ b/pkg/instancegroups/rollingupdate_test.go @@ -68,7 +68,7 @@ func getTestSetup() (*RollingUpdateCluster, *awsup.MockAWSCloud, *kopsapi.Cluste ClusterValidator: &successfulClusterValidator{}, FailOnValidate: true, ValidateTickDuration: 1 * time.Millisecond, - ValidateTimes: 1, + ValidateCount: 1, ValidateSucceeded: 0, } @@ -512,7 +512,7 @@ func (v *flappingClusterValidator) Validate() (*validation.ValidationCluster, er func TestRollingUpdateFlappingValidation(t *testing.T) { c, cloud, cluster := getTestSetup() - c.ValidateTimes = 3 + c.ValidateCount = 3 // This should only take a few milliseconds, // but we have to pad to allow for random delays (e.g. GC)