Project

General

Profile

Actions

Bug #28155

closed

Cannot view Compute-Profiles from a specific Compute-Resource

Added by Joerg Hinz over 4 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
High
Category:
Compute resources - VMware
Target version:
-
Difficulty:
medium
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

After upgradeing a few Foreman-releases (from 1.13 to 1.23 (all releases have been applied)), we now noticed a bit later, that all compute-profiles from ONE specific compute-resource cannot be view/edited in the GUI anymore.

Using "Infrastructure" -> "Compute Profiles" -> select one -> then the Compute Ressources are listed.

We have 5 VMware-Compute-Resources defined.

Selecting the non-problematic-ones show the menü to set up VM-specs.

Selecting the problematic Resource displays the error page with "Oops, we're sorry but something went wrong undefined method `gsub' for nil:NilClass", the full-trace starts with:

ActionView::Template::Error
undefined method `gsub' for nil:NilClass
/usr/share/foreman/app/models/concerns/fog_extensions/vsphere/folder.rb:6:in `to_label'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/helpers/form_options_helper.rb:805:in `value_for_collection'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/helpers/form_options_helper.rb:402:in `block in options_from_collection_for_select'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/helpers/form_options_helper.rb:401:in `map'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/helpers/form_options_helper.rb:401:in `options_from_collection_for_select'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/helpers/tags/collection_select.rb:23:in `render'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/helpers/form_options_helper.rb:204:in `collection_select'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/helpers/form_options_helper.rb:835:in `collection_select'
/usr/share/foreman/app/helpers/form_helper.rb:131:in `block in select_f'
/usr/share/foreman/app/helpers/form_helper.rb:379:in `block (3 levels) in field'
[...]

Is there any solution beside deleting the problematic resource (and all profiles with it)?

We would really appreciate a hint how to solve that issue.


Related issues 1 (0 open1 closed)

Has duplicate Foreman - Bug #30550: Unable to create compute profile for specific vmware compute resourceDuplicateActions
Actions #1

Updated by Joerg Hinz over 4 years ago

  • Subject changed from Cannot view Compute-Profilles from a specific Compute-Resource to Cannot view Compute-Profiles from a specific Compute-Resource
Actions #2

Updated by Tomer Brisker over 4 years ago

  • Category changed from Web Interface to Compute resources - VMware
Actions #3

Updated by Joerg Hinz over 4 years ago

  • Difficulty changed from hard to medium

Anyone?

Actions #4

Updated by Enrico Bartz over 4 years ago

Hi Jörg,

I would first of all try to get the compute profiles via hammer:

[root@node3 ~]# hammer compute-profile list
---|---------
ID | NAME
---|---------
1  | 1-Small
2  | 2-Medium
3  | 3-Large
---|---------

Then try to get more details over the CLI:

[root@node3 ~]# hammer compute-profile info --id 3
[root@node3 ~]# hammer compute-profile info --id 3
ID:                 3
Name:               3-Large
Created at:         2019/11/26 13:13:47
Updated at:         2019/11/26 13:13:47
Compute attributes:
 1) ID:               1
    Name:             4 CPUs and 16 GB memory
    Compute Resource: Xen1
    VM attributes:    {"vcpus_max"=>"4", "memory_min"=>"8489271296", "memory_max"=>"17179869184", "iso"=>"2844d010-a140-4319-81c2-59a25acd1e60", "start"=>"1", "target_sr"=>"8cbdc0ba-e536-01b0-f4c1-da54bda17df7", "builtin_template"=>"", "volumes_attributes"=>{"1574775028450"=>{"sr"=>"51cbbd45-eac9-13ff-9822-984052ddbf2a", "virtual_size_gb"=>"100"}}}

If that fails, you can still try to get something out of the database:

[root@node3 ~]# su - postgres
-bash-4.2$ psql
postgres=# \c foreman
foreman=# select * from compute_attributes;
 id | compute_profile_id | compute_resource_id |          name           |                                vm_attrs                                 |         created_at         |         updated_at
----+--------------------+---------------------+-------------------------+-------------------------------------------------------------------------+----------------------------+----------------------------
  1 |                  3 |                   1 | 4 CPUs and 16 GB memory | --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess                +| 2019-11-26 13:30:38.960835 | 2019-11-26 13:30:38.960835
    |                    |                     |                         | vcpus_max: '4'                                                         +|                            |
    |                    |                     |                         | memory_min: '8489271296'                                               +|                            |
    |                    |                     |                         | memory_max: '17179869184'                                              +|                            |
    |                    |                     |                         | iso: 2844d010-a140-4319-81c2-59a25acd1e60                              +|                            |
    |                    |                     |                         | start: '1'                                                             +|                            |
    |                    |                     |                         | target_sr: 8cbdc0ba-e536-01b0-f4c1-da54bda17df7                        +|                            |
    |                    |                     |                         | builtin_template: ''                                                   +|                            |
    |                    |                     |                         | volumes_attributes: !ruby/hash:ActiveSupport::HashWithIndifferentAccess+|                            |
    |                    |                     |                         |   '1574775028450': !ruby/hash:ActiveSupport::HashWithIndifferentAccess +|                            |
    |                    |                     |                         |     sr: 51cbbd45-eac9-13ff-9822-984052ddbf2a                           +|                            |
    |                    |                     |                         |     virtual_size_gb: '100'                                             +|                            |
    |                    |                     |                         |                                                                         |                            |
(1 row)

You can also try to find something that is different with one of your compute resources and try to eliminate that on the database level.

You could also try to create a new Compute Ressource and afterwards change the association of the profiles on database level. You probably only need to change the 'compute_resource_id' of the profile.

Anyway, before changing anything on database level, make sure to create a backup => https://theforeman.org/manuals/1.23/index.html#5.5.1Backup

Actions #5

Updated by Joerg Hinz over 4 years ago

Hi Enrico,

using hammer (# hammer compute-profile list|grep ^[0-9]|cut -d\| -f1|xargs -iXX hammer compute-profile info --id XX) no profile fails.

Since we use hammer to deploy hosts, with the existing profiles Foreman works "as is".

But yet we cannot add new (working) profiles or edit the existing profiles from that single ressource.

Any clues what I can do?

Actions #6

Updated by Joerg Hinz over 4 years ago

When I choose a random compute profile, the error occurs only when selecting this one specific compute-ressource. If I choose any other ressource, no problem.

This looks like the problem is located inside the compute ressource.

Have you got any SQL-hints what to do to figure out what is wrong with this one compute-ressource?

Question: If I delete that Ressource, and create a new one with the same name, will the profiles still work?

Actions #7

Updated by Joerg Hinz over 4 years ago

Okay, you cannot delete a compute ressource without prior removing of all associated profiles :-(

Actions #8

Updated by Joerg Hinz over 4 years ago

Interesting:

/usr/share/foreman/app/models/concerns/fog_extensions/vsphere:

Original file fails on the specific ressource:

# cat folder.rb_ORIG
module FogExtensions
  module Vsphere
    module Folder
      extend ActiveSupport::Concern
      def to_label
        path.slice((path.index(datacenter) + datacenter.length + 1)..-1).gsub('/', ' / ')
      end
    end
  end
end

If I remove the ".gsub()"-appendix:

# cat folder.rb
module FogExtensions
  module Vsphere
    module Folder
      extend ActiveSupport::Concern
      def to_label
        path.slice((path.index(datacenter) + datacenter.length + 1)..-1)
      end
    end
  end
end

Problem is gone.

So why has this specific compute ressource a problem with method `gsub', while the others not?

Actions #9

Updated by Joerg Hinz over 4 years ago

I guess Foreman works in our case without that gsub-method, because we do not deploy VMs in subfolders inside die vSphere ressource-pool/cluster.

So I would take this code-modification as "workaround".

Actions #10

Updated by Ondřej Ezr over 2 years ago

  • Has duplicate Bug #30550: Unable to create compute profile for specific vmware compute resource added
Actions #11

Updated by Ondřej Ezr over 2 years ago

  • Bugzilla link set to 1856626
Actions #12

Updated by The Foreman Bot over 2 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Bernhard Suttner
  • Pull request https://github.com/theforeman/foreman/pull/9006 added
Actions #13

Updated by The Foreman Bot over 2 years ago

  • Fixed in Releases 3.2.0 added
Actions #14

Updated by Bernhard Suttner over 2 years ago

  • Status changed from Ready For Testing to Closed
Actions #15

Updated by Ondřej Ezr over 2 years ago

  • Fixed in Releases 3.1.1 added
Actions

Also available in: Atom PDF