From b9210b285566acd72d0820b42c1a330ba56a1ad0 Mon Sep 17 00:00:00 2001 From: Zach Koopmans Date: Thu, 19 Mar 2020 16:05:52 -0700 Subject: Fix bm-tools to run on bazel. Fixes random stuff that is broken on bazel/kokoro. - random output coming back as "bytes" object instead of str - missed syntax error in bazel - a flag is missing in the version of gcloud on kokoro PiperOrigin-RevId: 301915289 --- benchmarks/harness/machine_producers/gcloud_producer.py | 8 +++++--- tools/images/BUILD | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/benchmarks/harness/machine_producers/gcloud_producer.py b/benchmarks/harness/machine_producers/gcloud_producer.py index 513d16e4f..1a624df2e 100644 --- a/benchmarks/harness/machine_producers/gcloud_producer.py +++ b/benchmarks/harness/machine_producers/gcloud_producer.py @@ -168,7 +168,9 @@ class GCloudProducer(machine_producer.MachineProducer): cmd.append("--zone=" + self.zone) cmd.append("--machine-type=" + self.machine_type) res = self._run_command(cmd) - return json.loads(res.stdout) + data = res.stdout + data = str(data, "utf-8") if isinstance(data, (bytes, bytearray)) else data + return json.loads(data) def _add_ssh_key_to_instances(self, names: List[str]) -> None: """Adds ssh key to instances by calling gcloud ssh command. @@ -186,11 +188,11 @@ class GCloudProducer(machine_producer.MachineProducer): TimeoutError: when 3 unsuccessful tries to ssh into the host return 255. """ for name in names: - cmd = "gcloud compute ssh {name}".format(name=name).split(" ") + cmd = "gcloud compute ssh {user}@{name}".format( + user=self.ssh_user, name=name).split(" ") cmd.append("--ssh-key-file={key}".format(key=self.ssh_key_file)) cmd.append("--zone={zone}".format(zone=self.zone)) cmd.append("--command=uname") - cmd.append("--ssh-key-expire-after=60m") timeout = datetime.timedelta(seconds=5 * 60) start = datetime.datetime.now() while datetime.datetime.now() <= timeout + start: diff --git a/tools/images/BUILD b/tools/images/BUILD index fe11f08a3..66ffd02aa 100644 --- a/tools/images/BUILD +++ b/tools/images/BUILD @@ -9,7 +9,7 @@ package( genrule( name = "zone", outs = ["zone.txt"], - cmd = "gcloud config get-value compute/zone > $@", + cmd = "gcloud config get-value compute/zone > \"$@\"", tags = [ "local", "manual", -- cgit v1.2.3