Hello List,
Every week, I receive an email from my local OBS Instance regarding the
inconsistency between API and backend. It lists one item as follows:
Additional projects in api:
["deleted"]
I remember that Adrian had once suggested on this list on how to clean this up,
but I'm unable to find that post. Looking at "rails -T" output and a few
ReleaseNotes files, I found that I can run "rails {check,fix}_project" commands.
When I run check_project, I get:
$ run_in_api rails check_project project=deleted
Project deleted lost on backend
When I run fix_project, it fails with:
$ run_in_api rails fix_project project=deleted
rails aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`api_production`.`path_elements`, CONSTRAINT `path_elements_ibfk_2` FOREIGN KEY (`repository_id`) REFERENCES `repositories` (`id`)): DELETE FROM `repositories` WHERE `repositories`.`id` = 3818
/srv/www/obs/api/app/jobs/consistency_check_job.rb:64:in `rescue in check_project'
/srv/www/obs/api/app/jobs/consistency_check_job.rb:59:in `check_project'
/srv/www/obs/api/app/jobs/consistency_check_job.rb:36:in `fix_project'
/srv/www/obs/api/lib/tasks/delayed_job.rake:27:in `block in '
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Caused by:
Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`api_production`.`path_elements`, CONSTRAINT `path_elements_ibfk_2` FOREIGN KEY (`repository_id`) REFERENCES `repositories` (`id`))
/srv/www/obs/api/app/jobs/consistency_check_job.rb:64:in `rescue in check_project'
/srv/www/obs/api/app/jobs/consistency_check_job.rb:59:in `check_project'
/srv/www/obs/api/app/jobs/consistency_check_job.rb:36:in `fix_project'
/srv/www/obs/api/lib/tasks/delayed_job.rake:27:in `block in '
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Caused by:
ActiveXML::Transport::NotFoundError: <status code="404">
<summary>project 'deleted' does not exist</summary>
<details>404 project 'deleted' does not exist</details>
</status>
/srv/www/obs/api/lib/backend/connection.rb:122:in `handle_response'
/srv/www/obs/api/lib/backend/connection.rb:31:in `get'
/srv/www/obs/api/lib/backend/connection_helper.rb:48:in `http_get'
/srv/www/obs/api/lib/backend/api/sources/project.rb:78:in `packages'
/srv/www/obs/api/app/jobs/consistency_check_job.rb:60:in `check_project'
/srv/www/obs/api/app/jobs/consistency_check_job.rb:36:in `fix_project'
/srv/www/obs/api/lib/tasks/delayed_job.rake:27:in `block in '
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => fix_project
(See full trace by running task with --trace)
Am I doing something wrong or is something missing on the API side? Or am I
using the command incorrectly?
Regards,
Srinidhi.
PS: run_in_api is a function I have extracted from OBS scripts:
$ type run_in_api
run_in_api is a function
run_in_api ()
{
export RAILS_ENV="production";
sudo chroot --userspec=wwwrun:www / /bin/bash -c "cd $API_ROOT && RAILS_ENV='production' /usr/bin/bundle.ruby2.5 exec $*"
}