Project

General

Profile

Bug #4018

API host creation fails with 500 error when unattended == false

Added by Tomáš Strachota almost 8 years ago. Updated almost 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

Host creation ends up with error 500 caused by missing compute_attributes accessor on attended installations.

unknown attribute: compute_attributes (ActiveRecord::UnknownAttributeError)
/root/foreman/vendor/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/attribute_assignment.rb:88:in `block in assign_attributes'
/root/foreman/vendor/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/attribute_assignment.rb:78:in `each'
/root/foreman/vendor/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
/root/foreman/vendor/ruby/1.9.1/gems/activerecord-3.2.15/lib/active_record/base.rb:498:in `initialize'
/root/foreman/app/models/concerns/foreman/sti.rb:22:in `new'
/root/foreman/app/models/concerns/foreman/sti.rb:22:in `new_with_cast'
/root/foreman/app/models/host.rb:16:in `method_missing'
/root/foreman/app/controllers/api/v2/hosts_controller.rb:62:in `create'

Related issues

Related to Foreman - Refactor #10413: Reimplement !unattended mode support as mainline featureNew2015-05-07

History

#1 Updated by Michael Griffin over 7 years ago

This problem extends to any host updates, as well as creations, via the hammer cli and it still exists in 1.4.1.

#2 Updated by Marcus Philip over 7 years ago

This makes the CLI effectively read-only... ;(
Is there no workaround?

#3 Updated by Dominic Cleal over 7 years ago

Is this definitely on the API side? I noticed today (see #6342) that hammer always passes compute attributes to the API.

#4 Updated by Michael Griffin over 7 years ago

I think that's exactly the issue... hammer always passes compute_attributes during host operations. The problem is that if Unattended==False, then Foreman doesn't know what 'compute_attributes' is and fails any host-update operations.

Could a workaround be that if Unattended==False, Foreman still define 'compute_attributes', but just throw the values on the floor?

#5 Updated by James Kyle almost 7 years ago

I'm getting this error in foreman 1.7 on CentOS 7. I receive the error using all of the following methods for updating a host:

- hammer host update
- curl -H "Content-Type: application/json" -u admin:$password -k --fail --silent -X PUT -d '{"host": {"hostgroup_id": 1}}' "https://ops1.zone1.example.com/api/v2/hosts/ops1.zone1.example.com"
- python requests module

hammer debug output is:

[root@ops1 ~]# /usr/bin/hammer -d host update --hostgroup ops1.zone1.example.com --name ops1.zone1.example.com
[ INFO 2015-02-24 13:29:56 Init] Initialization of Hammer CLI (0.1.3) has started...
[DEBUG 2015-02-24 13:29:56 Init] Running at ruby 2.0.0-p353
[ INFO 2015-02-24 13:29:56 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2015-02-24 13:29:56 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2015-02-24 13:29:56 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
[DEBUG 2015-02-24 13:29:57 Connection] Registered: foreman
[DEBUG 2015-02-24 13:29:57 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en" 
}
[ INFO 2015-02-24 13:29:57 Modules] Extension module hammer_cli_foreman (0.1.3) loaded
[DEBUG 2015-02-24 13:29:57 Init] Using locale 'en'
[DEBUG 2015-02-24 13:29:57 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/usr/share/gems/gems/hammer_cli-0.1.3/locale'
[DEBUG 2015-02-24 13:29:57 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/usr/share/locale'
[DEBUG 2015-02-24 13:29:57 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/usr/share/gems/gems/hammer_cli_foreman-0.1.3/locale'
[DEBUG 2015-02-24 13:29:57 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/usr/share/locale'
[ INFO 2015-02-24 13:29:57 HammerCLI::MainCommand] Called with options: {"option_debug"=>true}
[ INFO 2015-02-24 13:29:57 HammerCLIForeman::Host] Called with options: {}
[ INFO 2015-02-24 13:29:57 HammerCLIForeman::Host::UpdateCommand] Called with options: {"option_volume_list"=>[], "option_interface_list"=>[], "option_name"=>"ops1.zone1.example.com", "option_hostgroup_name"=>"ops1.zone1.example.com"}
[ INFO 2015-02-24 13:29:57 API] GET /api/hostgroups
[DEBUG 2015-02-24 13:29:57 API] Params: {
    :search => "name = \"ops1.zone1.example.com\"" 
}
[DEBUG 2015-02-24 13:29:57 API] Headers: {
    :params => {
        :search => "name = \"ops1.zone1.example.com\"" 
    }
}
[DEBUG 2015-02-24 13:29:57 API] Response: {
       "total" => 1,
    "subtotal" => 1,
        "page" => 1,
    "per_page" => 20,
      "search" => "name = \"ops1.zone1.example.com\"",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => [
        [0] {
                              "id" => 1,
                            "name" => "ops1.zone1.example.com",
                           "title" => "ops1.zone1.example.com",
                       "subnet_id" => 1,
                     "subnet_name" => "Management",
              "operatingsystem_id" => 2,
            "operatingsystem_name" => "Ubuntu 14.04",
                       "domain_id" => 1,
                     "domain_name" => "zone1.example.com",
                  "environment_id" => 3,
                "environment_name" => "testing",
              "compute_profile_id" => nil,
            "compute_profile_name" => nil,
                        "ancestry" => nil,
                 "puppet_proxy_id" => 1,
              "puppet_ca_proxy_id" => 1,
                       "ptable_id" => 8,
                     "ptable_name" => "Preseed default",
                       "medium_id" => 6,
                     "medium_name" => "Ubuntu mirror",
                 "architecture_id" => 1,
               "architecture_name" => "x86_64",
                        "realm_id" => nil,
                      "realm_name" => nil,
                      "created_at" => "2015-02-24T19:58:32Z",
                      "updated_at" => "2015-02-24T19:58:32Z" 
        }
    ]
}
[DEBUG 2015-02-24 13:29:57 API] Response headers: {
                   :date => "Tue, 24 Feb 2015 21:29:57 GMT",
                 :server => "Apache/2.4.6 (CentOS)",
        :foreman_version => "1.7.2",
    :foreman_api_version => "2",
        :apipie_checksum => "b11cc24f3ad4868cff40aeabbae5e069",
        :x_ua_compatible => "IE=Edge,chrome=1",
          :cache_control => "must-revalidate, private, max-age=0",
           :x_request_id => "c6e19c98cc3643177c2ec45de40212cf",
              :x_runtime => "0.034948",
           :x_rack_cache => "miss",
           :x_powered_by => "Phusion Passenger 4.0.18",
             :set_cookie => [
        [0] "_session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTk5OWFjZjM3OWRjZTZlMjk5OGI4MGZmMGVhOTU3NTkzBjsAVEkiC2xvY2FsZQY7AEYiB2Vu--739a59fec19f4a6beb0ad49bd42f6274337ac115; path=/; HttpOnly" 
    ],
                   :etag => "\"15a8ffa67fb848ba473737549950eeac\"",
                 :status => "200 OK",
             :connection => "close",
      :transfer_encoding => "chunked",
           :content_type => "application/json; charset=utf-8" 
}
[ INFO 2015-02-24 13:29:57 API] GET /api/hosts
[DEBUG 2015-02-24 13:29:57 API] Params: {
    :search => "name = \"ops1.zone1.example.com\"" 
}
[DEBUG 2015-02-24 13:29:57 API] Headers: {
    :params => {
        :search => "name = \"ops1.zone1.example.com\"" 
    }
}
[DEBUG 2015-02-24 13:29:57 API] Response: {
       "total" => 2,
    "subtotal" => 1,
        "page" => 1,
    "per_page" => 20,
      "search" => "name = \"ops1.zone1.example.com\"",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => [
        [0] {
                             "name" => "ops1.zone1.example.com",
                               "id" => 1,
                               "ip" => "172.16.156.131",
                   "environment_id" => 3,
                 "environment_name" => "testing",
                      "last_report" => "2015-02-24T21:26:38Z",
                              "mac" => "00:0c:29:d6:49:53",
                         "realm_id" => nil,
                       "realm_name" => nil,
                           "sp_mac" => nil,
                            "sp_ip" => nil,
                          "sp_name" => nil,
                        "domain_id" => 1,
                      "domain_name" => "zone1.example.com",
                  "architecture_id" => 1,
                "architecture_name" => "x86_64",
               "operatingsystem_id" => 1,
             "operatingsystem_name" => "CentOS 7.0",
                        "subnet_id" => nil,
                      "subnet_name" => nil,
                     "sp_subnet_id" => nil,
                        "ptable_id" => nil,
                      "ptable_name" => nil,
                        "medium_id" => nil,
                      "medium_name" => nil,
                            "build" => false,
                          "comment" => nil,
                             "disk" => nil,
                     "installed_at" => nil,
                         "model_id" => 1,
                       "model_name" => "VMware Virtual Platform",
                     "hostgroup_id" => nil,
                   "hostgroup_name" => nil,
                         "owner_id" => 3,
                       "owner_type" => "User",
                          "enabled" => true,
               "puppet_ca_proxy_id" => 1,
                          "managed" => false,
                        "use_image" => nil,
                       "image_file" => "",
                             "uuid" => nil,
              "compute_resource_id" => nil,
            "compute_resource_name" => nil,
               "compute_profile_id" => nil,
             "compute_profile_name" => nil,
                     "capabilities" => [
                [0] "build" 
            ],
                 "provision_method" => "build",
                  "puppet_proxy_id" => 1,
                         "certname" => "ops1.zone1.example.com",
                         "image_id" => nil,
                       "image_name" => nil,
                       "created_at" => "2015-02-24T19:53:38Z",
                       "updated_at" => "2015-02-24T21:26:42Z",
                     "last_compile" => "2015-02-24T21:26:41Z",
                  "last_freshcheck" => nil,
                           "serial" => nil,
                   "source_file_id" => nil,
                    "puppet_status" => 0
        }
    ]
}
[DEBUG 2015-02-24 13:29:57 API] Response headers: {
                   :date => "Tue, 24 Feb 2015 21:29:57 GMT",
                 :server => "Apache/2.4.6 (CentOS)",
        :foreman_version => "1.7.2",
    :foreman_api_version => "2",
        :apipie_checksum => "b11cc24f3ad4868cff40aeabbae5e069",
        :x_ua_compatible => "IE=Edge,chrome=1",
          :cache_control => "must-revalidate, private, max-age=0",
           :x_request_id => "6ad3c1a518f9ff4739fd5ac7b2449227",
              :x_runtime => "0.123171",
           :x_rack_cache => "miss",
           :x_powered_by => "Phusion Passenger 4.0.18",
             :set_cookie => [
        [0] "_session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY4NTE1NTMzZGViNWRmOWJjZWIxY2NmYjZmYTk4OTI2BjsAVEkiC2xvY2FsZQY7AEYiB2Vu--f778da37f50903d067ff81de0c6d94544e72074e; path=/; HttpOnly" 
    ],
                   :etag => "\"ef38923176e8a047fb50f2c45352d62b\"",
                 :status => "200 OK",
             :connection => "close",
      :transfer_encoding => "chunked",
           :content_type => "application/json; charset=utf-8" 
}
[ INFO 2015-02-24 13:29:57 API] PUT /api/hosts/1
[DEBUG 2015-02-24 13:29:57 API] Params: {
    "host" => {
                              "name" => "ops1.zone1.example.com",
                      "hostgroup_id" => 1,
                "compute_attributes" => {
            "volumes_attributes" => {}
        },
        "host_parameters_attributes" => {},
             "interfaces_attributes" => {}
    }
}
[DEBUG 2015-02-24 13:29:57 API] Headers: {}
[DEBUG 2015-02-24 13:29:57 API] 500 Internal Server Error
{
    "error" => {
        "message" => "No such file or directory - true" 
    }
}
[ERROR 2015-02-24 13:29:57 Exception] No such file or directory - true
Could not update the host:
  No such file or directory - true
[ERROR 2015-02-24 13:29:57 Exception]

RestClient::InternalServerError (500 Internal Server Error):
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:234:in `process_result'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:182:in `block in transmit'
    /usr/share/ruby/net/http.rb:852:in `start'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:176:in `transmit'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:65:in `execute'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:34:in `execute'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/resource.rb:76:in `put'
    /usr/share/gems/gems/apipie-bindings-0.0.10/lib/apipie_bindings/api.rb:199:in `http_call'
    /usr/share/gems/gems/apipie-bindings-0.0.10/lib/apipie_bindings/api.rb:153:in `call'
    /usr/share/gems/gems/apipie-bindings-0.0.10/lib/apipie_bindings/resource.rb:14:in `call'
    /usr/share/gems/gems/hammer_cli-0.1.3/lib/hammer_cli/apipie/command.rb:42:in `send_request'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.3/lib/hammer_cli_foreman/commands.rb:164:in `send_request'
    /usr/share/gems/gems/hammer_cli-0.1.3/lib/hammer_cli/apipie/command.rb:33:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.3/lib/hammer_cli/abstract.rb:22:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.3/lib/hammer_cli/abstract.rb:22:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.3/lib/hammer_cli/abstract.rb:22:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:126:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.3/bin/hammer:106:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'

#6 Updated by Dominic Cleal almost 7 years ago

James, your error from the server is "No such file or directory - true" which doesn't look like the same issue as reported here. You should probably check the server side logs for more info (/var/log/foreman/production.log) to figure out where it's coming from, and open a different bug report or thread on foreman-users for help.

#7 Updated by James Kyle almost 7 years ago

@Dominic

Will do.

#9 Updated by Rickard von Essen over 6 years ago

  • Related to Refactor #10413: Reimplement !unattended mode support as mainline feature added

Also available in: Atom PDF