Mailinglist Archive: opensuse-buildservice (88 mails)

< Previous Next >
Re: [opensuse-buildservice] How to ensure consistency for the "deleted" project? ("rails fix_project project=deleted" fails)
  • From: Adrian Schröter <adrian@xxxxxxx>
  • Date: Wed, 19 Feb 2020 09:10:07 +0100
  • Message-id: <1862806.KoffpC4sOx@linux-ywca>
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 <top
(required)>'
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 <top
(required)>'
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 <top
(required)>'
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 <adrian@xxxxxxx>
Build Infrastructure Project Manager

SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nuernberg, Germany
(HRB 247165, AG München), Geschäftsführer: Felix Imendörffer




--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-buildservice+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References