#4987 Remote hook declined the push
Closed: Fixed by mzch. Opened by mzch.

When I created a new project, The following error occurred. Could anyone tell me how to fix this issue?

Your task failed: Remote hook declined the push: Trace back (most recent call last): File "hooks/pre-receive", line 38, in <module> import pagure.lib ModuleNotFoundError: No module named 'pagure'

p.s.

Repository was created but README.md file wasn't created.

When I created a new project, The following error occurred. Could anyone tell me how to fix this issue?

```
Your task failed: Remote hook declined the push: Trace back (most recent call last): File "hooks/pre-receive", line 38, in import pagure.lib ModuleNotFoundError: No module named 'pagure'

Could you link to the project which triggered this?

Thanks

So far, all I tried to create...
My site: https://gitcollabo.com/

Ah ok, so a local/new pagure instance, cool :)

So it looks like the hook isn't finding the pagure module. How did you install it?

Something I do when I run pagure outside of the normal python path is:
- Edit pagure/hooks/file/hookrunner
- Un-comment and adjust the line 25: https://pagure.io/pagure/blob/master/f/pagure/hooks/files/hookrunner#_25 so it points to the pagure folder, thus adding it to the python path and making it available to the hooks

Repository was created but README.md file wasn't created.

It has likely run into the same issue as your manual push (hook declined it)

Oh yes, I didn't install any hooks. Resolved! Thanks! :)

But a new issue...Pagure says The permissions on this repository are being updated. This may take a while. During this time, you or some of the project's contributors may not be able to push to this repository.

This message is still shown and I can't delete a project I created last night.
Should I open another ticket?

Which GIT_AUTH_BACKEND are you using in the configuration?

If needed, there is a cli tool: pagure-admin which allows to toggle the read-only flag a project when the task that was supposed to do it failed.

I don't set GIT_AUTH_BACKEND. ..
I can’t find pagure-admin too in the git repository. Where can I get it?

I don't set GIT_AUTH_BACKEND. ..

So you have the default one: https://docs.pagure.org/pagure/configuration.html#git-auth-backend (I recommend you switch to pagure_authorized_keys as the gitolite integration is not working anymore and will be deprecated/removed soon).

I can’t find pagure-admin too in the git repository. Where can I get it?

in the git repo you can find it by calling: python pagure/cli/admin.py

Well, I entered PAGURE_CONFIG=/srv/pagure/pagure.cfg python pagure/cli/admin.py, then

Traceback (most recent call last):
  File "pagure/cli/admin.py", line 31, in <module>
    import pagure.config  # noqa: E402
ModuleNotFoundError: No module named 'pagure'

Try: PYTHONPATH=/path/to/your/git/clone/or/so PAGURE_CONFIG=.... python pagure/cli/admin.py

Thanks, I can delete my projects. But all projects I created on the web panel are read-only set. Could you tell me how to config to set read-write?

See python pagure/cli/admin.py read-only -h

I see. However is there the way to set read-write to any projects on the web panel?

I see. However is there the way to set read-write to any projects on the web panel?

It should be done automatically, so if it's not happening there is likely
something mis-configured. If you change the git auth backend, I expect that the
issue will go away.

OK. :)
I will wait for a while.

It should be quick, if it's not, there is something mis-configured in your pagure instance.

Not completed...If possible, could you tell me where my cfg is wrong?

  • pagure.cfg
import os
from datetime import timedelta
### Set the time after which the admin session expires
# There are two sessions on pagure, login that holds for 31 days and
# the session defined here after which an user has to re-login.
# This session is used when accessing all administrative parts of pagure
# (ie: changing a project's or a user's settings)
ADMIN_SESSION_LIFETIME = timedelta(minutes=20)
# Enable tickets and docs for all repos
ENABLE_TICKETS = True
ENABLE_DOCS = True
# Enables / Disables private projects
PRIVATE_PROJECTS = True
### Secret key for the Flask application
SECRET_KEY='secret-key'
### url to the database server:
DB_URL = 'mysql://pagure:password@localhost/pagure'
#DB_URL = 'postgres://user:pass@host/db_name'
#DB_URL = 'sqlite:////var/tmp/pagure_dev.sqlite'
### Send FedMsg notifications of events in pagure
FEDMSG_NOTIFICATIONS = False
### The FAS group in which the admin of pagure are
ADMIN_GROUP = ['sysadmin-main','admin']
### Hard-coded list of global admins
PAGURE_ADMIN_USERS = ["mzch"]
### Enables sending email using SMTP credentials.
EMAIL_SEND = True
### The email address to which the flask.log will send the errors (tracebacks)
EMAIL_ERROR = 'admin@gitcollabo.com'
### SMTP settings
SMTP_SERVER = 'mx1.mail-services.net'
SMTP_PORT = 587
SMTP_STARTTLS = True
SMTP_SSL = False
#Specify both for enabling SMTP with auth
SMTP_USERNAME = 'admin@example.com'
SMTP_PASSWORD = 'password'
### Information used to sent notifications
FROM_EMAIL = 'no-reply@gitcollabo.com'
DOMAIN_EMAIL_NOTIFICATIONS = 'gitcollabo.com'
SALT_EMAIL = 'salt'
### Restrict outgoing emails to these domains:
## If set, adding emailaccounts that don't end with these domainnames
## will not be permitted. Mails to already existing emailaccounts
## that are not covered by this list will not get sent.
# ALLOWED_EMAIL_DOMAINS = [ 'localhost.localdomain', 'example.com' ]
### Disallow remote pull requests
## If set, remote pull requests will be disabled and not available
## anymore as a selection in the PR dropdown menus
DISABLE_REMOTE_PR = False
### The URL at which the project is available.
APP_URL = 'https://gitcollabo.com/'
### The URL at which the documentation of projects will be available
## This should be in a different domain to avoid XSS issues since we want
## to allow raw html to be displayed (different domain, ie not a sub-domain).
DOC_APP_URL = 'http://docs.gitcollabo.com'
### The URL to use to clone git repositories.
GIT_URL_SSH = 'ssh://pagure@gitcollabo.com/'
GIT_URL_GIT = 'https://gitcollabo.com/'
### Folder containing to the git repos
GIT_FOLDER = os.path.join(
    os.path.abspath(os.path.dirname(__file__)),
    'data',
    'repos'
)
REPOSPANNER_PSEUDO_FOLDER = os.path.join(
    os.path.abspath(os.path.dirname(__file__)),
    'data',
    'pseudo'
)
### Folder containing the clones for the remote pull-requests
REMOTE_GIT_FOLDER = os.path.join(
    os.path.abspath(os.path.dirname(__file__)),
    'data',
    'remotes'
)
###
UPLOAD_FOLDER_PATH = os.path.join(
    os.path.abspath(os.path.dirname(__file__)),
    'data',
    'releases'
)
###
ATTACHMENTS_FOLDER =  os.path.join(
    os.path.abspath(os.path.dirname(__file__)),
    'data',
    'attachments'
)
### Whether to enable scanning for viruses in attachments
VIRUS_SCAN_ATTACHMENTS = False
### Configuration file for gitolite
GITOLITE_CONFIG = os.path.join(
    os.path.abspath(os.path.dirname(__file__)),
    '..',
    'gitolite.conf'
)
### Home folder of the gitolite user
### Folder where to run gl-compile-conf from
GITOLITE_HOME = None
### Version of gitolite used: 2 or 3?
GITOLITE_VERSION = 3
### Folder containing all the public ssh keys for gitolite
GITOLITE_KEYDIR = None
### Path to the gitolite.rc file
GL_RC = None
### Path to the /bin directory where the gitolite tools can be found
GL_BINDIR = None
# SSH Information
### The ssh certificates of the git server to be provided to the user
### /!\ format is important
SSH_KEYS = {'RSA': {'fingerprint': 'finger-print pagure@lb', 'pubkey': 'pub-key'}}
# Optional configuration
### Number of items displayed per page
# Used when listing items
ITEM_PER_PAGE = 50
### Maximum size of the uploaded content
# Used to limit the size of file attached to a ticket for example
MAX_CONTENT_LENGTH = 4 * 1024 * 1024  # 4 megabytes
### Lenght for short commits ids or file hex
SHORT_LENGTH = 6
### List of blacklisted project names that can conflicts for pagure's URLs
### or other
BLACKLISTED_PROJECTS = [
    'static', 'pv', 'releases', 'new', 'api', 'settings',
    'logout', 'login', 'users', 'groups', 'projects']
### IP addresses allowed to access the internal endpoints
### These endpoints are used by the milter and are security sensitive, thus
### the IP filter
IP_ALLOWED_INTERNAL = ['127.0.0.1', 'localhost', '::1']
### EventSource/Web-Hook/Redis configuration
# The eventsource integration is what allows pagure to refresh the content
# on your page when someone else comments on the ticket (and this without
# asking you to reload the page.
# By default it is off, ie: EVENTSOURCE_SOURCE is None, to turn it on, specify
# here what the URL of the eventsource server is, for example:
# https://ev.pagure.io or https://pagure.io:8080 or whatever you are using
# (Note: the urls sent to it start with a '/' so no need to add one yourself)
EVENTSOURCE_SOURCE = 'https://ev.gitcollabo.com'
# Port where the event source server is running (maybe be the same port
# as the one specified in EVENTSOURCE_SOURCE or a different one if you
# have something running in front of the server such as apache or stunnel).
EVENTSOURCE_PORT = 8880
# If this port is specified, the event source server will run another server
# at this port and will provide information about the number of active
# connections running on the first (main) event source server
#EV_STATS_PORT = 8888
# Web-hook can be turned on or off allowing using them for notifications, or
# not.
WEBHOOK = False
### Redis configuration
# A redis server is required for both the Event-Source server or the web-hook
# server.
REDIS_HOST = '127.0.0.1'
REDIS_PORT = 6379
REDIS_DB = 4
# Authentication related configuration option
###
SSH_FOLDER = '/srv/pagure/.ssh'
GIT_AUTH_BACKEND = 'pagure_authorized_keys'
HTTP_REPO_ACCESS_GITOLITE = None
SSH_KEYS_USERNAME_EXPECT = 'pagure'
SSH_COMMAND_NON_REPOSPANNER = ([
    "/usr/bin/%(cmd)s",
    "/srv/pagure/data/repos/%(reponame)s",
], {"GL_USER": "%(username)s"})
### Switch the authentication method
# Specify which authentication method to use.
# Available options: `fas`, `openid`, `oidc`, `local`
# Default: ``local``.
PAGURE_AUTH = 'local'
# When this is set to True, the session cookie will only be returned to the
# server via ssl (https). If you connect to the server via plain http, the
# cookie will not be sent. This prevents sniffing of the cookie contents.
# This may be set to False when testing your application but should always
# be set to True in production.
# Default: ``True``.
SESSION_COOKIE_SECURE = True
# The name of the cookie used to store the session id.
# Default: ``.pagure``.
SESSION_COOKIE_NAME = 'pagure'
# Boolean specifying whether to check the user's IP address when retrieving
# its session. This make things more secure (thus is on by default) but
# under certain setup it might not work (for example is there are proxies
# in front of the application).
CHECK_SESSION_IP = True
# Used by SESSION_COOKIE_PATH
APPLICATION_ROOT = '/'
# Allow the backward compatiblity endpoints for the old URLs schema to
# see the commits of a repo. This is only interesting if you pagure instance
# was running since before version 1.3 and if you care about backward
# compatibility in your URLs.
OLD_VIEW_COMMIT_ENABLED = False
# repoSpanner integration settings
# https://repospanner.org/
# Whether to create new repositories on repoSpanner by default.
# Either None or a region name.
REPOSPANNER_NEW_REPO = None
# Whether to allow admins to override region selection on creation.
REPOSPANNER_NEW_REPO_ADMIN_OVERRIDE = False
# Whether to create new forks on repoSpanner.
# Either None (no repoSpanner), True (same as origin project) or a region name.
REPOSPANNER_NEW_FORK = True
# Whether to allow an admin to manually migrate an individual project.
REPOSPANNER_ADMIN_MIGRATION = False
# The repoSpanner regions to be used in this Pagure instance.
# Example entry:
# 'default': {'url': 'https://nodea.regiona.repospanner.local:8444',
#             'repo_prefix': 'pagure/',
#             'hook': None,
#             'ca': '',
#             'admin_cert': {'cert': '',
#                            'key': ''},
#             'push_cert': {'cert': '',
#                           'key': ''}}
REPOSPANNER_REGIONS = {}
# Path to the plugins configuration file that is used to load plugins. Please
# look at files/plugins.cfg.sample for a configuration example.
# PAGURE_PLUGINS_CONFIG = "/srv/pagure/plugins.cfg"

Config looks good.

Have you started the workers? (What does systemctl |grep pagure return?)

Yes.

pagure-docs.service                                                                                         loaded active running   Pagure - Document Server
pagure-ev.service                                                                                           loaded active running   Pagure - EventSource
pagure-json.service                                                                                         loaded active running   Pagure - Json
pagure-logcom.service                                                                                       loaded active running   Pagure - Logcom
pagure-web.service                                                                                          loaded active running   Pagure - Git Server
pagure-worker.service                                                                                       loaded active running   Pagure - Worker
  • web starter
#! /bin/sh
PORT=3500
WORKERS=2
THREADS=4
LOGLEVEL=info
HOME=/srv/pagure
LOGDIR=$HOME/logs
RUNDIR=$HOME/run
if [ -d "$HOME/.pyenv/bin" ] ; then
    PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
fi
cd $HOME
OPTS=
OPTS=$OPTS" --access-logfile "$LOGDIR/web-access.log
OPTS=$OPTS" --error-logfile "$LOGDIR/web-error.log
OPTS=$OPTS" --log-level "$LOGLEVEL
OPTS=$OPTS" --name pagure-web"
OPTS=$OPTS" --chdir pagure"
OPTS=$OPTS" --pid "$RUNDIR"/web.pid"
OPTS=$OPTS" --bind 127.0.0.1:"$PORT
OPTS=$OPTS" --workers "$WORKERS
OPTS=$OPTS" --threads "$THREADS
PAGURE_CONFIG=/srv/pagure/pagure.cfg
export PAGURE_CONFIG
exec gunicorn $OPTS "pagure.flask_app:create_app()"
  • worker
#! /bin/sh
HOME=/srv/pagure
if [ -d "$HOME/.pyenv/bin" ] ; then
    PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
fi
cd $HOME/pagure
PAGURE_CONFIG=/srv/pagure/pagure.cfg
export PAGURE_CONFIG
exec celery worker -A pagure.lib.tasks --loglevel=info
  • document server
#! /bin/sh
PORT=3501
WORKERS=2
THREADS=4
LOGLEVEL=info
HOME=/srv/pagure
LOGDIR=$HOME/logs
RUNDIR=$HOME/run
if [ -d "$HOME/.pyenv/bin" ] ; then
    PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
fi
cd $HOME
OPTS=
OPTS=$OPTS" --access-logfile "$LOGDIR/docs-access.log
OPTS=$OPTS" --error-logfile "$LOGDIR/docs-error.log
OPTS=$OPTS" --log-level "$LOGLEVEL
OPTS=$OPTS" --name pagure-docs"
OPTS=$OPTS" --chdir pagure"
OPTS=$OPTS" --pid "$RUNDIR"/docs.pid"
OPTS=$OPTS" --bind 127.0.0.1:"$PORT
OPTS=$OPTS" --workers "$WORKERS
OPTS=$OPTS" --threads "$THREADS
PAGURE_CONFIG=/srv/pagure/pagure.cfg
export PAGURE_CONFIG
exec gunicorn $OPTS "pagure.docs_server:APP"
  • EventSource
#! /bin/sh
HOME=/srv/pagure
if [ -d "$HOME/.pyenv/bin" ] ; then
    PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
fi
cd $HOME/pagure
PAGURE_CONFIG=/srv/pagure/pagure.cfg
export PAGURE_CONFIG
exec python /srv/pagure/pagure/pagure_stream_server.py
  • JSON
#! /bin/sh
HOME=/srv/pagure
if [ -d "$HOME/.pyenv/bin" ] ; then
    PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
fi
cd $HOME/pagure
PAGURE_CONFIG=/srv/pagure/pagure.cfg
export PAGURE_CONFIG
exec celery worker -A pagure.lib.tasks_services --loglevel=info -Q pagure_loadjson
  • logcom
#! /bin/sh
HOME=/srv/pagure
if [ -d "$HOME/.pyenv/bin" ] ; then
    PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
fi
cd $HOME/pagure
PAGURE_CONFIG=/srv/pagure/pagure.cfg
export PAGURE_CONFIG
exec celery worker -A pagure.lib.tasks_services --loglevel=info -Q pagure_logcom

Do you have any logs in the pagure-worker service?

  • /var/log/daemon.log
Sep 10 11:43:43 lb worker.sh[24879]:
Sep 10 11:43:43 lb worker.sh[24879]:  -------------- celery@lb v4.4.7 (cliffs)
Sep 10 11:43:43 lb worker.sh[24879]: --- ***** -----
Sep 10 11:43:43 lb worker.sh[24879]: -- ******* ---- Linux-4.19.0-10-amd64-x86_64-with-glibc2.28 2020-09-10 11:43:43
Sep 10 11:43:43 lb worker.sh[24879]: - *** --- * ---
Sep 10 11:43:43 lb worker.sh[24879]: - ** ---------- [config]
Sep 10 11:43:43 lb worker.sh[24879]: - ** ---------- .> app:         tasks:0x7f0327c4e2e0
Sep 10 11:43:43 lb worker.sh[24879]: - ** ---------- .> transport:   redis://127.0.0.1:6379//
Sep 10 11:43:43 lb worker.sh[24879]: - ** ---------- .> results:     redis://127.0.0.1/
Sep 10 11:43:43 lb worker.sh[24879]: - *** --- * --- .> concurrency: 2 (prefork)
Sep 10 11:43:43 lb worker.sh[24879]: -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
Sep 10 11:43:43 lb worker.sh[24879]: --- ***** -----
Sep 10 11:43:43 lb worker.sh[24879]:  -------------- [queues]
Sep 10 11:43:43 lb worker.sh[24879]:                 .> celery           exchange=celery(direct) key=celery
Sep 10 11:43:43 lb worker.sh[24879]:
Sep 10 11:43:43 lb worker.sh[24879]: [tasks]
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.add_file_to_git
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.add_key_to_authorized_keys
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.clean_git
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.commits_author_stats
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.commits_history_stats
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.create_project
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.delete_branch
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.delete_project
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.fork
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.generate_archive
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.generate_gitolite_acls
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.git_garbage_collect
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.gitolite_post_compile_only
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.link_pr_to_ticket
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.merge_pull_request
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.move_to_repospanner
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.project_dowait
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.pull_remote_repo
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.pull_request_ready_branch
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.rebase_pull_request
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.refresh_pr_cache
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.refresh_remote_pr
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.remove_key_from_authorized_keys
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.sync_pull_ref
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.update_checksums_file
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.update_file_in_git
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.update_git
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks.update_pull_request
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks_services.load_json_commits_to_db
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks_services.log_commit_send_notifications
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks_services.trigger_ci_build
Sep 10 11:43:43 lb worker.sh[24879]:   . pagure.lib.tasks_services.webhook_notification
Sep 10 11:43:43 lb worker.sh[24879]: 2020-09-10 11:43:43,515 [INFO] celery.worker.consumer.connection: Connected to redis://127.0.0.1:6379//
Sep 10 11:43:43 lb worker.sh[24879]: 2020-09-10 11:43:43,521 [INFO] celery.worker.consumer.mingle: mingle: searching for neighbors
Sep 10 11:43:44 lb worker.sh[24879]: 2020-09-10 11:43:44,539 [WARNING] celery.redirected: /srv/pagure/.pyenv/versions/3.8.5/lib/python3.8/site-packages/celery/app/control.py:52: DuplicateNodenameWarning: Received multiple replies from nodename: celery@lb.
Sep 10 11:43:44 lb worker.sh[24879]: Please make sure you give each node a unique nodename using
Sep 10 11:43:44 lb worker.sh[24879]: the celery worker `-n` option.
Sep 10 11:43:44 lb worker.sh[24879]:   warnings.warn(DuplicateNodenameWarning(
Sep 10 11:43:44 lb worker.sh[24879]: 2020-09-10 11:43:44,539 [INFO] celery.worker.consumer.mingle: mingle: all alone
Sep 10 11:43:44 lb worker.sh[24879]: 2020-09-10 11:43:44,547 [INFO] celery.apps.worker: celery@lb ready.

These are the logs of the server starting. Is there any entry added when you try
to create a project?

No. I found only above in the log file.

Hm, this is odd, it looks like the workers aren't getting the task from the web UI. Do you see anything the web logs then? Redis is working fine?

Redis works well but no key is registered. Any idea?

Anything in the logs of the web frontend?

Nothing. But I changed redis bind address from 127.0.0.1 to 0.0.0.0 and restarted, then my project has been become to be able to delete.
It seems that it fixed this issue. Is it related?

Hm we apparently do use 0.0.0.0 for redis as well. It is likely the reason for the observed behavior but I don't remember the reason from the top of my head, we would have to check the redis documentation.

Glad you got it working anyway!

Thanks for your effort and support! :)

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

Metadata