Project

General

Profile

Actions

Refactor #24852

closed

Having empty "Allocation (GB)" when creating a new Host, nil:NilClass returned on creating the Host

Added by Ivan Necas over 6 years ago. Updated 11 months ago.

Status:
Closed
Priority:
Immediate
Category:
Host creation
Target version:
-
Difficulty:
medium
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1625258

Description of problem:
When creating a new Host and specifying on Virtual Machine tab "Allocation(GB)" as empty, Host create fails with

NoMethodError: undefined method `[]' for nil:NilClass

error. It is more user-unfriendly also due to the fact that the Allocation(GB) is purged when one clicks to "Size" button right from the value.

How reproducible:
100%

Steps to Reproduce:
1. Start creating a new Host
2. In Virtual Machine tab, click to "Size" button (or leave "Allocation(GB)" empty either way)
3. Fill all other parameters properly.
4. Submit the Host

Actual results:
Host create fails with "undefined method `[]' for nil:NilClass"

Expected results:
Either no error (if the parameter can have empty value with some meaning), or provide some meaningfull error message before tryng to create the host (e.g. similar to leaving root password empty).

Additionally, we could default to size value value in the UI, so that people don't run into the empty value issue that likely + it would provide a good example of what values are expected.

Additional info:
backtrace:
2018-09-04 15:20:37 18507e4a [app] [W] Failed to create a compute satotest (Libvirt) instance pmoravec-test.sysmgmt.lan: undefined method `[]' for nil:NilClass

NoMethodError: undefined method `[]' for nil:NilClass
/opt/theforeman/tfm/root/usr/share/gems/gems/fog-libvirt-0.2.0/lib/fog/libvirt/models/compute/volume.rb:119:in `split_size_unit'
(erb):3:in `to_xml'

Relevant code:

112 def split_size_unit(text)
113 if text.kind_of? Integer
114 # if text is an integer, match will fail
115 size = text
116 unit = 'G'
117 else
118 matcher = text.match(/(\d+)(.+)/)
119 size = matcher1
120 unit = matcher2
121 end
122 [size, unit]
123 end

that simply does not count with empty value in text

Actions

Also available in: Atom PDF