-
Notifications
You must be signed in to change notification settings - Fork 993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #4198 - API v2 - add child nodes to show responses. Ex. architecture should show operating systems node #1208
Conversation
@@ -2,5 +2,6 @@ object @hostgroup | |||
|
|||
extends "api/v2/hostgroups/base" | |||
|
|||
attributes :subnet_id, :subnet_name, :operatingsystem_id, :operatingsystem_name, :domain_id, :domain_name, :environment_id, :environment_name, | |||
:compute_profile_id, :compute_profile_name, :ancestry, :parameters, :puppetclass_ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:parameters, :puppetclass_ids
were removed here and moved to child nodes in show.json.rabl
@@ -11,3 +11,11 @@ end | |||
child :operatingsystems, :object_root => false do | |||
extends "api/v2/operatingsystems/base" | |||
end | |||
|
|||
child :environments, :object_root => false do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say either remove this, or add host groups here, since config templates are associated with env/host.
Because we have template combinations though, I'd prefer to remove environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@domcleal, removing environments
Could you check the test failure too please? |
Do you want to address http://projects.theforeman.org/issues/4349 too, and add orgs/loc child nodes? |
@domcleal, I was looking at this issue now. |
this is really strange that the 2 failing tests pass locally for me. My is that SETTINGS[:locations_enabled] or SETTINGS[:organizations_enabled] is not being read as true. |
@@ -20,6 +20,8 @@ | |||
# need to restart spork for it take effect. | |||
|
|||
ENV["RAILS_ENV"] = "test" | |||
SETTINGS[:locations_enabled] = true | |||
SETTINGS[:organizations_enabled] = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-committed after adding these two lines
@isratrade getting some test failures? |
The test failures are strange since it passes locally. I thought adding SETTINGS[:locations_enabled] = true to test_helper.rb would work, but it doesn't. Any ideas what could be on my local setup that isn't on Jenkins?? |
@domcleal, I just ran the tests again and no failures on my local dev |
Jenkins already sets locations/orgs_enabled in settings.yaml before running tests, so there shouldn't be anything different.... |
Something Bad happened on the last test run, I'd suggest running In any case, I'm able to reproduce four test failures locally: https://gist.github.com/domcleal/9068336 |
Quick investigation into the first error shows this response being formed: Rendered api/v1/errors/unprocessable_entity.json.rabl (1.7ms) Body: {"config_template":{"id":1007981701,"errors":{"base":["centos5_3_pxelinux is used by #<OsDefaultTemplate:0x000 0000d605b28>","centos5_3_pxelinux is used by #<OsDefaultTemplate:0x0000000d7480d0>"]},"full_messages":["centos5_3_pxelinux is used by #<OsDefaultTemplate:0x0000000d605b28>","centos5_3_pxelinux is used by #<OsDefaultTemplate:0x0000000d7480d0>"]}} Completed 422 Unprocessable Entity in 192.3ms (Views: 8.4ms | ActiveRecord: 3.2ms) But then later in the request, the error handling throws an error too, causing the response code to change to 500! 1 resource have no errors (RuntimeError) 2 /home/dcleal/code/foreman/foreman/app/controllers/api/base_controller.rb:74:in `process_resource_error' 3 /home/dcleal/code/foreman/foreman/app/controllers/api/base_controller.rb:93:in `process_response' 4 /home/dcleal/code/foreman/foreman/app/controllers/api/v1/config_templates_controller.rb:72:in `destroy' |
Hmm, I get entirely different failures to Jenkins, strange. |
created new branch from develop. cherry-picked and --amend both commits. all tests pass locally. let's hope they pass on our good friend jenkins |
still same 2 failing tests, can any else download this patch and run the tests locally. It's hard to debug when it passes for me locally. @GregSutcliffe, @elobato |
Tested it locally, maybe this will shed some light on this: (rdb:1) Domain.first.locations
[#<Location id: 255093256, name: "Location 1", type: "Location", created_at: "2014-02-18 20:08:44", updated_at: "2014-02-18 20:08:44", ignore_types: []>]
(rdb:1) Domain.first.organizations
[#<Organization id: 447626438, name: "Organization 1", type: "Organization", created_at: "2014-02-18 20:08:44", updated_at: "2014-02-18 20:08:44", ignore_types: []>]
88 debugger
=> 89 assert show_response.keys.include?(node), "'#{node}' child node should be in response but was not"
90 end
91 end
92
93 end
(rdb:1) show_response
{"id"=>22495316, "name"=>"mydomain.net", "fullname"=>nil, "dns_id"=>113629430, "created_at"=>"2014-02-18T20:08:44Z", "updated_at"=>"2014-02-18T20:08:44Z", "parameters"=>[{"id"=>665394701, "name"=>"parameter", "value"=>"value1"}], "interfaces"=>[], "taxonomies"=>[{"id"=>447626438, "name"=>"Organization 1"}], "subnets"=>[]} The "taxonomies" subnode is created by partial("api/v2/taxonomies/children_nodes", :object => domain) instead of "organizations" and "locations". |
@elobato, here is what I get when I inspect {"id"=>22495316, "name"=>"mydomain.net", "fullname"=>nil, "dns_id"=>113629430, "created_at"=>"2014-02-19T07:36:03Z", "updated_at"=>"2014-02-19T07:36:03Z", "parameters"=>[{"id"=>665394701, "name"=>"parameter", "value"=>"value1"}], "interfaces"=>[], "locations"=>[{"id"=>255093256, "name"=>"Location 1"}], "organizations"=>[{"id"=>447626438, "name"=>"Organization 1"}], "subnets"=>[]} I have nodes organizations" and "locations" and no node "taxonomies" like you have. I wonder what the difference in our code base. |
@@ -15,7 +15,7 @@ gem 'scoped_search', '>= 2.5' | |||
gem 'net-ldap' | |||
gem 'uuidtools' | |||
gem "apipie-rails", "~> 0.0.23" | |||
gem 'rabl', '>= 0.7.5', '<= 0.9.0' | |||
gem 'rabl', '>= 0.7.5', '< 0.9.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isratrade hm, this could be a problem as I know @jlsherrill updated the rabl RPM to 0.9.0 recently to fix something else. Can we dig in a bit deeper and identify the issue on 0.9.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@domcleal, will do, but in that case, let's allow all 0.9.x. Any reason to limit to 0.9.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isratrade good point, I don't know why that was. I don't mind shipping a newer version, should be easy to build.
…x. architecture should show operating systems node
@@ -0,0 +1,11 @@ | |||
if SETTINGS[:locations_enabled] | |||
child :locations => :locations do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should do the trick.
+ child :locations => :locations
I tried tries, but it causes an error and apparently :object_root => false isn't needed like I thought.
child :locations => :locations, :object_root => false
Somebody else also reported this issue from 0.9 to 0.9 on STI models nesquena/rabl#505
…nodes to user, domain, subnet, etc show json templates
@isratrade nice one. There are still a few unresolved comments above, particularly for interfaces and environments versus template combinations - could you double check these please? |
@domcleal, changes per your and @GregSutcliffe's comments. |
@@ -2,22 +2,30 @@ object @operatingsystem | |||
|
|||
extends "api/v2/operatingsystems/main" | |||
|
|||
child :media, :object_root => false do | |||
node do |operatingsystem| | |||
{ :parameters => partial("api/v2/parameters/base", :object => operatingsystem.parameters) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[fixed] What's going on here, shouldn't this be a child node?
Merged as d8b61e3, 8d113bd for Foreman 1.5.0, thanks @isratrade. |
No description provided.