[go: up one dir, main page]

Skip to content

GitLab API: "commit_count" and "last_activity_at" values are usually not up-to-date

Summary

gitlab api does not always correctly show "last_activity_at" and "commit_count"

Steps to reproduce

  • created a fresh sandbox project
  • added, committed, and pushed change
  • run curl -s -H 'Cache-Control: no-cache' --no-keepalive --header "PRIVATE-TOKEN: <token>" "https://gitlab.com/api/v4/projects/<project_id>?statistics=true"
  • run git rev-list --count HEAD

Repeat the last three steps. "Usually" the last two commands not return the same value for commit_count, even after 5-10 minutes.

Example Project

git@gitlab.com:agosta/sandbox.git

What is the current bug behavior?

  • commit_count has different value, than the actual number of commits
  • 'last_activity_at' not gives the correct time when the last activity was made

What is the expected correct behavior?

'commit_count' and 'last_activity_at' should always be the same given by gitlab API and the web interface

Relevant logs and/or screenshots

Faulty behaviour:

agosta@agosta-HP-ZBook-15:~/git/sandbox$ vi asdf                                                                                                                                                                                              
agosta@agosta-HP-ZBook-15:~/git/sandbox$ git add asdf 
agosta@agosta-HP-ZBook-15:~/git/sandbox$ git commit -m '6'
[master 67a617b] 6
 1 file changed, 2 insertions(+)
agosta@agosta-HP-ZBook-15:~/git/sandbox$ git push origin HEAD:master
Counting objects: 3, done.
Writing objects: 100% (3/3), 264 bytes | 264.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To gitlab.com:agosta/sandbox.git
   bd2d8f0..67a617b  HEAD -> master
