Skip to content

Commit

Permalink
kubetest2-kops: rename control-plane-size flag to control-plane-count
Browse files Browse the repository at this point in the history
For consistency with kops create cluster.

It doesn't appear to be used outside this repo, although test-infra
declares KOPS_CONTROL_PLANE_SIZE and that is then passed to our
e2e/scenarios scripts.

Issue #15559
  • Loading branch information
justinsb committed Jul 19, 2023
1 parent 59ced8c commit 7352f30
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/kubetest2-kops/deployer/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ func (d *deployer) verifyKopsFlags() error {
return errors.New("missing required --kops-binary-path when --kops-version-marker is not used")
}

if d.ControlPlaneSize == 0 {
d.ControlPlaneSize = 1
if d.ControlPlaneCount == 0 {
d.ControlPlaneCount = 1
}

switch d.CloudProvider {
Expand Down
29 changes: 21 additions & 8 deletions tests/e2e/kubetest2-kops/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ type deployer struct {
KopsBaseURL string `flag:"-"`
PublishVersionMarker string `flag:"publish-version-marker" desc:"The GCS path to which the --kops-version-marker is uploaded if the tests pass"`

ClusterName string `flag:"cluster-name" desc:"The FQDN to use for the cluster name"`
ControlPlaneSize int `flag:"control-plane-size" desc:"Number of control plane instances"`
CloudProvider string `flag:"cloud-provider" desc:"Which cloud provider to use"`
GCPProject string `flag:"gcp-project" desc:"Which GCP Project to use when --cloud-provider=gce"`
Env []string `flag:"env" desc:"Additional env vars to set for kops commands in NAME=VALUE format"`
CreateArgs string `flag:"create-args" desc:"Extra space-separated arguments passed to 'kops create cluster'"`
KopsBinaryPath string `flag:"kops-binary-path" desc:"The path to kops executable used for testing"`
createBucket bool `flag:"-"`
ClusterName string `flag:"cluster-name" desc:"The FQDN to use for the cluster name"`
CloudProvider string `flag:"cloud-provider" desc:"Which cloud provider to use"`
GCPProject string `flag:"gcp-project" desc:"Which GCP Project to use when --cloud-provider=gce"`
Env []string `flag:"env" desc:"Additional env vars to set for kops commands in NAME=VALUE format"`
CreateArgs string `flag:"create-args" desc:"Extra space-separated arguments passed to 'kops create cluster'"`
KopsBinaryPath string `flag:"kops-binary-path" desc:"The path to kops executable used for testing"`
createBucket bool `flag:"-"`

// ControlPlaneCount specifies the number of VMs in the control-plane.
ControlPlaneCount int `flag:"control-plane-count" desc:"Number of control plane instances"`

ControlPlaneIGOverrides []string `flag:"control-plane-instance-group-overrides" desc:"overrides for the control plane instance groups"`
NodeIGOverrides []string `flag:"node-instance-group-overrides" desc:"overrides for the node instance groups"`
Expand Down Expand Up @@ -123,6 +125,17 @@ func New(opts types.Options) (types.Deployer, *pflag.FlagSet) {
// register flags for klog
klog.InitFlags(nil)
fs.AddGoFlagSet(flag.CommandLine)

// Map deprecated flag names to their new names
fs.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
switch name {
case "control-plane-size":
klog.Warningf("deprecated --control-plane-size specified; please use --control-plane-count instead")
name = "control-plane-count"
}
return pflag.NormalizedName(name)
})

return d, fs
}

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/kubetest2-kops/deployer/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) e
args = append(args, createArgs...)
}
args = appendIfUnset(args, "--admin-access", adminAccess)
args = appendIfUnset(args, "--master-count", fmt.Sprintf("%d", d.ControlPlaneSize))
args = appendIfUnset(args, "--control-plane-count", fmt.Sprintf("%d", d.ControlPlaneCount))
args = appendIfUnset(args, "--master-volume-size", "48")
args = appendIfUnset(args, "--node-count", "4")
args = appendIfUnset(args, "--node-volume-size", "48")
Expand Down Expand Up @@ -284,7 +284,7 @@ func (d *deployer) verifyUpFlags() error {
func (d *deployer) zones() ([]string, error) {
switch d.CloudProvider {
case "aws":
return aws.RandomZones(d.ControlPlaneSize)
return aws.RandomZones(d.ControlPlaneCount)
case "gce":
return gce.RandomZones(1)
case "digitalocean":
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/scenarios/upgrade-ab/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ${KUBETEST2} \
--up \
--kops-binary-path="${KOPS_A}" \
--kubernetes-version="${K8S_VERSION_A}" \
--control-plane-size="${KOPS_CONTROL_PLANE_SIZE:-1}" \
--control-plane-count="${KOPS_CONTROL_PLANE_SIZE:-1}" \
--template-path="${KOPS_TEMPLATE:-}" \
--create-args="--networking calico ${KOPS_EXTRA_FLAGS:-} ${create_args}"

Expand Down

0 comments on commit 7352f30

Please sign in to comment.