[opensuse-buildservice] How to ensure consistency for the "deleted" project? ("rails fix_project project=deleted" fails)
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
On Mittwoch, 19. Februar 2020, 08:06:11 CET Srinidhi B wrote:
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.
yes, right way ...
When I run check_project, I get:
$ run_in_api rails check_project project=deleted Project deleted lost on backend
that should not have happened ... You need to recover it on the backend, you can do so from your api server via curl -X POST $src_server:$port/source/deleted?cmd=undelete You should be fine afterwards. But have a look who deleted that project (and that without to do so in api).
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 $*" }
--
Adrian Schroeter
Hello Adrian, On Wed, 2020-02-19 at 09:10 +0100, Adrian Schröter wrote:
yes, right way ...
Danke!
When I run check_project, I get:
$ run_in_api rails check_project project=deleted Project deleted lost on backend
that should not have happened ...
I thought so too.
You need to recover it on the backend, you can do so from your api server via
curl -X POST $src_server:$port/source/deleted?cmd=undelete
$ curl -s -X POST http://build:5352/source/deleted?cmd=undelete <status code="404"> <summary>project 'deleted' is not deleted</summary> <details>404 project 'deleted' is not deleted</details> </status> Do I have to create this project? Also, /srv/obs/projects/_deleted/deleted.pkg does not exist on the backend.
You should be fine afterwards. But have a look who deleted that project (and that without to do so in api).
I can't figure this part out. API returns the project details: $ osc api /source/deleted <directory count='0'> </directory> $ osc meta prj deleted <project name="deleted"> <title/> <description/> <repository name="standard"/> <repository name="deleted"/> </project> But trying to check the history of the project returns an error: $ osc log -M deleted Server returned an error: HTTP Error 404: project 'deleted' does not exist project 'deleted' does not exist $ osc log -M -D deleted Server returned an error: HTTP Error 404: Not Found deleted Output does not change if I remove the "-M" option. Am I in more trouble than I had initially imagined? Regards, Srinidhi.N�����r��y隊Z)z{.���Wlz��qﮞ˛���m�)z{.��+�:�{Zr�az�'z��j)h���Ǜ�)]���Ǿ� ޮ�^�ˬz��
participants (2)
-
Adrian Schröter
-
Srinidhi B