Hi Kyle! Try running it again with the environment variable EXCON_DEBUG=1 set to see more details from the 400 response. I did some investigation and saw this in the response body:
@data={:body=>"{\"message\":\"Validation failed.\",\"code\":400,\"details\":\"Record TTL must be greater than or equal to 300\"}" When I set my TTL to 300, the request succeeded. Give that a shot and let me know if that works for you. - Ash (Sorry if you get this twice -- I tried to send this from another address but I hadn't joined the group with that one, so I got a bounceback.) On Thursday, February 13, 2014 1:14:35 PM UTC-5, Kyle Crumpton wrote: > > Hi all. Fairly new to Fog here. I'm creating a plugin for Openshift Origin > and running into some hurdles. So I'm going to give all the information I > have here and hope for the best. > The code can be found here: > https://github.com/kcrumpto/origin-server/blob/master/plugins/dns/rackspace/lib/openshift/rackspace_plugin.rb > So I have been messing around with the Fog. My goal is to create a DNS > CNAME record each time a new application is made by adding it to my > Rackspace DNS page as an entry. > > The basic usecase is that I create an app: > > "rhc app-create test <app-type>" > The namespace is called ns in this instance. > So it will create a CNAME record on the broker called "test-ns.example.com". > It will then try to register this record with my Rackspace account so that > people outside of the broker can find the application and SSH to it. > > So here is the issue.. I am using the following code to register an > application: > def register_application(app_name,namespace,public_hostname) > fqdn="#{app_name}-#{namespace}.#{@domain_suffix}" > #create a CNAME record > update = { > :value => public_hostname, > :name => fqdn, > :type => "CNAME", > :ttl => 30 > } > Rails.logger.info "FQDN=#{fqdn}. #{@rackspace_dns_zoneid}" > Rails.logger.info "Debug message inserted by Kyle Crumpton." > zone=rackspace.zones.get(@rackspace_dns_zoneid) > res = zone.records.create(update) > end > > The @rackspace_dns_zoneid, FQDN, and update parameters all reflect > correctly what they should be. > Here is the error when I try and run this method on the Rails Console: > > irb(main):003:0> d.register_application('testapp1','testns1', ' > node1.example.com') > Fog::DNS::Rackspace::BadRequest: [HTTP 400 | ] Validation failed. - > from > /usr/local/share/gems/gems/excon-0.28.0/lib/excon/middlewares/expects.rb:6:in > `response_call' > from > /usr/local/share/gems/gems/excon-0.28.0/lib/excon/middlewares/response_parser.rb:8:in > > `response_call' > from > /usr/local/share/gems/gems/excon-0.28.0/lib/excon/connection.rb:361:in > `response' > from > /usr/local/share/gems/gems/excon-0.28.0/lib/excon/connection.rb:254:in > `request' > from > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/core/connection.rb:57:in > `request' > from > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/core/deprecated/connection.rb:20:in > > `request' > from > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/service.rb:43:in > `request' > from > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/dns.rb:115:in > `request' > from > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/requests/dns/add_records.rb:28:in > > `add_records' > from > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/models/dns/record.rb:62:in > > `create' > from > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/models/dns/record.rb:39:in > > `save' > from > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/core/collection.rb:52:in > `create' > from > /usr/local/share/gems/gems/openshift-origin-dns-rackspace-1.10.16/lib/openshift/rackspace_plugin.rb:71:in > > `register_application' > from (irb):3 > from > /usr/share/gems/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in > `start' > from > /usr/share/gems/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in > `start' > from /usr/share/gems/gems/railties-3.2.13/lib/rails/commands.rb:41:in > `<top (required)>' > from script/rails:54:in `require' > from script/rails:54:in `<main>'irb(main):004:0> > > So my question is.. has anyone ever seen anything like this happening? > Here is some more of the trace if it helps: > > > 2014-02-12 21:15:08.602 [ERROR] Encountered error during execute '[HTTP > 400 | ] Validation failed. - ' rollback pending: false (pid:1579) > 2014-02-12 21:15:14.141 [ERROR] Reference ID: > 359f13e3fdab3c0724aa01c522d32285 - [HTTP 400 | ] Validation failed. - > > /usr/local/share/gems/gems/excon-0.28.0/lib/excon/middlewares/expects.rb:6:in > `response_call' > > /usr/local/share/gems/gems/excon-0.28.0/lib/excon/middlewares/response_parser.rb:8:in > > `response_call' > /usr/local/share/gems/gems/excon-0.28.0/lib/excon/connection.rb:361:in > `response' > /usr/local/share/gems/gems/excon-0.28.0/lib/excon/connection.rb:254:in > `request' > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/core/connection.rb:57:in > `request' > > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/core/deprecated/connection.rb:20:in > > `request' > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/service.rb:43:in > `request' > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/dns.rb:115:in > `request' > > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/requests/dns/add_records.rb:28:in > > `add_records' > > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/models/dns/record.rb:62:in > > `create' > > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/rackspace/models/dns/record.rb:39:in > > `save' > /usr/local/share/gems/gems/fog-1.18.0/lib/fog/core/collection.rb:52:in > `create' > > /usr/local/share/gems/gems/openshift-origin-dns-rackspace-1.10.16/lib/openshift/rackspace_plugin.rb:71:in > > `register_application' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/gear.rb:123:in > > `register_dns' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/pending_ops/register_dns_op.rb:9:in > > `execute' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/pending_app_op_group.rb:75:in > > `block in execute' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/pending_app_op_group.rb:64:in > > `each' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/pending_app_op_group.rb:64:in > > `execute' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/application.rb:1557:in > > `run_jobs' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/application.rb:676:in > > `block in add_features' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/application.rb:1623:in > > `run_in_application_lock' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/application.rb:669:in > > `add_features' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/models/application.rb:253:in > > `create_app' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/app/controllers/applications_controller.rb:147:in > > `create' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb:4:in > > `send_action' > > /usr/share/gems/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:167:in > `process_action' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal/rendering.rb:10:in > > `process_action' > > /usr/share/gems/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:18:in > > `block in process_action' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:481:in > > `block in > _run__2585324845023905795__process_action__3526227800655018281__callbacks' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:215:in > > `block in _conditional_callback_around_386' > > /usr/share/gems/gems/openshift-origin-controller-1.18.0/lib/openshift/controller/action_log.rb:80:in > > `set_logged_request' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:214:in > > `_conditional_callback_around_386' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:403:in > > `_run__2585324845023905795__process_action__3526227800655018281__callbacks' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in > > `__run_callback' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in > > `_run_process_action_callbacks' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in > > `run_callbacks' > > /usr/share/gems/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in > > `process_action' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in > > `process_action' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in > > `block in process_action' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in > > `block in instrument' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in > > `instrument' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in > > `instrument' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in > > `process_action' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in > > `process_action' > > /usr/share/gems/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:in > `process' > > /usr/share/gems/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in > > `process' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal.rb:203:in > `dispatch' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in > > `dispatch' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_controller/metal.rb:246:in > `block in action' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in > > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in > > `dispatch' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in > > `call' > /usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in > call' > /usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:56:in `each' > /usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:56:in `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in > > `call' > > /usr/share/gems/gems/mongoid-3.1.4/lib/rack/mongoid/middleware/identity_map.rb:34:in > > `block in call' > /usr/share/gems/gems/mongoid-3.1.4/lib/mongoid/unit_of_work.rb:39:in > `unit_of_work' > > /usr/share/gems/gems/mongoid-3.1.4/lib/rack/mongoid/middleware/identity_map.rb:34:in > > `call' > /usr/share/gems/gems/sass-3.2.6/lib/sass/plugin/rack.rb:54:in `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in > > `call' > /usr/share/gems/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call' > /usr/share/gems/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in > > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in > > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in > > `call' > /usr/share/gems/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in > `context' > /usr/share/gems/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in > > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in > > `block in call' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in > > `_run__2339041322041708277__call__741858123488100523__callbacks' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in > > `__run_callback' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in > > `_run_call_callbacks' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in > > `run_callbacks' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in > > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in > > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in > > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in > > `call' > /usr/share/gems/gems/railties-3.2.13/lib/rails/rack/logger.rb:32:in > `call_app' > /usr/share/gems/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in > `block in call' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in > > `tagged' > /usr/share/gems/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in > `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in > > `call' > /usr/share/gems/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call' > /usr/share/gems/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call' > > /usr/share/gems/gems/activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in > > `call' > /usr/share/gems/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call' > > /usr/share/gems/gems/actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in > > `call' > /usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in > `forward' > /usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in > `pass' > /usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in > `invalidate' > /usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in > `call!' > /usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in > `call' > /usr/share/gems/gems/railties-3.2.13/lib/rails/engine.rb:479:in `call' > /usr/share/gems/gems/railties-3.2.13/lib/rails/application.rb:223:in > `call' > > /usr/share/gems/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in > `method_missing' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/rack/request_handler.rb:97:in > > `process_request' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_request_handler.rb:521:in > > `accept_and_process_next_request' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_request_handler.rb:274:in > > `main_loop' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/rack/application_spawner.rb:206:in > > `start_request_handler' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/rack/application_spawner.rb:171:in > > `block in handle_spawn_application' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/utils.rb:470:in > `safe_fork' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/rack/application_spawner.rb:166:in > > `handle_spawn_application' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server.rb:357:in > > `server_main_loop' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server.rb:206:in > > `start_synchronously' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server.rb:180:in > > `start' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/rack/application_spawner.rb:129:in > > `start' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/spawn_manager.rb:253:in > > `block (2 levels) in spawn_rack_application' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server_collection.rb:132:in > > `lookup_or_add' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/spawn_manager.rb:246:in > > `block in spawn_rack_application' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server_collection.rb:82:in > > `block in synchronize' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server_collection.rb:79:in > > `synchronize' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server_collection.rb:79:in > > `synchronize' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/spawn_manager.rb:244:in > > `spawn_rack_application' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/spawn_manager.rb:137:in > > `spawn_application' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/spawn_manager.rb:275:in > > `handle_spawn_application' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server.rb:357:in > > `server_main_loop' > > /usr/share/gems/gems/passenger-3.0.21/lib/phusion_passenger/abstract_server.rb:206:in > > `start_synchronously' > > /usr/share/gems/gems/passenger-3.0.21/helper-scripts/passenger-spawn-server:102:in > > `<main>' (pid:1579) > 2014-02-12 21:15:14.142 [INFO ] Completed 500 Internal Server Error in > 16029ms (Views: 0.5ms) (pid:1579) > > Now the funny part; when I run the equivalent code on my local system as a > simple ruby script it works like a charm. > > Any ideas? thank you. > -- You received this message because you are subscribed to the Google Groups "ruby-fog" group. To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.