Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run unit tests 2 instead of 3 times via bazel #94699

Merged
merged 1 commit into from Sep 11, 2020

Conversation

spiffxp
Copy link
Member

@spiffxp spiffxp commented Sep 10, 2020

What type of PR is this?

/kind cleanup
/kind flake

What this PR does / why we need it:

Followup to #93605 which changed from retryng 3 times to avoid flakes, to requiring a pass 3 times.

In order to migrate the pull-kubernetes-bazel-test job to a communty owned cluster with dedicated resources, we need to stop using RBE. When we did so, we started seeing many more flakes. (ref: kubernetes/test-infra#19070 (comment))

RBE fans out to a large pool of compute, whereas now we're running in a single pod on a single node.

It may be that using 2 runs instead of 3 will relieve some resource contention, giving us an appropriate compromise between not ignoring flakes but not leaning all the way into causing them. (ref: kubernetes/test-infra#19070 (comment))

Which issue(s) this PR fixes:
n/a

Special notes for your reviewer:

/hold
I'd like to see if the behavior of pull-kubernetes-bazel-test improves now that we've given it 7 CPUs instead of 4. I'm teeing this up as a further mitigation if we decide that's not enough, or if 7 CPUs is excessive resource consumption.

NONE

/cc @liggitt @BenTheElder

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/flake Categorizes issue or PR as related to a flaky test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 10, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: spiffxp

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

The pull request process is described here

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 Sep 10, 2020
@spiffxp
Copy link
Member Author

spiffxp commented Sep 10, 2020

/sig testing
/priority important-soon

@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 10, 2020
@liggitt
Copy link
Member

liggitt commented Sep 10, 2020

7 CPUs is excessive resource consumption

7 CPUs to run unit tests feels excessive. If we are not actually caching unit test results from unaffected packages and are running all tests 3 times on every PR push, then reducing to 2 runs is reasonable.

@liggitt
Copy link
Member

liggitt commented Sep 10, 2020

/lgtm

unhold at will

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 10, 2020
@BenTheElder
Copy link
Member

7 CPUs to run unit tests feels excessive. If we are not actually caching unit test results from unaffected packages and are running all tests 3 times on every PR push, then reducing to 2 runs is reasonable.

cached-ness is easily confirmed in the log output.

a line like:

//pkg/kubelet/cm/cpumanager:go_default_test PASSED in 1.1s

means we ran it. it will say something like (cached) at the end otherwise.

@spiffxp
Copy link
Member Author

spiffxp commented Sep 10, 2020

/milestone v1.20
/hold cancel
Yeah I'm going to go ahead and drop us to 2. These are graphs for the CI job, which uses 7 cpu already. They're from a local grafana instance that queries against k8s-gubernator:builds.

It's pretty easy to see when #93605 landed. Makes me wonder if the retry_flake_attempts setting was added before the move to RBE
Screen Shot 2020-09-10 at 3 55 01 PM

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 10, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Sep 10, 2020
@spiffxp
Copy link
Member Author

spiffxp commented Sep 10, 2020

(Pulling this out of slack) and yes it turns out if we run multiple times, we can't cache, unless we want to accept potentially caching failures https://docs.bazel.build/versions/master/user-manual.html#flag--cache_test_results

If this option is set to 'auto' (the default) then Bazel will only rerun a test if any of the following conditions applies:

  • Bazel detects changes in the test or its dependencies
  • the test is marked as external
  • multiple test runs were requested with --runs_per_test
  • the test failed.

If 'no', all tests will be executed unconditionally.
If 'yes', the caching behavior will be the same as auto except that it may cache test failures and test runs with --runs_per_test.

@k8s-ci-robot k8s-ci-robot merged commit 0c4e1d0 into kubernetes:master Sep 11, 2020
@spiffxp
Copy link
Member Author

spiffxp commented Sep 11, 2020

Makes me wonder if the retry_flake_attempts setting was added before the move to RBE

#59283 added test:unit --flaky_test_attempts=3 on 2018-02-06

... but it was in build/root/Makefile as bazel flags before that
... before #45855 moved Makefile to build/root
... before #41280 moved it from .bazelrc to Makefile

So, yeah, it was in the first PR that added .bazelrc on 2017-01-20 (#40231). Definitely before we tried running bazel via RBE

@spiffxp spiffxp deleted the bazel-test-unit-twice branch September 11, 2020 00:24
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/flake Categorizes issue or PR as related to a flaky test. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants