Closed xjparkerx closed 4 years ago
You should try to upgrade your plugin: 0.5.5 is old now. Vmid generation has been already fixed in newer versions.
The plugin suggest next vmid but you can specify which one you want. Upgrade to 0.8.3+ and test again. If you have still a bug you could post it in issues.
Describe the bug I am getting invalid vmid when I try to create a new vm using the foreman api.
To Reproduce Steps to reproduce the behavior: Post a vm config to the foreman api using a rest client.
Expected behavior A new vm should be created
Desktop (please complete the following information):
Foreman and plugin versions foreman = 1.20.3 proxmox = 5.3-12 foreman_proxmox_plugin = 0.5.5-1
Additional context
from foreman production.log 2019-05-13T09:32:17 [D|app|e48dd] new_server_vm() vm.config= <Fog::Compute::Proxmox::ServerConfig vmid=104, digest=nil, description=nil, ostype="l26", smbios1=nil, numa="1", kvm="1", vcpus=nil, cores="4", bootdisk=nil, onboot="0", boot=nil, agent="0", scsihw="virtio-scsi-pci", sockets="2", memory=17179869184, min_memory=nil, shares=nil, balloon=0, name="foreman_1557754337", cpu="cputype=kvm64", cpulimit=nil, cpuunits=nil, keyboard="en-us", vga="std", interfaces= <Fog::Compute::Proxmox::Interfaces [ <Fog::Compute::Proxmox::Interface id="net0", mac=nil, model="virtio", name=nil, ip=nil, ip6=nil, bridge="vmbr0", firewall=nil, link_down=nil, rate=nil, queues=nil, tag=nil
Foreman::Exception: ERF42-8295 [Foreman::Exception]: invalid vmid=0 /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_fog_proxmox-0.5.5/app/models/foreman_fog_proxmox/proxmox.rb:229:in'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/mapper.rb:48:in
create_vm' /usr/share/foreman/app/models/concerns/orchestration/compute.rb:86:in
setCompute' /usr/share/foreman/app/models/concerns/orchestration.rb:222:inexecute' /usr/share/foreman/app/models/concerns/orchestration.rb:145:in
block in process' /usr/share/foreman/app/models/concerns/orchestration.rb:137:ineach' /usr/share/foreman/app/models/concerns/orchestration.rb:137:in
process' /usr/share/foreman/app/models/concerns/orchestration.rb:44:inaround_save_orchestration' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in
block in run_callbacks' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:136:inrun_callbacks' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:816:in
_run_save_callbacks' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/callbacks.rb:342:increate_or_update' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/persistence.rb:275:in
save' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/validations.rb:46:insave' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:310:in
block (2 levels) in save' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:387:inblock in with_transaction_returning_status' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in
block in transaction' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:239:inblock in within_new_transaction' /opt/rh/rh-ruby25/root/usr/share/ruby/monitor.rb:226:in
mon_synchronize' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:236:inwithin_new_transaction' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in
transaction' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:212:intransaction' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:385:in
with_transaction_returning_status' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:310:inblock in save' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:325:in
rollback_active_record_state!' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:309:insave' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/suppressor.rb:44:in
save' /usr/share/foreman/app/models/concerns/foreman/sti.rb:26:insave' /usr/share/foreman/app/controllers/api/v2/hosts_controller.rb:145:in
create' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/basic_implicit_render.rb:6:insend_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:194:in
process_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/rendering.rb:30:inprocess_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:42:in
block in process_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:109:inblock in run_callbacks' /usr/share/foreman/app/controllers/api/v2/base_controller.rb:163:in
disable_json_root' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:inblock in run_callbacks' /usr/share/foreman/app/controllers/concerns/application_shared.rb:15:in
set_timezone' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:inblock in run_callbacks' /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in
clear_thread' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:inblock in run_callbacks' /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in
set_topbar_sweeper_controller' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:inblock in run_callbacks' /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.7.1/lib/audited/sweeper.rb:14:in
around' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:inblock in run_callbacks' /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.7.1/lib/audited/sweeper.rb:14:in
around' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:inblock in run_callbacks' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:136:in
run_callbacks' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:41:inprocess_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/rescue.rb:22:in
process_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:34:inblock in process_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in
block in instrument' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb:23:ininstrument' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in
instrument' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:32:inprocess_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/params_wrapper.rb:256:in
process_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/railties/controller_runtime.rb:24:inprocess_action' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:134:in
process' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/rendering.rb:32:inprocess' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal.rb:191:in
dispatch' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal.rb:252:indispatch' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:52:in
dispatch' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:34:inserve' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/mapper.rb:18:in
block inserve' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:52:in
block in serve' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:ineach' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in
serve' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:840:incall' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.14/lib/apipie/static_dispatcher.rb:65:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.14/lib/apipie/extractor/recorder.rb:137:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:incall' /usr/share/foreman/lib/middleware/telemetry.rb:9:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.14/lib/apipie/middleware/checksum_in_headers.rb:27:incall' /usr/share/foreman/lib/middleware/catch_json_parse_errors.rb:8:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/tempfile_reaper.rb:15:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/etag.rb:25:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/conditional_get.rb:38:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/head.rb:12:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/http/content_security_policy.rb:18:incall' /usr/share/foreman/lib/middleware/logging_context.rb:23:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:232:incontext' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:226:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/cookies.rb:670:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in
block in call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:98:inrun_callbacks' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:26:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:61:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/rack/logger.rb:38:incall_app' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/rack/logger.rb:28:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/remote_ip.rb:81:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/request_id.rb:27:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/method_override.rb:22:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/runtime.rb:22:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/executor.rb:14:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/sendfile.rb:111:incall' /opt/theforeman/tfm/root/usr/share/gems/gems/secure_headers-6.0.0/lib/secure_headers/middleware.rb:13:in
call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/engine.rb:524:incall' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/railtie.rb:190:in
public_send' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/railtie.rb:190:inmethod_missing' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:68:in
block in call' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:53:ineach' /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in
call' /usr/share/passenger/phusion_passenger/rack/thread_handler_extension.rb:74:inprocess_request' /usr/share/passenger/phusion_passenger/request_handler/thread_handler.rb:141:in
accept_and_process_next_request' /usr/share/passenger/phusion_passenger/request_handler/thread_handler.rb:109:inmain_loop' /usr/share/passenger/phusion_passenger/request_handler.rb:455:in
block (3 levels) in start_threads' /opt/theforeman/tfm/root/usr/share/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context' 2019-05-13T09:32:18 [D|app|e48dd] Cache write: 2d5d465d-3b26-4b28-9959-da6d15e52c2f ({:expires_in=>5 minutes}) 2019-05-13T09:32:18 [W|app|e48dd] Rolling back due to a problem: [#<Orchestration::Task:0x00007f945f565180 @name="Set up compute instance api-test.eng.fireeye.com", @id="Set up compute instance api-test.eng.fireeye.com", @status="failed", @priority=2, @action=[#<Host::Managed id: nil, name: "api-test.eng.fireeye.com", last_compile: nil, last_report: nil, updated_at: nil, created_at: nil, root_pass: "$5$kBpvFps2D4ORwBGR$ABdQoGXKHjv/zkYjUnp5oqwnBjl5dc...", architecture_id: 1, operatingsystem_id: 18, environment_id: nil, ptable_id: 118, medium_id: 9, build: false, comment: nil, disk: nil, installed_at: nil, model_id: nil, hostgroup_id: 19, owner_id: 4, owner_type: "User", enabled: true, puppet_ca_proxy_id: nil, managed: true, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: 4, puppet_proxy_id: nil, certname: nil, image_id: nil, organization_id: nil, location_id: nil, type: "Host::Managed", otp: nil, realm_id: nil, compute_profile_id: 6, provision_method: nil, grub_pass: "$5$kBpvFps2D4ORwBGR$ABdQoGXKHjv/zkYjUnp5oqwnBjl5dc...", global_status: 0, lookup_value_matcher: "fqdn=api-test.eng.fireeye.com", pxe_loader: nil, discovery_rule_id: nil, initiated_at: nil, build_errors: nil>, :setCompute], @created=1557754338.1082678, @timestamp=2019-05-13 13:32:18 UTC>] 2019-05-13T09:32:18 [I|app|e48dd] Processed 1 tasks from queue 'Host::Managed Main', completed 0/8 2019-05-13T09:32:18 [E|app|e48dd] Task 'Set up compute instance api-test.eng.fireeye.com' failed 2019-05-13T09:32:18 [E|app|e48dd] Task 'Query instance details for api-test.eng.fireeye.com' canceled 2019-05-13T09:32:18 [E|app|e48dd] Task 'Create DHCP Settings for api-test.eng.fireeye.com' canceled 2019-05-13T09:32:18 [E|app|e48dd] Task 'Create IPv4 DNS record for api-test.eng.fireeye.com' canceled 2019-05-13T09:32:18 [E|app|e48dd] Task 'Deploy TFTP PXELinux config for api-test.eng.fireeye.com' canceled 2019-05-13T09:32:18 [E|app|e48dd] Task 'Deploy TFTP PXEGrub2 config for api-test.eng.fireeye.com' canceled 2019-05-13T09:32:18 [E|app|e48dd] Task 'Deploy TFTP PXEGrub config for api-test.eng.fireeye.com' canceled 2019-05-13T09:32:18 [E|app|e48dd] Task 'Deploy TFTP iPXE config for api-test.eng.fireeye.com' canceled 2019-05-13T09:32:18 [E|app|e48dd] Unprocessable entity Host::Managed (id: new): Failed to create a compute elrond (Proxmox) instance api-test.eng.fireeye.com: ERF42-8295 [Foreman::Exception]: invalid vmid=02019-05-13T09:32:18 [I|app|e48dd] Rendering api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout 2019-05-13T09:32:18 [I|app|e48dd] Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (1.8ms) 2019-05-13T09:32:18 [D|app|e48dd] Body: { "error": {"id":null,"errors":{"base":["Failed to create a compute elrond (Proxmox) instance api-test.eng.fireeye.com: ERF42-8295 [Foreman::Exception]: invalid vmid=0\n "]},"full_messages":["Failed to create a compute elrond (Proxmox) instance api-test.eng.fireeye.com: ERF42-8295 [Foreman::Exception]: invalid vmid=0\n "]} }
2019-05-13T09:32:18 [I|app|e48dd] Completed 422 Unprocessable Entity in 4414ms (Views: 3.8ms | ActiveRecord: 89.7ms) 2019-05-13T09:32:22 [I|app|] Started GET "/" for 10.35.133.57 at 2019-05-13 09:32:22 -0400