agosta@agosta-HP-ZBook-15:~/git/sandbox$ curl -s -H 'Cache-Control: no-cache' --no-keepalive --header "PRIVATE-TOKEN: `cat ~/.ssh/gitlab_token`" "https://gitlab.com/api/v4/projects/5384216?statistics=true"
{"id":5384216,"description":"","name":"sandbox","name_with_namespace":"Apor Ágost / sandbox","path":"sandbox","path_with_namespace":"agosta/sandbox","created_at":"2018-02-06T15:58:42.468Z","default_branch":"master","tag_list":[],"ssh_url_to_repo":"git@gitlab.com:agosta/sandbox.git","http_url_to_repo":"https://gitlab.com/agosta/sandbox.git","web_url":"https://gitlab.com/agosta/sandbox","avatar_url":null,"star_count":0,"forks_count":0,"last_activity_at":"2018-02-06T17:21:26.892Z","_links":{"self":"http://gitlab.com/api/v4/projects/5384216","issues":"http://gitlab.com/api/v4/projects/5384216/issues","merge_requests":"http://gitlab.com/api/v4/projects/5384216/merge_requests","repo_branches":"http://gitlab.com/api/v4/projects/5384216/repository/branches","labels":"http://gitlab.com/api/v4/projects/5384216/labels","events":"http://gitlab.com/api/v4/projects/5384216/events","members":"http://gitlab.com/api/v4/projects/5384216/members"},"archived":false,"visibility":"private","owner":{"id":1694091,"name":"Apor Ágost","username":"agosta","state":"active","avatar_url":"https://secure.gravatar.com/avatar/b7aa8fa7f5667a1f74f05ed0cac1b860?s=80&d=identicon","web_url":"https://gitlab.com/agosta"},"resolve_outdated_diff_discussions":false,"container_registry_enabled":true,"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":1694091,"namespace":{"id":2077759,"name":"agosta","path":"agosta","kind":"user","full_path":"agosta","parent_id":null},"import_status":"none","import_error":null,"open_issues_count":0,"runners_token":"uj3E-qKyNcNAvfTe5mdm","public_jobs":true,"ci_config_path":null,"shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"request_access_enabled":false,"only_allow_merge_if_all_discussions_are_resolved":false,"printing_merge_request_link_enabled":true,"statistics":{"commit_count":5,"storage_size":94371,"repository_size":94371,"lfs_objects_size":0,"job_artifacts_size":0},"permissions":{"project_access":{"access_level":40,"notification_level":3},"group_access":null}}
agosta@agosta-HP-ZBook-15:~/git/sandbox$ git rev-list --count HEAD
6

Expected behaviour:

agosta@agosta-HP-ZBook-15:~/git/sandbox$ vi asdf           
agosta@agosta-HP-ZBook-15:~/git/sandbox$ git add asdf 
agosta@agosta-HP-ZBook-15:~/git/sandbox$ git commit -m '5?'
[master bd2d8f0] 5?
 1 file changed, 2 insertions(+)
agosta@agosta-HP-ZBook-15:~/git/sandbox$ git push origin HEAD:master
Counting objects: 3, done.
Writing objects: 100% (3/3), 266 bytes | 266.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To gitlab.com:agosta/sandbox.git
   4c23089..bd2d8f0  HEAD -> master
agosta@agosta-HP-ZBook-15:~/git/sandbox$ curl -s -H 'Cache-Control: no-cache' --no-keepalive --header "PRIVATE-TOKEN: `cat ~/.ssh/gitlab_token`" "https://gitlab.com/api/v4/projects/5384216?statistics=true"
{"id":5384216,"description":"","name":"sandbox","name_with_namespace":"Apor Ágost / sandbox","path":"sandbox","path_with_namespace":"agosta/sandbox","created_at":"2018-02-06T15:58:42.468Z","default_branch":"master","tag_list":[],"ssh_url_to_repo":"git@gitlab.com:agosta/sandbox.git","http_url_to_repo":"https://gitlab.com/agosta/sandbox.git","web_url":"https://gitlab.com/agosta/sandbox","avatar_url":null,"star_count":0,"forks_count":0,"last_activity_at":"2018-02-06T17:21:26.892Z","_links":{"self":"http://gitlab.com/api/v4/projects/5384216","issues":"http://gitlab.com/api/v4/projects/5384216/issues","merge_requests":"http://gitlab.com/api/v4/projects/5384216/merge_requests","repo_branches":"http://gitlab.com/api/v4/projects/5384216/repository/branches","labels":"http://gitlab.com/api/v4/projects/5384216/labels","events":"http://gitlab.com/api/v4/projects/5384216/events","members":"http://gitlab.com/api/v4/projects/5384216/members"},"archived":false,"visibility":"private","owner":{"id":1694091,"name":"Apor Ágost","username":"agosta","state":"active","avatar_url":"https://secure.gravatar.com/avatar/b7aa8fa7f5667a1f74f05ed0cac1b860?s=80&d=identicon","web_url":"https://gitlab.com/agosta"},"resolve_outdated_diff_discussions":false,"container_registry_enabled":true,"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":1694091,"namespace":{"id":2077759,"name":"agosta","path":"agosta","kind":"user","full_path":"agosta","parent_id":null},"import_status":"none","import_error":null,"open_issues_count":0,"runners_token":"uj3E-qKyNcNAvfTe5mdm","public_jobs":true,"ci_config_path":null,"shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"request_access_enabled":false,"only_allow_merge_if_all_discussions_are_resolved":false,"printing_merge_request_link_enabled":true,"statistics":{"commit_count":5,"storage_size":94371,"repository_size":94371,"lfs_objects_size":0,"job_artifacts_size":0},"permissions":{"project_access":{"access_level":40,"notification_level":3},"group_access":null}}
agosta@agosta-HP-ZBook-15:~/git/sandbox$ git rev-list --count HEAD
5

Output of checks

This bug happens on GitLab.com using gitlab API

General comments:

  • The web interface seems to be always up-to-date
  • https://gitlab.com/api/v4/projects/<project_id>/repository/commits seems to always be fine
  • The same issue is reproducable using a browser instead of curl