summaryrefslogtreecommitdiff
path: root/buildstream/_pipeline.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2017-07-13 17:24:01 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2017-07-21 11:17:31 +0100
commit14a8b5aa28db973243b58a9ecb1ac9b26afa0994 (patch)
tree8f992f0d2e54ac3aa74f8a931b39ee0d73f8d63d /buildstream/_pipeline.py
parent977210795c9ec67309eae3b78e2100c6b2281823 (diff)
downloadbuildstream-sam/artifactcache-preflight-check.tar.gz
Check for write access to remote artifact cache early on in the pipelinesam/artifactcache-preflight-check
Previously, the first time you configured an artifact cache, you would get to the end of your first build and then BuildStream would exit because of some stupid mistake like you got the address slightly wrong or you forgot to add the host keys of the remote artifact cache to `~/.ssh/known_hosts`. To avoid surprises, if there's an artifacts push-url configured we now try to connect to it as a preflight check so that issues are raised early. On success, you will see something like this: [--:--:--][90904fe4][ main:gnu-toolchain/stage2.bst ] START Checking connectivity to remote artifact cache [00:00:00][90904fe4][ main:gnu-toolchain/stage2.bst ] SUCCESS Connectivity OK On failure, it looks like this: [--:--:--][90904fe4][ main:gnu-toolchain/stage2.bst ] START Checking connectivity to remote artifact cache [00:00:03][90904fe4][ main:gnu-toolchain/stage2.bst ] FAILURE BuildStream will be unable to push artifacts to the shared cache: ssh: connect to host ostree.baserock.org port 2220: Connection timed out As a bonus, for some reason this check causes SSH to ask about unknown host keys rather than just failing, so you may now see messages like this if the host keys are unknown rather than an error: The authenticity of host '[ostree.baserock.org]:22200 ([185.43.218.170]:22200)' can't be established. ECDSA key fingerprint is SHA256:mB+MNfYREOdRfp2FG6dceOlguE/Skd4QwnS0tvCPcnI. ECDSA key fingerprint is MD5:8f:fa:ab:90:19:31:f9:f7:f1:d4:e5:f0:a2:be:56:71. Are you sure you want to continue connecting (yes/no)?
Diffstat (limited to 'buildstream/_pipeline.py')
-rw-r--r--buildstream/_pipeline.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index 960581a5c..64ce4d679 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -19,6 +19,7 @@
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
# Jürg Billeter <juerg.billeter@codethink.co.uk>
+import datetime
import os
import stat
import shlex
@@ -282,6 +283,21 @@ class Pipeline():
return element
+ # Internal: If a remote artifact cache is configured for pushing, check that it
+ # actually works.
+ def assert_remote_artifact_cache(self):
+ if self.artifacts.can_push():
+ starttime = datetime.datetime.now()
+ self.message(self.target, MessageType.START, "Checking connectivity to remote artifact cache")
+ try:
+ self.artifacts.preflight()
+ except _ArtifactError as e:
+ self.message(self.target, MessageType.FAIL, str(e),
+ elapsed=datetime.datetime.now() - starttime)
+ raise PipelineError()
+ self.message(self.target, MessageType.SUCCESS, "Connectivity OK",
+ elapsed=datetime.datetime.now() - starttime)
+
#############################################################
# Commands #
#############################################################
@@ -391,6 +407,8 @@ class Pipeline():
detail="\n".join([el + "-" + str(src) for el, src, _
in self.unused_workspaces]))
+ self.assert_remote_artifact_cache()
+
if build_all or track_first:
plan = list(self.dependencies(Scope.ALL))
else: