Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1994945 - hammer cannot use the cluster name or id as valid input when clusters are residing inside folders and fails with error Fog::Vsphere::Compute::NotFound error
Summary: hammer cannot use the cluster name or id as valid input when clusters are re...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Compute Resources - VMWare
Version: 6.9.0
Hardware: All
OS: Linux
high
high
Target Milestone: 6.12.0
Assignee: Chris Roberts
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
: 1993888 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-08-18 08:29 UTC by Sayan Das
Modified: 2024-12-20 20:44 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2131761 (view as bug list)
Environment:
Last Closed: 2022-11-16 13:32:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 35438 0 Normal Closed hammer cannot use the cluster name or id as valid input when clusters are residing inside folders and fails with error f... 2022-09-02 18:33:58 UTC
Github theforeman foreman pull 9383 0 None Merged Fixes #35438 - Unescape cluster on compute resource controller 2022-09-02 18:34:05 UTC
Github theforeman hammer-cli-foreman pull 604 0 None Merged Refs #35438 - Enhance VMware listing commands and switch to cluster_name param 2022-09-08 17:40:42 UTC
Red Hat Issue Tracker SAT-12371 0 None None None 2022-08-29 13:36:05 UTC
Red Hat Product Errata RHSA-2022:8506 0 None None None 2022-11-16 13:33:34 UTC

Description Sayan Das 2021-08-18 08:29:16 UTC
Description of problem:

When Clusters are residing in a folder inside datacenter, hammer cannot properly use the full_path\id\name of that cluster as an acceptable value for any operations

But Satellite UI can properly detect the full_path of the cluster and work with the same without any issues.



Version-Release number of selected component (if applicable):
Satellite 6.9 [ as well as Satellite 6.10 ]


How reproducible:
100% when certain conditions are met

DC:
  | Folder1
          : Cluster1
  | Folder2
          : Cluster2

Steps to Reproduce:

1. Ensure that in vCenter we have DC, inside DC we have a folder and inside folder we have a cluster. So full path of the cluster would be Folder1/Cluster1 i.e. in my example OT_Non-Oracle/OT_Non_Oracle_HA

2. Create a Compute resource for that vCenter and DC

3. Create two compute profiles named CP1 and CP2.

4. Configure all compute attributes for CP1 from Satellite UI

5. Configure all compute attributes for CP2 using hammer.


Actual results:

Step 5: UI is able to create the cluster without any issues and "OT_Non-Oracle/OT_Non_Oracle_HA" is an acceptable value there for cluster

2021-08-13T14:58:38 [I|aud|9f6d1abb] ComputeAttribute (43) create event on vm_attrs {"cpus"=>"2", "corespersocket"=>"2", "memory_mb"=>"4096", "firmware"=>"efi", "cluster"=>"OT_Non-Oracle/OT_Non_Oracle_HA", "resource_pool"=>"Resources", "path"=>"/Datacenters/TC/vm/OT Non-Oracle/Linux", "guest_id"=>"rhel8_64Guest", "hardware_version"=>"Default", "memoryHotAddEnabled"=>"0", "cpuHotAddEnabled"=>"0", "add_cdrom"=>"0", "boot_order"=>["disk", "network"], "annotation"=>"", "scsi_controllers"=>[{"type"=>"ParaVirtualSCSIController", "key"=>1000}, {"type"=>"ParaVirtualSCSIController", "key"=>1001}], "interfaces_attributes"=>{"0"=>{"type"=>"VirtualVmxnet3", "network"=>"network-1711"}, "1628859505113"=>{"type"=>"VirtualVmxnet3", "network"=>"dvportgroup-1685"}, "1628859506738"=>{"type"=>"VirtualVmxnet3", "network"=>"network-158"}}, "volumes_attributes"=>{"0"=>{"thin"=>true, "name"=>"Hard disk", "mode"=>"persistent", "controller_key"=>1000, "size_gb"=>2, "datastore"=>"AFF_ALL_TOM2Y820_OT_LINUX_M_42D", "storage_pod"=>nil}, "1"=>{"size_gb"=>60, "datastore"=>"AFF_ALL_TOM2Y820_OT_LINUX_M_42D", "storage_pod"=>nil, "thin"=>true, "eager_zero"=>false, "name"=>"Hard disk", "mode"=>"persistent", "controller_key"=>1000}, "2"=>{"size_gb"=>4, "datastore"=>"AFF_ALL_TOM2Y820_OT_LINUX_M_42D", "storage_pod"=>nil, "thin"=>true, "eager_zero"=>false, "name"=>"Hard disk", "mode"=>"persistent", "controller_key"=>1001}}}



Step 6: hammer fails to find the cluster itself when using "OT_Non-Oracle/OT_Non_Oracle_HA"

# /usr/bin/hammer compute-profile values create --compute-profile-id 52 --compute-resource-id 1 '--compute-attributes={"cpus":2,"corespersocket":2,"memory_mb":4096,"firmware":"efi","resource_pool":"Resources","cluster":"OT_Non_Oracle/OT_Non_Oracle_HA","guest_id":"rhel8_64Guest","path":"/Datacenters/TC/vm/OT Non-Oracle/Linux","hardware_version":"Default","memoryHotAddEnabled":0,"cpuHotAddEnabled":0,"add_cdrom":0,"boot_order":["disk","network"],"scsi_controllers":[{"type":"ParaVirtualSCSIController","key":1000},{"type":"ParaVirtualSCSIController","key":1001}]}'

Could not set the compute profile attributes:
  Fog::Vsphere::Compute::NotFound


And backend log always and everytime suggests that Satellite cannot find the cluster details . Sharing one example: 
~~
2021-08-12T14:22:54 [I|app|4da8f3cc] Backtrace for 'Action failed' error (ActionView::Template::Error): Fog::Vsphere::Compute::NotFound
 4da8f3cc | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-3.4.0/lib/fog/vsphere/requests/compute/get_cluster.rb:7:in `get_cluster'
 4da8f3cc | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-3.4.0/lib/fog/vsphere/models/compute/clusters.rb:17:in `get'
 4da8f3cc | /usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:87:in `block in cluster'
 4da8f3cc | /usr/share/foreman/app/services/compute_resource_cache.rb:68:in `instance_eval'
 4da8f3cc | /usr/share/foreman/app/services/compute_resource_cache.rb:68:in `get_uncached_value'
 4da8f3cc | /usr/share/foreman/app/services/compute_resource_cache.rb:22:in `cache'
 4da8f3cc | /usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:86:in `cluster'
 4da8f3cc | /usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:158:in `block in resource_pools'
 4da8f3cc | /usr/share/foreman/app/services/compute_resource_cache.rb:68:in `instance_eval'
 4da8f3cc | /usr/share/foreman/app/services/compute_resource_cache.rb:68:in `get_uncached_value'
 4da8f3cc | /usr/share/foreman/app/services/compute_resource_cache.rb:22:in `cache'
 4da8f3cc | /usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:157:in `resource_pools'
 4da8f3cc | /usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:674:in `normalize_vm_attrs'
 4da8f3cc | /usr/share/foreman/app/models/compute_attribute.rb:36:in `normalized_vm_attrs'
 4da8f3cc | /opt/theforeman/tfm/root/usr/share/gems/gems/rabl-0.14.3/lib/rabl/helpers.rb:16:in `data_object_attribute'
~~


Expected results:

hammer will be able to use "OT_Non_Oracle/OT_Non_Oracle_HA" as a valid value for cluster attrobute.


Additional info:


Hammer cannot even see the full_path of cluster as we can see below.

# hammer compute-resource clusters --id 1
--------------|-----------------------
ID            | NAME
--------------|-----------------------
...
domain-c1694  | OT_Non_Oracle_HA
domain-c208   | OT_Oracle_HA
...

And none of the name or ID works here.  Normally it's expected that we will be able to use the name of cluster and that works for me but fails under Folder1\Cluster1 situation.

hammer compute-resource resource-pools --cluster-id OT_Oracle_HA --id 1
Fog::Vsphere::Compute::NotFound

hammer compute-resource resource-pools --cluster-id domain-c1694 --id 1
Fog::Vsphere::Compute::NotFound

# hammer compute-resource resource-pools --cluster-id "OT_Non_Oracle/OT_Non_Oracle_HA" --id 1
404 Not Found

Comment 1 Sayan Das 2021-08-18 08:32:18 UTC
NOTE: I have queried cluster details from vCenter inside the foreman-rake console and I got the following details.


   <Fog::Vsphere::Compute::Cluster
    id="domain-c1694",
    name="OT_Non_Oracle_HA",
    datacenter="TC",
    num_host=6,
    num_cpu_cores=216,
    overall_status="green",
    full_path="OT_Non-Oracle/OT_Non_Oracle_HA"
  >]


   <Fog::Vsphere::Compute::Cluster
    id="domain-c208",
    name="OT_Oracle_HA",
    datacenter="TC",
    num_host=4,
    num_cpu_cores=144,
    overall_status="green",
    full_path="OT_Oracle/OT_Oracle_HA"
  >,




Looks like, UI can detect and work with id and\or full_path but hammer CLI can't work with any of the id\name\full_path in this situation.

So it could be related to https://bugzilla.redhat.com/show_bug.cgi?id=1993888 as well to some extent.

Comment 2 Sayan Das 2021-08-18 10:47:29 UTC
// Update //

It seems there was a small mistake done from my mine and customer's end.

Full path that rake gave us for the cluster was "OT_Non-Oracle/OT_Non_Oracle_HA"

But we were using "OT_Non_Oracle/OT_Non_Oracle_HA"

So OT_Non_Oracle != OT_Non-Oracle


I have informed that and that hopefully will let customer create the CP as well.


Now, Hao++ was assisting and found out that even if "hammer compute-profile values create" command is accepting that Full Cluster PATH, the "hammer compute-resource resource-pools --cluster-id" is not accepting the same.

In case of Folder/Cluster architecture, "hammer compute-resource resource-pools --cluster-id" accepts none of the values i.e. id or name or full_path


hammer compute-resource resource-pools --cluster-id OT_Oracle_HA --id 1
Fog::Vsphere::Compute::NotFound

hammer compute-resource resource-pools --cluster-id domain-c1694 --id 1
Fog::Vsphere::Compute::NotFound


hammer compute-resource resource-pools --cluster-id "OT_Non-Oracle/OT_Non_Oracle_HA" --id 1
404 Not Found


So suggestions is :

1. Always map the name attribute of cluster with full_path 

or 

2. Add an additional parameter to be able to use Cluster Full Path



One more definite recommendation is, following output should print a third column i.e. Full Path where full_path value of cluster will be present.


# hammer compute-resource clusters --id 1
--------------|-----------------------
ID            | NAME
--------------|-----------------------
...
domain-c1694  | OT_Non_Oracle_HA
domain-c208   | OT_Oracle_HA
...

Comment 9 Chris Roberts 2022-08-22 19:19:50 UTC
Completed issue #1 and enhanced hammer to show the following:

-------------|-----------------------|----------------|-----------------|------------------
ID           | NAME                  | FULL PATH      | NUMBER OF HOSTS | STATUS OF CLUSTER
-------------|-----------------------|----------------|-----------------|------------------
domain-c1235 | ABJ-LabCluster        | RH_Engineering | 1               | green            
domain-c7    | Satellite-Engineering | RH_Engineering | 3               | green            
domain-c65   | vMotion-Cluster       | RH_Engineering | 3               | green            
-------------|-----------------------|----------------|-----------------|------------------

With a datacenter inside of a folder like the customer has:

--------------|----------------|-------------|-----------------|------------------
ID            | NAME           | FULL PATH   | NUMBER OF HOSTS | STATUS OF CLUSTER
--------------|----------------|-------------|-----------------|------------------
domain-c40243 | Folder-Cluster | CEE/test_dc | 0               | green            
--------------|----------------|-------------|-----------------|------------------

Will work on issue #2 tomorrow

Comment 10 Chris Roberts 2022-08-22 19:23:47 UTC
changed FULL PATH to be called DATACENTER PATH

Comment 11 Chris Roberts 2022-08-22 21:09:16 UTC
For reference this is what the old output looked like:

-------------|----------------------
ID           | NAME                 
-------------|----------------------
domain-c1235 | ABJ-LabCluster       
domain-c7    | Satellite-Engineering
domain-c65   | vMotion-Cluster      
-------------|----------------------

Comment 12 Chris Roberts 2022-08-23 19:30:34 UTC
I was able to confirm resource pools works without a nested cluster:

[vagrant@centos7-hammer-devel ~]$ hammer -d compute-resource resource-pools --id 2 --cluster-id "Satellite-Engineering"

-----------|-----------|-----------------------|----------------|---------------
ID         | NAME      | CLUSTER               | DATACENTER     | OVERALL STATUS
-----------|-----------|-----------------------|----------------|---------------
resgroup-8 | Resources | Satellite-Engineering | RH_Engineering | green         
-----------|-----------|-----------------------|----------------|---------------

But does not work with the nested such as how the bz was filed:

hammer -d compute-resource resource-pools --id 1 --cluster-id "Test-Folder/Test-Cluster"

Starting to work on this part now

Comment 13 Chris Roberts 2022-08-24 14:20:39 UTC
So we have narrowed down the issue to being an issue with Hammer sending off the / encoded as %2F but Apache is blocking / per:

https://httpd.apache.org/docs/current/mod/core.html#allowencodedslashes

Opening this up is a security concern for the project, so we have a patch that will unescape it and I am going to test that today. If that does not get approved I think we can apply that apache directive to the custom hiera file to have the installer add it to apache for you.

My method would make it so you have to send in the cluster like this:

hammer -d compute-resource resource-pools --id 1 --cluster-id "Test-Folder%2FTest-Cluster"

With the apache directive turned on you would be able to send it as hammer -d compute-resource resource-pools --id 1 --cluster-id "Test-Folder/Test-Cluster"

Will test on a non devel setup today to see if my change works and to test the hiera method as well

Comment 14 Chris Roberts 2022-08-25 17:11:43 UTC
I verified the patch works correctly now:


hammer -d compute-profile values create --compute-profile-id 6 --compute-resource-id 6 '--compute-attributes={"cpus":2,"corespersocket":2,"memory_mb":4096,"firmware":"efi","resource_pool":"Resources","cluster":"Test-Folder/Test-Cluster","guest_id":"rhel8_64Guest","path":"/Datacenters/Toledo-Test/vm","hardware_version":"Default","memoryHotAddEnabled":0,"cpuHotAddEnabled":0,"add_cdrom":0,"boot_order":["disk","network"],"scsi_controllers":[{"type":"ParaVirtualSCSIController","key":1000},{"type":"ParaVirtualSCSIController","key":1001}]}'

Compute profile attributes are set.

So with compute profile we can pass in folder/cluster but with clusters we still need to pass in %2F because of Apache.

Will push up PR's and link them up to the BZ

Comment 15 Bryan Kearney 2022-08-29 12:03:56 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/35438 has been resolved.

Comment 17 Chris Roberts 2022-09-08 14:04:56 UTC
Moving to POST, the Foreman PR got built into the snap but we now need the hammer PR built into the snap.

https://github.com/theforeman/hammer-cli-foreman/pull/604

Comment 18 Marek Hulan 2022-09-15 13:16:26 UTC
*** Bug 1993888 has been marked as a duplicate of this bug. ***

Comment 19 Lukáš Hellebrandt 2022-10-05 13:53:23 UTC
Verified with Sat 6.12 snap 13.0.

For vSphere versions 6 and 7, followed the instructions from OP + succesfully created hosts using the compute profiles. No related traceback.

$ hammer compute-profile values create --compute-profile-id 2 --compute-resource-id 5 '--compute-attributes={"cpus":4,"corespersocket":2,"memory_mb":4096,"firmware":"efi","resource_pool":"Resources","cluster":"lhellebr-clusterfolder-willdelsoon/Satellite-Engineering","guest_id":"rhel8_64Guest","path":"/Datacenters/RH_Engineering/vm/","hardware_version":"Default","memoryHotAddEnabled":0,"cpuHotAddEnabled":0,"add_cdrom":0,"boot_order":["disk","network"],"scsi_controllers":[{"type":"ParaVirtualSCSIController","key":1000},{"type":"ParaVirtualSCSIController","key":1001}]}'
Compute profile attributes are set.

Comment 27 errata-xmlrpc 2022-11-16 13:32:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.12 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:8506


Note You need to log in before you can comment on or make changes to this bug.