Project

General

Profile

Bug #29008

rake db:seed can fail on updating locked template

Added by Marek Hulán 6 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

When running db:migrate task, I've seen the following, preventing loading the environment and therefore migrating the database.

2020-02-13T21:39:01 [D|app|] updating existing template
2020-02-13T21:39:01 [D|app|] setting attributes for AutoYaST SLES default with id: 7
2020-02-13T21:39:01 [D|sql|]   TemplateInput Load (0.2ms)  SELECT "template_inputs".* FROM "template_inputs" WHERE "template_inputs"."template_id" = $1  [["template_id", 7]]
2020-02-13T21:39:01 [D|sql|]   ↳ app/models/template.rb:191
2020-02-13T21:39:01 [D|sql|]   ForeignInputSet Load (0.2ms)  SELECT "foreign_input_sets".* FROM "foreign_input_sets" WHERE "foreign_input_sets"."template_id" = $1  [["template_id", 7]]
2020-02-13T21:39:01 [D|sql|]   ↳ /home/ares/z/foreman_remote_execution/app/models/concerns/foreman_remote_execution/template_overrides.rb:5
2020-02-13T21:39:01 [D|sql|]   ProvisioningTemplate Exists (0.3ms)  SELECT  1 AS one FROM "templates" WHERE "templates"."type" IN ('ProvisioningTemplate') AND "templates"."name" = $1 AND "templates"."id" != $2 LIMIT $3  [["name", "AutoYaST SLES default"], ["id", 7], ["LIMIT", 1]]
2020-02-13T21:39:01 [D|sql|]   ↳ lib/seed_helper.rb:129
/home/ares/z/foreman/lib/seed_helper.rb:129:in `import_raw_template': Unable to update template AutoYaST SLES default: This template is locked. Please clone it to a new template to customize. (RuntimeError)
        from /home/ares/z/foreman/lib/seed_helper.rb:138:in `block in import_templates'
        from /home/ares/z/foreman/lib/seed_helper.rb:137:in `each'
        from /home/ares/z/foreman/lib/seed_helper.rb:137:in `import_templates'
        from /home/ares/z/foreman/db/seeds.d/070-provisioning_templates.rb:9:in `block in <main>'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing'
        from /home/ares/z/foreman/db/seeds.d/070-provisioning_templates.rb:2:in `<main>'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:281:in `block in load'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:281:in `load'
        from /home/ares/z/foreman/app/services/foreman_seeder.rb:39:in `block (2 levels) in execute'
        from /home/ares/z/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
        from /home/ares/z/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin'
        from /home/ares/z/foreman/app/services/foreman_seeder.rb:38:in `block in execute'
        from /home/ares/z/foreman/app/services/foreman_seeder.rb:32:in `each'
        from /home/ares/z/foreman/app/services/foreman_seeder.rb:32:in `execute'
        from /home/ares/z/foreman/config/initializers/seeds.rb:8:in `block (2 levels) in <main>'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `call'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/application.rb:361:in `initialize!'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing'
        from /home/ares/z/foreman/config/environment.rb:5:in `<main>'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:106:in `preload'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:157:in `serve'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:139:in `run'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /usr/local/rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from -e:1:in `<main>'

the fix is easy, we should ignore locking when checking whether the template is valid, like we do later when saving


Related issues

Related to Foreman - Bug #29272: template seeding fails during app initializationClosed

Associated revisions

Revision 7ec4d3b4 (diff)
Added by Marek Hulán 6 months ago

Fixes #29008 - consider locked templates valid in seed

When a template is already persisted, it's considered invalid when
changed, if it's locked, however seeding should update default template.
When we call save, we ignore locking, but we also need to ignore it when
checking for errors on few lines above. This is I believe a regression
caused by running seed checks.

History

#1 Updated by The Foreman Bot 6 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/7436 added

#2 Updated by The Foreman Bot 6 months ago

  • Fixed in Releases 2.1.0 added

#3 Updated by Marek Hulán 6 months ago

  • Status changed from Ready For Testing to Closed

#4 Updated by Tomer Brisker 5 months ago

  • Has duplicate Bug #29272: template seeding fails during app initialization added

#5 Updated by Tomer Brisker 5 months ago

  • Has duplicate deleted (Bug #29272: template seeding fails during app initialization)

#6 Updated by Tomer Brisker 5 months ago

  • Related to Bug #29272: template seeding fails during app initialization added

Also available in: Atom PDF