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

Attempt to fix flaky GPG test by stopping gpg-agent #104

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

krobelus
Copy link
Contributor

@krobelus krobelus commented Oct 4, 2021

The new GPG tests fail occasionally, for example in
https://github.com/mystor/git-revise/pull/99/checks?check_run_id=3785380820
An excerpt from the job log is added below.

I'm not sure if problem is the

FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.extra'

or the

gpg failed to sign commit

line; neither should happen.

The first sounds like a race between the GPG agent shutdown and the
cleanup of the test's temp dir. Try to fix that by stopping the agent
before cleanup. Intuitively, this fix makes sense because it's
probably not normal to remove $GNUPGHOME while gpg-agent is running.
Extract everything that handles our temporary $GNUPGHOME to a fixture,
so we can include a cleanup step.
This could be tested by repeating this in the CI a
number of times but I'm not sure if that's worth it.

Unfortunately, the "gpg failed to sign commit" (very last line of
the log below) does not tell us which one failed but that probably
wouldn't help either.

============================= test session starts ==============================
tests/test_gpgsign.py .E

==================================== ERRORS ====================================
______________________ ERROR at teardown of test_gpgsign _______________________

    @pytest.fixture
    def short_tmpdir():
        with tempfile.TemporaryDirectory() as tdir:
>           yield py.path.local(tdir)

tests/conftest.py:67: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/tempfile.py:809: in __exit__
    self.cleanup()
/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/tempfile.py:813: in cleanup
    _shutil.rmtree(self.name)
/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/shutil.py:486: in rmtree
    _rmtree_safe_fd(fd, path, onerror)
/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/shutil.py:444: in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

topfd = 11, path = '/tmp/tmpdqw8v4oq'
onerror = <function rmtree.<locals>.onerror at 0x7fe22474da60>

    def _rmtree_safe_fd(topfd, path, onerror):
	...
                try:
>                   os.unlink(name, dir_fd=topfd)
E                   FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.extra'

