Issue #327: committed via Kallithea into repository
Reported by: | zwarmapapa |
State: | resolved |
Created on: | 2018-08-14 18:02 |
Updated on: | 2019-03-18 19:37 |
Description
I made a cronjob that pulls a remote repository every 10 minutes.
Everything works well, but now whenever I check my admin journal, all I see is "committed via Kallithea into repository" lines.
Even when the remote repository didn't change (and so, the cronjob shouldn't have committed anything).
Is there any way to disable this message, or is there a way to fix it so that it only adds this message when something did actually got committed (when something actually changed in the remote repo)?
Attachments
Comments
Comment by Mads Kiilerich, on 2018-08-14 18:59
What version control system are you using?
What Kallithea version are you using?
How do you pull - what command is the cron job running?
Comment by zwarmapapa, on 2018-08-14 19:14
Git.
Kallithea v0.3.99 (last time I pulled was maybe a couple months to half a year ago).
The cronjob line is:
*/10 * * * * curl https://mywebsite.com/_admin/api -X POST -H 'content-type:text/plain' --data-binary '{"id":1,"api_key":"a5aaaaaaaaaaaaaaaaaaaaaaaaaaa","method":"pull","args":{"repoid":65}}' > /dev/null 2>&1
Comment by Thomas De Schampheleire, on 2018-08-14 20:51
I think this is caused by kallithea/lib/scm.py, pull_changes
, which in case of git
calls _handle_push
:
if repo.alias == 'git': repo.fetch(clone_uri) # git doesn't really have something like post-fetch action # we fake that now. #TODO: extract fetched revisions somehow # here self._handle_push(repo, username=username, action='push_remote', repo_name=repo_name, revisions=[])
In that function is a call to _handle_rc_scm_extras
that does not pass the action
of push_remote
, and inside that one is a line:
'action': action or 'push_local',
where push_local
will resolve to the string you mentioned.
Comment by Mads Kiilerich, on 2018-08-14 22:47
It also seems a bit wrong to not log the pull attempt ...
Perhaps, when pulling that often, do it outside Kallithea and then call gearbox update-repoinfo
. Or check if there are any incoming changes before invoking the API.
Comment by zwarmapapa, on 2018-08-15 12:20
Ah I see, is there any way to disable this that wouldn't break or be reverted when I update kallithea?
Logging every pull attempt makes the log completely useless, since it's flooded with these messages now. I think it should only log anything when it either actually pulls a change, or when an error occurs. If no error occurs, and no changes have been pulled, I don't think it should log anything, because if it does, the log becomes unusable.
-Edit-
By the way, you said "kallithea/lib/scm.py", but I can't find a scm.py in lib, the only scm.py I can find is located at "kallithea/model/scm.py", is that the correct one?
I've currently disabled the lines you've listed in that file, and I've also purged the push messages from my log with SQL:
DELETE FROM user_logs WHERE action = 'push_local:'
Now the log is usable again, but it's not really a permanent solution, since this change will be undone when pulling a newer kallithea version.
-Edit 2-
Oh no it didn't work, my log is full again, was it the wrong file?
-Edit 3-
I've looked through the file again, the log message was 'push_local', not 'push_remote', so I started looking for 'push_local'.
In function commit_change I've found a 'push_local' log call, so I disabled that one now, this is probably the correct one (if not I'll correct it down below, in edit 4).
-Edit 4-
Nope it wasn't this one either, I give up.
Comment by Thomas De Schampheleire, on 2018-08-16 19:22
I think the following is a bugfix that will make sure that the setting of action to 'push_remote' is respected:
diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py --- a/kallithea/model/scm.py +++ b/kallithea/model/scm.py @@ -363,7 +363,7 @@ class ScmModel(object): :param repo_name: name of repo :param revisions: list of revisions that we pushed """ - self._handle_rc_scm_extras(username, repo_name, repo_alias=repo.alias) + self._handle_rc_scm_extras(username, repo_name, repo_alias=repo.alias, action=action) _scm_repo = repo._repo # trigger push hook if repo.alias == 'hg':
It will still log all pull attempts, but it will not erroneously log as 'committed via Kallithea' but instead as 'pulled from remote'.
Question is now whether or not default Kallithea should log pulling if nothing was actually pulled.
Comment by Thomas De Schampheleire, on 2019-03-18 19:37
The inaccurate log message is committed as b8deb93894ea. There is still an entry for pull even if no changes are pulled, but this is a semantic discussion whether we are logging the action that someone pulled, or whether something got pulled.