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

Handle FileNotFound error in checking git repository version #6284

Merged
merged 2 commits into from Oct 30, 2019

Conversation

@anoadragon453
Copy link
Member

anoadragon453 commented Oct 29, 2019

A user hit an interesting edge case where they'd get an error if git was not installed: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240498#c3

2019-09-11 14:43:53,745 - synapse.util.versionstring - 85 - INFO - None - Failed to check for git repository: [Errno 2] No such file or directory: 'git': 'git'

Just assume no git branch (does the same as if we weren't in a git directory) on FileNotFoundError, which not having git installed will produce:

✗ python3                                                                   
Python 3.6.8 (default, Jun 20 2019, 17:11:57) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.check_output(["git", "diff"])
b'diff --git a/scripts-dev/update_database b/scripts-dev/update_database\nindex 10166583e..27a1ad1e7 100755\n--- a/scripts-dev/update_database\n+++ b/scripts-dev/update_database\n@@ -25,8 +25,8 @@ from twisted.internet import defer, reactor\n from synapse.config.homeserver import HomeServerConfig\n from synapse.metrics.background_process_metrics import run_as_background_process\n from synapse.server import HomeServer\n-from synapse.storage.engines import create_engine\n from synapse.storage import DataStore\n+from synapse.storage.engines import create_engine\n from synapse.storage.prepare_database import prepare_database\n \n logger = logging.getLogger("update_database")\n@@ -122,4 +122,3 @@ if __name__ == "__main__":\n     ))\n \n     reactor.run()\n-\n'
>>> subprocess.check_output(["gitx", "diff"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/home/user/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/user/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/home/user/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gitx': 'gitx'
>>> 
@anoadragon453 anoadragon453 self-assigned this Oct 29, 2019
@anoadragon453 anoadragon453 added this to In progress in Homeserver Task Board via automation Oct 29, 2019
@anoadragon453 anoadragon453 moved this from In progress to Review in Homeserver Task Board Oct 30, 2019
@richvdh richvdh moved this from Review to In progress in Homeserver Task Board Oct 30, 2019
@anoadragon453 anoadragon453 requested a review from matrix-org/synapse-core Oct 30, 2019
@anoadragon453 anoadragon453 moved this from In progress to Review in Homeserver Task Board Oct 30, 2019
@anoadragon453 anoadragon453 merged commit b39ca49 into develop Oct 30, 2019
20 checks passed
20 checks passed
buildkite/synapse Build #5218 passed (19 minutes, 53 seconds)
Details
buildkite/synapse/check-sample-config Passed (1 minute, 32 seconds)
Details
buildkite/synapse/check-style Passed (1 minute, 49 seconds)
Details
buildkite/synapse/isort Passed (17 seconds)
Details
buildkite/synapse/mypy Passed (27 seconds)
Details
buildkite/synapse/newspaper-newsfile Passed (14 seconds)
Details
buildkite/synapse/packaging Passed (30 seconds)
Details
buildkite/synapse/pipeline Passed (4 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-postgres-9-dot-5 Passed (17 minutes, 49 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite Passed (6 minutes, 39 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite-slash-old-deps Passed (9 minutes, 43 seconds)
Details
buildkite/synapse/python-3-dot-6-slash-sqlite Passed (7 minutes, 40 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-11 Passed (17 minutes, 10 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-9-dot-5 Passed (17 minutes, 35 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-sqlite Passed (7 minutes, 10 seconds)
Details
buildkite/synapse/synapse-port-db-slash-python-3-dot-5-slash-postgres-9-dot-5 Passed (1 minute, 52 seconds)
Details
buildkite/synapse/synapse-port-db-slash-python-3-dot-7-slash-postgres-11 Passed (1 minute, 14 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-monolith Passed (15 minutes, 11 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-workers Passed (13 minutes, 16 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-sqlite-slash-monolith Passed (13 minutes, 58 seconds)
Details
Homeserver Task Board automation moved this from Review to Done Oct 30, 2019
@anoadragon453 anoadragon453 deleted the anoa/git_version_checking branch Oct 30, 2019
anoadragon453 added a commit that referenced this pull request Oct 30, 2019
…ger_warning

* 'develop' of github.com:matrix-org/synapse:
  Fix log line that was printing undefined value (#6278)
  Update CI to run isort on scripts and scripts-dev (#6270)
  Fix small typo in comment (#6269)
  Fix typo in domain name in account_threepid_delegates config option (#6273)
  Remove redundant arguments to CI's flake8 (#6277)
  Handle FileNotFound error in checking git repository version (#6284)
  Don't return coroutines
  Newsfile
  Port receipt and read markers to async/wait
  Make concurrently_execute work with async/await
  Newsfile
  Port federation_server to async/await
  Newsfile
  Port room rest handlers to async/await
  Newsfile
  Port replication http server endpoints to async/await
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.