Bug 1232281

Summary: Error:"You cannot call create unless the parent is saved [host/create]" in add new host
Product: Red Hat CloudForms Management Engine Reporter: Aziza Karol <akarol>
Component: UI - OPSAssignee: Martin Hradil <mhradil>
Status: CLOSED ERRATA QA Contact: Aziza Karol <akarol>
Severity: medium Docs Contact:
Priority: high    
Version: 5.4.0CC: cpelland, hkataria, jhardy, mfeifer, mpovolny, obarenbo
Target Milestone: GAKeywords: ZStream
Target Release: 5.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.5.0.1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1254666 (view as bug list) Environment:
Last Closed: 2015-12-08 13:13:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1254666    
Attachments:
Description Flags
err none

Description Aziza Karol 2015-06-16 12:22:42 UTC
Created attachment 1039420 [details]
err

Description of problem:


Version-Release number of selected component (if applicable):
5.4.0.5

How reproducible:
100%

Steps to Reproduce:
1.Navigate to infrastructure->hosts->configuration->Add a new host
2.enter all the basic information and select host platform as "VMware ESX".
3.click on add.

Actual results:
You cannot call create unless the parent is saved [host/create] is displayed in UI. see attached screenshot

Expected results:


Additional info:
production.log
[----] I, [2015-06-16T07:47:10.305780 #2459:e9dea0]  INFO -- : Completed 200 OK in 269.6ms (Views: 0.6ms | ActiveRecord: 0.9ms)
[----] I, [2015-06-16T07:47:15.448354 #2459:e9dea0]  INFO -- : Started POST "/host/create/new?button=add" for 127.0.0.1 at 2015-06-16 07:47:15 -0400
[----] I, [2015-06-16T07:47:15.453431 #2459:e9dea0]  INFO -- : Processing by HostController#create as JS
[----] I, [2015-06-16T07:47:15.453532 #2459:e9dea0]  INFO -- :   Parameters: {"button"=>"add", "id"=>"new"}
[----] F, [2015-06-16T07:47:15.475681 #2459:e9dea0] FATAL -- : Error caught: [ActiveRecord::RecordNotSaved] You cannot call create unless the parent is saved
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activerecord/lib/active_record/associations/collection_association.rb:427:in `create_record'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activerecord/lib/active_record/associations/collection_association.rb:119:in `create'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activerecord/lib/active_record/associations/collection_proxy.rb:46:in `create'
/var/www/miq/vmdb/app/models/mixins/custom_attribute_mixin.rb:39:in `miq_custom_set'
/var/www/miq/vmdb/app/models/mixins/custom_attribute_mixin.rb:21:in `block (3 levels) in <module:CustomAttributeMixin>'
/var/www/miq/vmdb/app/controllers/host_controller.rb:965:in `set_record_vars'
/var/www/miq/vmdb/app/controllers/host_controller.rb:269:in `create'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/abstract_controller/base.rb:167:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal/rendering.rb:10:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/callbacks.rb:568:in `_run__3510692938762062161__process_action__2252268127437349515__callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal/rescue.rb:29:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/notifications.rb:123:in `block in instrument'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/notifications.rb:123:in `instrument'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activerecord/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/abstract_controller/base.rb:121:in `process'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/abstract_controller/rendering.rb:45:in `process'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal.rb:203:in `dispatch'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_controller/metal.rb:246:in `block in action'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/routing/route_set.rb:73:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/routing/route_set.rb:36:in `call'
/opt/rh/cfme-gemset/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/opt/rh/cfme-gemset/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/opt/rh/cfme-gemset/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/routing/route_set.rb:608:in `call'
/opt/rh/cfme-gemset/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
/opt/rh/cfme-gemset/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
/opt/rh/cfme-gemset/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
/opt/rh/cfme-gemset/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
/opt/rh/cfme-gemset/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/head.rb:14:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/flash.rb:242:in `call'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activerecord/lib/active_record/query_cache.rb:64:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/callbacks.rb:405:in `_run__3055438731397051558__call__3512400057747199118__callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/rack/logger.rb:32:in `call_app'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/rack/logger.rb:18:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/activesupport/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/actionpack/lib/action_dispatch/middleware/static.rb:63:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/engine.rb:484:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/application.rb:231:in `call'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/rack/log_tailer.rb:17:in `call'
/opt/rh/ruby200/root/usr/share/gems/gems/thin-1.3.1/lib/thin/connection.rb:80:in `block in pre_process'
/opt/rh/ruby200/root/usr/share/gems/gems/thin-1.3.1/lib/thin/connection.rb:78:in `catch'
/opt/rh/ruby200/root/usr/share/gems/gems/thin-1.3.1/lib/thin/connection.rb:78:in `pre_process'
/opt/rh/ruby200/root/usr/share/gems/gems/thin-1.3.1/lib/thin/connection.rb:53:in `process'
/opt/rh/ruby200/root/usr/share/gems/gems/thin-1.3.1/lib/thin/connection.rb:38:in `receive_data'
/opt/rh/ruby200/root/usr/share/gems/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run_machine'
/opt/rh/ruby200/root/usr/share/gems/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run'
/opt/rh/ruby200/root/usr/share/gems/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'
/opt/rh/ruby200/root/usr/share/gems/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/handler/thin.rb:13:in `run'
/opt/rh/cfme-gemset/gems/rack-1.4.5/lib/rack/server.rb:268:in `start'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/commands/server.rb:70:in `start'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/commands.rb:55:in `block in <top (required)>'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/commands.rb:50:in `tap'
/opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'

Comment 3 CFME Bot 2015-06-25 21:52:38 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/e39ae148233c2af2b965e6f54e2fd245f49a96ba

commit e39ae148233c2af2b965e6f54e2fd245f49a96ba
Author:     Martin Hradil <mhradil>
AuthorDate: Thu Jun 25 14:33:19 2015 +0000
Commit:     Martin Hradil <mhradil>
CommitDate: Thu Jun 25 14:33:19 2015 +0000

    host/create: Set host custom attributes only when *not* validating
    
    Possibly rails4 related, adding a new host with a custom attribute
    (Custom Identifier) would trigger an exception
    ([ActiveRecord::RecordNotSaved] You cannot call create unless the parent is saved).
    
    Since set_record_vars is called with mode=:validate, then saved and then
    set_record_vars is called without validate, we can simply hold off
    setting the custom attribute until we're not validating.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1232281

 vmdb/app/controllers/host_controller.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comment 4 CFME Bot 2015-08-19 21:18:10 UTC
New commit detected on cfme/5.4.z:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme.git;a=commitdiff;h=f7f977e16d8d4bafcee1b152f899db8d60bad229

commit f7f977e16d8d4bafcee1b152f899db8d60bad229
Author:     Martin Hradil <mhradil>
AuthorDate: Thu Jun 25 14:33:19 2015 +0000
Commit:     Martin Hradil <mhradil>
CommitDate: Wed Aug 19 13:18:49 2015 +0000

    host/create: Set host custom attributes only when *not* validating
    
    Possibly rails4 related, adding a new host with a custom attribute
    (Custom Identifier) would trigger an exception
    ([ActiveRecord::RecordNotSaved] You cannot call create unless the parent is saved).
    
    Since set_record_vars is called with mode=:validate, then saved and then
    set_record_vars is called without validate, we can simply hold off
    setting the custom attribute until we're not validating.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1232281
    (cherry picked from commit e39ae148233c2af2b965e6f54e2fd245f49a96ba)

 vmdb/app/controllers/host_controller.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comment 5 CFME Bot 2015-08-19 22:07:48 UTC
New commit detected on cfme/5.4.z:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme.git;a=commitdiff;h=f7f977e16d8d4bafcee1b152f899db8d60bad229

commit f7f977e16d8d4bafcee1b152f899db8d60bad229
Author:     Martin Hradil <mhradil>
AuthorDate: Thu Jun 25 14:33:19 2015 +0000
Commit:     Martin Hradil <mhradil>
CommitDate: Wed Aug 19 13:18:49 2015 +0000

    host/create: Set host custom attributes only when *not* validating
    
    Possibly rails4 related, adding a new host with a custom attribute
    (Custom Identifier) would trigger an exception
    ([ActiveRecord::RecordNotSaved] You cannot call create unless the parent is saved).
    
    Since set_record_vars is called with mode=:validate, then saved and then
    set_record_vars is called without validate, we can simply hold off
    setting the custom attribute until we're not validating.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1232281
    (cherry picked from commit e39ae148233c2af2b965e6f54e2fd245f49a96ba)

 vmdb/app/controllers/host_controller.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comment 6 CFME Bot 2015-08-19 22:28:16 UTC
New commit detected on cfme/5.4.z:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme.git;a=commitdiff;h=f7f977e16d8d4bafcee1b152f899db8d60bad229

commit f7f977e16d8d4bafcee1b152f899db8d60bad229
Author:     Martin Hradil <mhradil>
AuthorDate: Thu Jun 25 14:33:19 2015 +0000
Commit:     Martin Hradil <mhradil>
CommitDate: Wed Aug 19 13:18:49 2015 +0000

    host/create: Set host custom attributes only when *not* validating
    
    Possibly rails4 related, adding a new host with a custom attribute
    (Custom Identifier) would trigger an exception
    ([ActiveRecord::RecordNotSaved] You cannot call create unless the parent is saved).
    
    Since set_record_vars is called with mode=:validate, then saved and then
    set_record_vars is called without validate, we can simply hold off
    setting the custom attribute until we're not validating.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1232281
    (cherry picked from commit e39ae148233c2af2b965e6f54e2fd245f49a96ba)

 vmdb/app/controllers/host_controller.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comment 7 CFME Bot 2015-08-19 23:01:49 UTC
New commit detected on cfme/5.4.z:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme.git;a=commitdiff;h=f7f977e16d8d4bafcee1b152f899db8d60bad229

commit f7f977e16d8d4bafcee1b152f899db8d60bad229
Author:     Martin Hradil <mhradil>
AuthorDate: Thu Jun 25 14:33:19 2015 +0000
Commit:     Martin Hradil <mhradil>
CommitDate: Wed Aug 19 13:18:49 2015 +0000

    host/create: Set host custom attributes only when *not* validating
    
    Possibly rails4 related, adding a new host with a custom attribute
    (Custom Identifier) would trigger an exception
    ([ActiveRecord::RecordNotSaved] You cannot call create unless the parent is saved).
    
    Since set_record_vars is called with mode=:validate, then saved and then
    set_record_vars is called without validate, we can simply hold off
    setting the custom attribute until we're not validating.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1232281
    (cherry picked from commit e39ae148233c2af2b965e6f54e2fd245f49a96ba)

 vmdb/app/controllers/host_controller.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comment 8 CFME Bot 2015-08-20 00:31:27 UTC
New commit detected on cfme/5.4.z:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme.git;a=commitdiff;h=f7f977e16d8d4bafcee1b152f899db8d60bad229

commit f7f977e16d8d4bafcee1b152f899db8d60bad229
Author:     Martin Hradil <mhradil>
AuthorDate: Thu Jun 25 14:33:19 2015 +0000
Commit:     Martin Hradil <mhradil>
CommitDate: Wed Aug 19 13:18:49 2015 +0000

    host/create: Set host custom attributes only when *not* validating
    
    Possibly rails4 related, adding a new host with a custom attribute
    (Custom Identifier) would trigger an exception
    ([ActiveRecord::RecordNotSaved] You cannot call create unless the parent is saved).
    
    Since set_record_vars is called with mode=:validate, then saved and then
    set_record_vars is called without validate, we can simply hold off
    setting the custom attribute until we're not validating.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1232281
    (cherry picked from commit e39ae148233c2af2b965e6f54e2fd245f49a96ba)

 vmdb/app/controllers/host_controller.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comment 9 Aziza Karol 2015-09-21 12:26:21 UTC
Verified and working fine in 5.5.0.1-alpha1.20150915151429_2230bd4

Comment 11 errata-xmlrpc 2015-12-08 13:13:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2015:2551