-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use shared builds for some e2e jobs #4105
Use shared builds for some e2e jobs #4105
Conversation
fa9d4cb
to
82e0fa6
Compare
scenarios/kubernetes_build.py
Outdated
gcs_build = "gs://"+bucket+dest+latest | ||
# and then write it to GCS | ||
gcs_shared = args.gcs_shared + os.getenv('PULL_REFS', '') + '/build-location.txt' | ||
upload_string(gcs_shared, gcs_build) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make the extra steps optional, since only pr build job need to upload to shared builds for now.
Maybe consider only do this when PULL_REFS
is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM.
scenarios/kubernetes_e2e.py
Outdated
if args.use_shared_build: | ||
link += args.use_shared_build + '-' | ||
link += 'build-location.txt' | ||
url = link.replace("gs://", "https://storage.googleapis.com/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/"
/'
/ (and other places), and I think gsutil cat might be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixing the strings, I'm not sure if gsutil cat is going to be any better.
scenarios/kubernetes_e2e.py
Outdated
url = link.replace("gs://", "https://storage.googleapis.com/") | ||
build_loc = urllib2.urlopen(url).read() | ||
# tell kubetest to extract from this location | ||
args.kubetest_args += "--extract="+build_loc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll need to add a test to assert other --extract
does not exist in config.json, or what's the expect behavior?
--extract should be allowed in other jobs (eg --extract=latest), but when
using shared builds it needs to be set to the build location dynamically
…On Thu, Aug 17, 2017 at 3:59 PM, Sen Lu ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In scenarios/kubernetes_e2e.py
<#4105 (comment)>
:
> @@ -476,7 +477,17 @@ def main(args):
runner_args.append(
'--gcp-service-account=%s' % mode.add_service_account(args.service_account))
- if args.build is not None:
+ if args.use_shared_build is not None:
+ # find shared build location from GCS
+ link = args.gcs_shared + os.getenv('PULL_REFS', '') + '/'
+ if args.use_shared_build:
+ link += args.use_shared_build + '-'
+ link += 'build-location.txt'
+ url = link.replace("gs://", "https://storage.googleapis.com/")
+ build_loc = urllib2.urlopen(url).read()
+ # tell kubetest to extract from this location
+ args.kubetest_args += "--extract="+build_loc
I think you'll need to add a test to assert other --extract does not
exist in config.json, or what's the expect behavior?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4105 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA4Bq2qTJ0bpWUVvlimzQnV2f9jOXEEvks5sZMW0gaJpZM4O64Lr>
.
|
82e0fa6
to
ef7942d
Compare
We support multiple --extract flags, it will extract multiple times and it means different things in kubetest, mostly for upgrade from one version to another :-) (It does not simply overwrite, if that's what you are expecting) |
@krzyzacy Added an entry to this PR's todo list to ensure that the flags are valid in the config, I will do that now. |
921fa6d
to
e7bd923
Compare
Please also add some tests to assert the intended behavior. |
e7bd923
to
28a1e6e
Compare
@krzyzacy PTAL, I've updated the tests, fixed a few things, and configured the non-blocking PR GPU job to run after a build step. |
scenarios/kubernetes_build.py
Outdated
dest += args.suffix | ||
build_tar = tarfile.open("_output/release-tars/kubernetes.tar.gz") | ||
latest = build_tar.getmember("kubernetes/version").read().strip() | ||
gcs_build = 'gs://'+bucket+dest+latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not give you the right path - maybe use os.path.join
and I would suggest you add a unittest for both bazel and build scenario as well
scenarios/kubernetes_e2e.py
Outdated
try: | ||
build_loc = read_gcs_path(gcs_path) | ||
# tell kubetest to extract from this location | ||
args.kubetest_args.append("--extract="+build_loc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: single quote, and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, extra space: " + build_loc
scenarios/kubernetes_bazel.py
Outdated
@@ -37,6 +37,13 @@ def check_output(*cmd): | |||
print >>sys.stderr, 'Run:', cmd | |||
return subprocess.check_output(cmd) | |||
|
|||
def upload_string(gcs_path, text): | |||
"""Uploads s to gcs_path""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/s/text/?
scenarios/kubernetes_bazel.py
Outdated
# log push-build location to path child jobs can find | ||
# (gs://<shared-bucket>/$PULL_REFS/bazel-build-location.txt) | ||
pull_refs = os.getenv('PULL_REFS', '') | ||
gcs_shared = args.gcs_shared + pull_refs + '/bazel-build-location.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd probably be safer to use os.path.join
here so that you don't end up with something weird if --gcs_shared
is missing a trailing slash. i.e. change this to
gcs_shared = os.path.join(args.gcs_shared, pull_refs, 'bazel-build-location.txt`)
scenarios/kubernetes_build.py
Outdated
dest += args.suffix | ||
build_tar = tarfile.open("_output/release-tars/kubernetes.tar.gz") | ||
latest = build_tar.getmember("kubernetes/version").read().strip() | ||
gcs_build = os.path.join('gs://', bucket, dest, latest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicating the logic of push-build.sh seems pretty fragile... I'd rather either we remove that logic from push-build.sh or add an option to push-build.sh to create this pointer file. @david-mcmahon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely fragile, I'm considering if we can just enable this feature for bazel build jobs and skip doing it for non-bazel builds since it's now scoped to just PR jobs anyhow. I'm pretty sure all jobs shouldn't need the special logic for finding builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed out-of-band, I think we don't need to support this for non-bazel builds so for now I will remove this.
scenarios/kubernetes_e2e.py
Outdated
args.build = None | ||
except urllib2.URLError as err: | ||
print >>sys.stderr, 'Failed to get shared build location: %s'%err.reason | ||
print >>sys.stderr, 'Falling back to local build...' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why fallback? this makes things complicated and may result in the job timing out instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fallback just seemed like a safer way to make this change. I can remove it.
NOTE: this needs to port over #4160 once that is in. |
642056c
to
6c38a39
Compare
jenkins/bootstrap_test.py
Outdated
extract_in_args = False | ||
build_in_args = False | ||
for arg in args: | ||
if arg.startswith("--use-shared-build"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/"/'/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, also below
scenarios/kubernetes_e2e.py
Outdated
gcs_path = os.path.join(args.gcs_shared, os.getenv('PULL_REFS', ''), build_file) | ||
try: | ||
# tell kubetest to extract from this location | ||
args.kubetest_args.append('--extract=' + read_gcs_path(gcs_path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about print gcs_path
so that we can have more debug clue on failures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
'--use-shared-build', nargs='?', default=None, const='', | ||
help='Use prebuilt kubernetes binaries if set, optionally specifying strategy') | ||
parser.add_argument( | ||
'--gcs-shared', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bikeshed: maybe --shared-build-location
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this flag can be used for other shared files and isn't actually the build location but where the "symlink" to the build is.
scenarios/kubernetes_e2e.py
Outdated
build_file += args.use_shared_build + '-' | ||
build_file += 'build-location.txt' | ||
gcs_path = os.path.join(args.gcs_shared, os.getenv('PULL_REFS', ''), build_file) | ||
print >>sys.stderr, "Getting shared build location from: "+gcs_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last nitpick for the quotes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seriously need gofmt, but for python.
done.
scenarios/kubernetes_e2e.py
Outdated
help='Use prebuilt kubernetes binaries if set, optionally specifying strategy') | ||
parser.add_argument( | ||
'--gcs-shared', | ||
default="gs://kubernetes-jenkins/shared-results/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well 😈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
scenarios/kubernetes_e2e_test.py
Outdated
# normal path | ||
with Stub(kubernetes_e2e, 'check_env', self.fake_check_env): | ||
with Stub(kubernetes_e2e, 'read_gcs_path', always_kubernetes): | ||
kubernetes_e2e.main(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, here in the test, I would like to see the gcs path pass into read_gcs_path
is correct, both with normal build and bazel build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
and please squash :-) |
Should be green, fixed nits. Will sqaush once everything checks out. |
/lgtm weee, let's see how it will work! |
@BenTheElder: I updated Prow config for you! In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
run_after_success: | ||
- name: pull-kubernetes-e2e-gce-gpu | ||
agent: jenkins | ||
always_run: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does always_run
and run_after_success
interact?
How does run_after_success
and /test all
interact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @krzyzacy @BenTheElder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I think @BenTheElder chatted with @mindprince offline, but worth document the behavior as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spxtr knows this better, this has since been reverted and is only being used on a canary job while we sort some other things out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref #4475 (comment)
We should definitely doc this more. I've since been a bit confused about the behavior myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see also some discussion in sig-testing slack: https://kubernetes.slack.com/archives/C09QZ4DQB/p1504904920000295
This will allow some jobs to reuse the same kubernetes build. In particular our PR e2e jobs each do a build and then
kubetest --extract=local ...
instead of one shared build.TODO:
run_after_success
jobs able to find buildsgs://some-shared-bucket/$PULL_REFS/(bazel-)?build-location.txt
FOLLOW-UP:
This is a little ugly but after a lot of discussion on-and-offline (#4047, #4074, ...) it seems to be the best solution for the moment. We may want to revisit the entire
run_after_success
system at some point in the future.