/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/shutil.py:442: FileNotFoundError
----------------------------- Captured stdout call -----------------------------
[master (root-commit) 5aa2dc9] commit 1
 Author: Bash Author <bash_author@example.com>
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD'] {'check': True}
960d4c0a13a4 commit 1
Updating refs/heads/master (5aa2dc979632e41770014678a2c829369d7eea9a => 960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD'] {'check': True}
c67e6e4a4c25 commit 1
Updating refs/heads/master (960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0 => c67e6e4a4c25442f3cdf55d03a57639697420357)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD', '--gpg-sign'] {'check': True}
960d4c0a13a4 commit 1
Updating refs/heads/master (c67e6e4a4c25442f3cdf55d03a57639697420357 => 960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD', '--no-gpg-sign'] {'check': True}
c67e6e4a4c25 commit 1
Updating refs/heads/master (960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0 => c67e6e4a4c25442f3cdf55d03a57639697420357)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD', '-S'] {'check': True}
960d4c0a13a4 commit 1
Updating refs/heads/master (c67e6e4a4c25442f3cdf55d03a57639697420357 => 960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD', '--gpg-sign'] {'check': True}
subprocess exited with non-zero status: 1
[master 6a92b96] commit 2
 Author: Bash Author <bash_author@example.com>
[master 07435aa] commit 3
 Author: Bash Author <bash_author@example.com>
[master 33cebdc] commit 4
 Author: Bash Author <bash_author@example.com>
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD~~', '--gpg-sign'] {'check': True}
2b2c0313c39a commit 2
6932b3a0cd34 commit 3
018843b015b2 commit 4
Updating refs/heads/master (33cebdc30539bfeb0fc5e5530d1eee3fda277be1 => 018843b015b2221d9d87e10590dee48d90075f7a)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD~', '--no-gpg-sign'] {'check': True}
8e096b818b34 commit 3
af3a5ac5a196 commit 4
Updating refs/heads/master (018843b015b2221d9d87e10590dee48d90075f7a => af3a5ac5a196d0bef501e14b57fb33e3b683e947)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD~~', '--gpg-sign'] {'check': True}
2b2c0313c39a commit 2
6932b3a0cd34 commit 3
018843b015b2 commit 4
Updating refs/heads/master (af3a5ac5a196d0bef501e14b57fb33e3b683e947 => 018843b015b2221d9d87e10590dee48d90075f7a)
----------------------------- Captured stderr call -----------------------------
gpg: keybox '/tmp/tmpdqw8v4oq/pubring.kbx' created
gpg: /tmp/tmpdqw8v4oq/trustdb.gpg: trustdb created
gpg: key 1B1CE6765D1A672E marked as ultimately trusted
gpg: directory '/tmp/tmpdqw8v4oq/openpgp-revocs.d' created
gpg: revocation certificate stored as '/tmp/tmpdqw8v4oq/openpgp-revocs.d/844AB55D2239CF1037507DA71B1CE6765D1A672E.rev'
gpg failed to sign commit

try:
yield
finally:
bash("gpgconf --kill gpg-agent")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just --kill all? Not sure if dirmngr or scdaemon might also be used

The new GPG tests fail occasionally, for example in
https://github.com/mystor/git-revise/pull/99/checks?check_run_id=3785380820
An excerpt from the job log is added below.

I'm not sure if problem is the

	FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.extra'

or the

	gpg failed to sign commit

line; neither should happen.

The first sounds like a race between the GPG agent shutdown and the
cleanup of the test's temp dir. Try to fix that by stopping the agent
before cleanup.  Intuitively, this fix makes sense because it's
probably not normal to remove $GNUPGHOME while gpg-agent is running.
Extract everything that handles our temporary $GNUPGHOME to a fixture,
so we can include a cleanup step.
This could be tested by repeating this in the CI a
number of times but I'm not sure if that's worth it.

Unfortunately, the "gpg failed to sign commit" (very last line of
the log below) does not tell us which one failed but that probably
wouldn't help either.

============================= test session starts ==============================
tests/test_gpgsign.py .E

==================================== ERRORS ====================================
______________________ ERROR at teardown of test_gpgsign _______________________

    @pytest.fixture
    def short_tmpdir():
        with tempfile.TemporaryDirectory() as tdir:
>           yield py.path.local(tdir)

tests/conftest.py:67:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/tempfile.py:809: in __exit__
    self.cleanup()
/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/tempfile.py:813: in cleanup
    _shutil.rmtree(self.name)
/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/shutil.py:486: in rmtree
    _rmtree_safe_fd(fd, path, onerror)
/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/shutil.py:444: in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

topfd = 11, path = '/tmp/tmpdqw8v4oq'
onerror = <function rmtree.<locals>.onerror at 0x7fe22474da60>

    def _rmtree_safe_fd(topfd, path, onerror):
	...
                try:
>                   os.unlink(name, dir_fd=topfd)
E                   FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.extra'

/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/shutil.py:442: FileNotFoundError
----------------------------- Captured stdout call -----------------------------
[master (root-commit) 5aa2dc9] commit 1
 Author: Bash Author <bash_author@example.com>
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD'] {'check': True}
960d4c0a13a4 commit 1
Updating refs/heads/master (5aa2dc979632e41770014678a2c829369d7eea9a => 960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD'] {'check': True}
c67e6e4a4c25 commit 1
Updating refs/heads/master (960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0 => c67e6e4a4c25442f3cdf55d03a57639697420357)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD', '--gpg-sign'] {'check': True}
960d4c0a13a4 commit 1
Updating refs/heads/master (c67e6e4a4c25442f3cdf55d03a57639697420357 => 960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD', '--no-gpg-sign'] {'check': True}
c67e6e4a4c25 commit 1
Updating refs/heads/master (960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0 => c67e6e4a4c25442f3cdf55d03a57639697420357)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD', '-S'] {'check': True}
960d4c0a13a4 commit 1
Updating refs/heads/master (c67e6e4a4c25442f3cdf55d03a57639697420357 => 960d4c0a13a46b43af7aff0d7cb8ea6f4546f7b0)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD', '--gpg-sign'] {'check': True}
subprocess exited with non-zero status: 1
[master 6a92b96] commit 2
 Author: Bash Author <bash_author@example.com>
[master 07435aa] commit 3
 Author: Bash Author <bash_author@example.com>
[master 33cebdc] commit 4
 Author: Bash Author <bash_author@example.com>
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD~~', '--gpg-sign'] {'check': True}
2b2c0313c39a commit 2
6932b3a0cd34 commit 3
018843b015b2 commit 4
Updating refs/heads/master (33cebdc30539bfeb0fc5e5530d1eee3fda277be1 => 018843b015b2221d9d87e10590dee48d90075f7a)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD~', '--no-gpg-sign'] {'check': True}
8e096b818b34 commit 3
af3a5ac5a196 commit 4
Updating refs/heads/master (018843b015b2221d9d87e10590dee48d90075f7a => af3a5ac5a196d0bef501e14b57fb33e3b683e947)
Running ['/home/runner/work/git-revise/git-revise/.tox/py36/bin/python', '-m', 'gitrevise', 'HEAD~~', '--gpg-sign'] {'check': True}
2b2c0313c39a commit 2
6932b3a0cd34 commit 3
018843b015b2 commit 4
Updating refs/heads/master (af3a5ac5a196d0bef501e14b57fb33e3b683e947 => 018843b015b2221d9d87e10590dee48d90075f7a)
----------------------------- Captured stderr call -----------------------------
gpg: keybox '/tmp/tmpdqw8v4oq/pubring.kbx' created
gpg: /tmp/tmpdqw8v4oq/trustdb.gpg: trustdb created
gpg: key 1B1CE6765D1A672E marked as ultimately trusted
gpg: directory '/tmp/tmpdqw8v4oq/openpgp-revocs.d' created
gpg: revocation certificate stored as '/tmp/tmpdqw8v4oq/openpgp-revocs.d/844AB55D2239CF1037507DA71B1CE6765D1A672E.rev'
gpg failed to sign commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants