Sitelet https://github.com/kubernetes/kops/pull/18463
Skip to content

e2e: Filter random AZ selection by instance type availability - #18463

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
rifelpet:random-zone-instance-type
Jun 12, 2026
Merged

k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
rifelpet:random-zone-instance-type

Conversation

@rifelpet

@rifelpet rifelpet commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

currently kubetest2-kops selects random AWS availability zones if they aren't provided.

For many prow jobs we specify a specific zone because we want to use a specific instance type not offered in every zone:

https://github.com/search?q=repo%3Akubernetes%2Ftest-infra%20path%3Aconfig%2Fjobs%2Fkubernetes%2Fkops%2Fbuild_jobs.py%20--zones&type=code

This results in hot spots of zones, especially if the --zone flag is used in many jobs like in the grid definition. A claude analysis:

Per-zone weekly run totals across periodic jobs that pin --zones=...:

  ┌───────────────┬───────────┬─────────────────────────────────┐
  │     Zone      │ Runs/week │ # of periodic jobs contributing │
  ├───────────────┼───────────┼─────────────────────────────────┤
  │ eu-west-1a    │       924 │                             624 │
  ├───────────────┼───────────┼─────────────────────────────────┤
  │ eu-central-1a │        77 │                              11 │
  ├───────────────┼───────────┼─────────────────────────────────┤
  │ us-west-2a    │        63 │                               3 │
  ├───────────────┼───────────┼─────────────────────────────────┤
  │ eu-west-1b    │        21 │                               1 │
  ├───────────────┼───────────┼─────────────────────────────────┤
  │ eu-west-1c    │        21 │                               1 │
  ├───────────────┼───────────┼─────────────────────────────────┤
  │ us-west-1a    │        14 │                               2 │
  └───────────────┴───────────┴─────────────────────────────────┘

  Total: 1,815 runs/week across the seven zones.

  Where the volume comes from:
  - eu-west-1a (924) is dominated by the AWS grid (every arm64 × networking × k8s × kops combination = ~568 once-weekly grid jobs at 1 run/week each), plus 8 arm64 kops-aws-distro-* jobs
   × 21 + 8 arm64 kops-aws-nftables-* jobs × 21.
  - eu-central-1a (77) is kops-aws-conformance-{v} and kops-aws-conformance-arm64-{v} across 5 k8s versions × 7/week each, plus the single kops-aws-cni-cilium-k8s-ci at 7/week.
  - us-west-2a (63) — three IPv6 CNI jobs (calico/cilium/kindnet), each 21/week.
  - eu-west-1b / eu-west-1c (21 each) — the single kops-aws-ha-euwest1 3×/day job, counted once per zone in its 3-zone list.
  - us-west-1a (14) — the two terraform scenario jobs, 7/week each.

Along with a graph of EC2 instance launches in the kops prow account grouped by zone over the past week:

https://us5.datadoghq.com/s/82b785d3-4052-11f0-9c7a-f2f155245a29/vwu-qbw-ug3

Count by availability-zone over _source_amazon_auto_scaling _Launching a new

Instead of restricting jobs to one zone we can query EC2 for instance type availability in each zone and use that to filter the zone randomization.

Once this merges we can remove all of the AWS --zones usage in build_jobs.py, perhaps leaving the scale tests' zones due to quotas.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 12, 2026
@rifelpet

Copy link
Copy Markdown
Member Author

The temp commit I added should override this job's pinning to eu-central-1a:

/test pull-kops-e2e-arm64

@k8s-ci-robot
k8s-ci-robot requested review from hakman and olemarkus June 12, 2026 01:00
@rifelpet

Copy link
Copy Markdown
Member Author

The temp commit I added should override this job's pinning to eu-central-1a:

/test pull-kops-e2e-arm64

confirmed it used us-east-2a:

https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kops/18463/pull-kops-e2e-arm64/2065237745483124736

@rifelpet
rifelpet force-pushed the random-zone-instance-type branch from 327e960 to 853f979 Compare June 12, 2026 03:38
@rifelpet
rifelpet marked this pull request as ready for review June 12, 2026 03:38
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 12, 2026
@hakman hakman changed the title Filter random AZ selection by instance type availability e2e: Filter random AZ selection by instance type availability Jun 12, 2026
@ameukam

ameukam commented Jun 12, 2026

Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 12, 2026
chosenZones = append(chosenZones, chosenRegion[randIndexes[i]])
// Try regions in a random order so that a single region without the
// requested instance types does not deterministically fail.
regionOrder := rng.Perm(len(eligibleRegions))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh fancy!

// zonesWithInstanceTypes returns the subset of zones in which every one of
// instanceTypes is offered, according to DescribeInstanceTypeOfferings.
func zonesWithInstanceTypes(region string, zones []string, instanceTypes []string) ([]string, error) {
ctx := context.Background()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I always prefer adding the ctx context.Context parameter if it's a new function, but ... not a blocker

}
}

matching := make([]string, 0, len(zones))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: particularly in test code there's really no reason to bother with pre-allocation

Comment on lines +469 to +470
seen := make(map[string]bool)
var types []string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: any reason to keep both, vs just building the slice at the end?

@justinsb justinsb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 12, 2026
@k8s-ci-robot
k8s-ci-robot merged commit 0c65a74 into kubernetes:master Jun 12, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants