Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle VPC flavor with nil :disks value #475

Merged
merged 1 commit into from
Oct 28, 2023

Conversation

jaywcarman
Copy link
Member

I noticed VPC refresh failing (us-south region) due to:

[----] I, [2023-10-27T17:51:52.340185 #563743:a258]  INFO -- evm: MIQ(ManageIQ::Providers::IbmCloud::VPC::CloudManager::Refresher#refresh) Refreshing all targets...
[----] I, [2023-10-27T17:51:52.340287 #563743:a258]  INFO -- evm: MIQ(ManageIQ::Providers::IbmCloud::VPC::CloudManager::Refresher#refresh) EMS: [vpc-dallas], id: [3] Refreshing targets for EMS...
[----] I, [2023-10-27T17:51:52.340344 #563743:a258]  INFO -- evm: MIQ(ManageIQ::Providers::IbmCloud::VPC::CloudManager::Refresher#refresh) EMS: [vpc-dallas], id: [3]   ManageIQ::Providers::IbmCloud::VPC::CloudManager [vpc-dallas] id [3]
[----] I, [2023-10-27T17:51:55.832719 #563743:a258]  INFO -- evm: MIQ(ManageIQ::Providers::IbmCloud::VPC::CloudManager::Refresher#refresh_targets_for_ems) EMS: [vpc-dallas], id: [3] Refreshing target ManageIQ::Providers::IbmCloud::VPC::CloudManager [vpc-dallas] id [3]...
[----] E, [2023-10-27T17:52:12.377043 #563743:a258] ERROR -- evm: MIQ(ManageIQ::Providers::IbmCloud::VPC::CloudManager::Refresher#refresh) EMS: [vpc-dallas], id: [3] Refresh failed
[----] E, [2023-10-27T17:52:12.379667 #563743:a258] ERROR -- evm: [NoMethodError]: undefined method `first' for nil:NilClass  Method:[block (2 levels) in <class:LogProxy>]
[----] E, [2023-10-27T17:52:12.380055 #563743:a258] ERROR -- evm: /home/jwcarman/src/github.com/ManageIQ/manageiq-providers-ibm_cloud/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb:185:in `block in flavors'
/home/jwcarman/src/github.com/ManageIQ/manageiq-providers-ibm_cloud/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb:183:in `each'
/home/jwcarman/src/github.com/ManageIQ/manageiq-providers-ibm_cloud/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb:183:in `flavors'
/home/jwcarman/src/github.com/ManageIQ/manageiq-providers-ibm_cloud/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb:19:in `parse'
...

I'm not sure if this Flavor is new or something (why wasn't it failing before?), but it does indeed have a null disks value:

$ ibmcloud is instance-profile bx2-2x8 --json | head
{
    "bandwidth": {
        "type": "fixed",
        "value": 4000
    },
    "disks": null,
    "family": "balanced",
    "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/profiles/bx2-2x8",
    "memory": {
        "type": "fixed",

Use safe navigation to parse a nil :disks value.
@jaywcarman jaywcarman added the bug Something isn't working label Oct 27, 2023
@agrare agrare self-assigned this Oct 28, 2023
@agrare agrare merged commit 0f3d095 into ManageIQ:master Oct 28, 2023
3 checks passed
@jaywcarman jaywcarman deleted the vpc_flavor_disks_safe_nav branch October 29, 2023 16:39
@Fryguy
Copy link
Member

Fryguy commented Nov 8, 2023

Backported to quinteros in commit 61f206e.

commit 61f206e097c3598f4039ab0aec49bf1b5b4ca5f5
Author: Adam Grare <adam@grare.com>
Date:   Sat Oct 28 13:16:12 2023 -0400

    Merge pull request #475 from jaywcarman/vpc_flavor_disks_safe_nav
    
    Handle VPC flavor with nil :disks value
    
    (cherry picked from commit 0f3d09547ab2f72f06f405b3ba2fe58587589090)

Fryguy pushed a commit that referenced this pull request Nov 8, 2023
Handle VPC flavor with nil :disks value

(cherry picked from commit 0f3d095)
@Fryguy
Copy link
Member

Fryguy commented Dec 7, 2023

@jaywcarman A conflict occurred during the backport of this pull request to morphy.

If this pull request is based on another pull request that has not been marked for backport, add the appropriate labels to the other pull request. Otherwise, please create a new pull request direct to the morphy branch in order to resolve this.

Conflict details:

diff --cc app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb
index 6a37fe4,7999a58..0000000
--- a/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb
+++ b/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb
@@@ -179,14 -182,14 +179,18 @@@ class ManageIQ::Providers::IbmCloud::In
    def flavors
      collector.flavors.each do |flavor|
        memory = flavor&.dig(:memory, :value)
++<<<<<<< HEAD
 +      memory_mb = Integer(memory) * 1024 if memory
++=======
+       disk = flavor[:disks]&.first&.dig(:size, :value) || 0
++>>>>>>> 0f3d095 (Merge pull request #475 from jaywcarman/vpc_flavor_disks_safe_nav)
        persister.flavors.build(
 -        :ems_ref         => flavor[:name],
 -        :name            => flavor[:name],
 -        :cpu_total_cores => flavor&.dig(:vcpu_count, :value),
 -        :memory          => memory&.gigabytes,
 -        :root_disk_size  => disk&.gigabytes,
 -        :enabled         => true
 +        :ems_ref   => flavor[:name],
 +        :name      => flavor[:name],
 +        :cpus      => flavor&.dig(:vcpu_count, :value),
 +        :cpu_cores => flavor&.dig(:vcpu_count, :value),
 +        :memory    => memory_mb,
 +        :enabled   => true
        )
      end
    end

@jaywcarman
Copy link
Member Author

@Fryguy, looks like this bug wasn't introduced until najdorf:

master|8c5bf6f5|manageiq-providers-ibm_cloud$ git show 56e36dba99e352f514a207dba0fe2f733ae6ebae -- app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb
commit 56e36dba99e352f514a207dba0fe2f733ae6ebae
Author: nasark <nasarak_786@hotmail.com>
Date:   Wed Nov 3 10:20:15 2021 -0400

    add resize vm functionality

diff --git a/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb b/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb
index 7f7133a6..4bd9b0f9 100644
--- a/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb
+++ b/app/models/manageiq/providers/ibm_cloud/inventory/parser/vpc.rb
@@ -182,12 +182,13 @@ class ManageIQ::Providers::IbmCloud::Inventory::Parser::VPC < ManageIQ::Provider
   def flavors
     collector.flavors.each do |flavor|
       memory = flavor&.dig(:memory, :value)
-      memory_mb = Integer(memory) * 1024 if memory
+      disk = flavor[:disks].first&.dig(:size, :value) || 0
       persister.flavors.build(
         :ems_ref         => flavor[:name],
         :name            => flavor[:name],
         :cpu_total_cores => flavor&.dig(:vcpu_count, :value),
-        :memory          => memory_mb,
+        :memory          => memory&.gigabytes,
+        :root_disk_size  => disk&.gigabytes,
         :enabled         => true
       )
     end
master|8c5bf6f5|manageiq-providers-ibm_cloud$ git fetch upstream && git branch -r -l 'upstream/*' --contains 56e36dba99e352f514a207dba0fe2f733ae6ebae             
  upstream/HEAD -> upstream/master
  upstream/master
  upstream/najdorf
  upstream/oparin
  upstream/petrosian
  upstream/quinteros
  upstream/renovate/configure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants