#9000 Adjust distgit_check_hook.py to move the pagure hooks
Closed: Fixed by pingou. Opened by pingou.

Describe what you would like us to do:


When we migrated the repo over from RHEL7 to RHEL8, the symlink pointing to the pagure hooks were also copied, in the old state.
So we've ended up with things like:

 pre-receive -> /usr/lib/python2.7/site-packages/pagure/hooks/files/hookrunner
 update -> /usr/lib/python2.7/site-packages/pagure/hooks/files/hookrunner

which were basically pointing to nowhere since pagure on rhel8 is python3 (3.6 to be precise).

It would be good to see if we can adjust the roles/git/check/files/distgit_check_hook.py script to also check for these hooks and fix them when/where needed.

When do you need this to be done by? (YYYY/MM/DD)


We've "solved" the problem by creating the py2.7 file which is a link to the 3.6 one, but that's not nice and we shouldn't keep this for longer than necessary.


@nils is this perhaps something you would have time to work on?

Metadata Update from @smooge:
- Issue priority set to: Waiting on Assignee (was: Needs Review)

Metadata Update from @pingou:
- Issue tagged with: dev

Metadata Update from @nphilipp:
- Issue assigned to nphilipp

Proposed approach:

  • Have distgit_check_hook.py import the pagure module to figure out the root directory and path to hookrunner and fix links pointing to .../hookrunner in repos accordingly.
  • Move the hookrunner script in Pagure out of the Python sitelib to some unversioned place, e.g. /usr/libexec/pagure-hookrunner.
  • Let distgit_check_hook.py point hook symlinks there.

Metadata Update from @nphilipp:
- Issue untagged with: dev

Metadata Update from @pingou:
- Issue tagged with: dev

Proposed fix: fedora-infra/ansible#149

The script mostly works, but doesn't handle one situation:

Processing: rpms
/srv/git/repositories/rpms/cinch.git/hooks/pre-receive is not pointing to the expected target: /usr/lib/python3.6/site-packages/pagure/hooks/files/hookrunner
Traceback (most recent call last):
  File "/usr/local/bin/distgit_check_hook.py", line 159, in <module>
    sys.exit(main())
  File "/usr/local/bin/distgit_check_hook.py", line 155, in main
    process_namespace(namespace, args.check, walk=walk)
  File "/usr/local/bin/distgit_check_hook.py", line 114, in process_namespace
    test_and_fix_repo_hooks(repo_path, is_fork=is_fork, check=check)
  File "/usr/local/bin/distgit_check_hook.py", line 85, in test_and_fix_repo_hooks
    fix_link(hook_path, link_target)
  File "/usr/local/bin/distgit_check_hook.py", line 55, in fix_link
    hook.symlink_to(target_link)
  File "/usr/lib64/python3.6/pathlib.py", line 1327, in symlink_to
    self._accessor.symlink(target, self, target_is_directory)
  File "/usr/lib64/python3.6/pathlib.py", line 434, in symlink
    return os.symlink(str(a), str(b))
FileExistsError: [Errno 17] File exists: '/usr/lib/python3.6/site-packages/pagure/hooks/files/hookrunner' -> '/srv/git/repositories/rpms/cinch.git/hooks/pre-receive'

Check the filesystem:

 ll /srv/git/repositories/rpms/cinch.git/hooks/pre-receive
lrwxrwxrwx. 1 pagure packager 63 Sep 13  2017 /srv/git/repositories/rpms/cinch.git/hooks/pre-receive -> /usr/lib/python2.7/site-packages/pagure/hooks/files/pre-receive

Where /usr/lib/python2.7/site-packages/pagure/hooks/files/pre-receive does not exist.

@nphilipp fixed the above issue in https://pagure.io/fedora-infra/ansible/pull-request/150

The script is running and so far w/o error

Second run:

# time /usr/local/bin/distgit_check_hook.py  
Processing: rpms
Processing: container
Processing: forks
Processing: modules
Processing: tests
real    0m24.793s
user    0m18.289s
sys     0m6.131s

I'm going to remove our hack to /usr/lib/python2.7/site-packages/pagure/ and monitor commits on datagrepper to check that notifications are still happening.
If all goes fine, I think we'll be able to close this as fixed :)

Thanks for working on this @nphilipp !

I see messages coming in and I've pushed a couple of tests commit fine.

Let's consider this fixed!

Metadata Update from @pingou:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

Metadata