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

Correct and update disk information #158

Merged
merged 1 commit into from
Nov 9, 2017
Merged

Correct and update disk information #158

merged 1 commit into from
Nov 9, 2017

Conversation

djberg96
Copy link
Collaborator

@djberg96 djberg96 commented Nov 3, 2017

We inadvertently used the host disk (flavor) size when we really wanted to use the OS/data disk size. This updates it so that it only falls back to flavor size if it can't find the OS/data disk size.

In addition, we need to include the disk_type (managed or unmanaged) and storage type (standard LRS, premium, etc) for the mode.

https://bugzilla.redhat.com/show_bug.cgi?id=1503866
New BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1512569

@miq-bot miq-bot added the wip label Nov 3, 2017
@bronaghs
Copy link

bronaghs commented Nov 6, 2017

I'm not sure we should even fall back to the flavor disk size if that is the maximum size that can be allocated to the OS Disk, not the actual.

@djberg96
Copy link
Collaborator Author

djberg96 commented Nov 6, 2017

@bronaghs ok, will just default to 0 if it doesn't have the expected property then.

@blomquisg
Copy link
Member

blomquisg commented Nov 8, 2017

Looks like this need VCR updates

(I saw WIP, but thought I'd be proactive 😸)

end

def add_azure_instance_disk(array, instance, os_disk = nil)
os_disk ||= instance.properties.storage_profile.os_disk

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the right side will only parse for OS Disks, can you pass in the OS Disk like you pass in the data disk so this isn't needed?

storage_key = storage_keys['key1'] || storage_keys['key2']
blob_props = storage_acct.blob_properties(container_name, blob_name, storage_key)
disk_size = blob_props.content_length.to_i
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would disk size be nil? I would love to avoid the complexities around lines 389 - 392

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't completely nailed down why some vm's include the disk size in their storage profile, and why some don't, but it must have something to do with the way they were provisioned, or possibly even when they were provisioned. Or it could have something to do with the OS. In any case, I cannot predict it at this time.

You can see the difference by running the following commands on the CLI:

az vm show -n miq-test-win12 -g miq-azure-test1 # This doesn't show a disk size.
az vm show -n dberger1 -g dberger1 # This does show a disk size


# No data availbale on swap disk? Called temp or resource disk.
array << disk
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djberg96
Until I dug deep, it looked like this method add_azure_instance_disk accepts a data disk as the third parameter yet only parses OS disks. Upon closer review, it looks like data disks will be parsed correctly. Can you rename the osDisk variable to disk to avoid confusion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing.

end

def add_azure_instance_disk(array, instance, os_disk = nil)
os_disk ||= instance.properties.storage_profile.os_disk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you insert the string azure into the method name? Its implied that this applies to Azure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can rename it. I didn't want to use add_instance_disk since it's inherited, but I guess there's no harm in just redefining it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea you could override it.

filter = "resourceType eq '#{resource_type}'"
@res.list_all(:filter => filter)
end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this method used?

Copy link
Collaborator Author

@djberg96 djberg96 Nov 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought I removed it. The original plan was to use the ResourceService since it has a smaller footprint, until I discovered that it did not include the information that I needed.

::Azure::Armrest::ResourceService.new(config).tap do |service|
service.api_version = Settings.ems.ems_azure.api_versions.resource.to_s
end
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this method used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto as above, will remove.

@djberg96 djberg96 changed the title [WIP] Correct and update disk information Correct and update disk information Nov 9, 2017
@djberg96
Copy link
Collaborator Author

djberg96 commented Nov 9, 2017

@bronaghs Ok, I think I've made all the requested changes.

@miq-bot miq-bot removed the wip label Nov 9, 2017
# Redefine the inherited method for our purposes
def add_instance_disk(array, instance, disk = nil)
disk ||= instance.properties.storage_profile.os_disk

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you pass the OS Disk in as a parameter so its the same as you do for data disks? This line is OS disk specific yet the method is used for all disks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done.

vhd_loc = os_disk.try(:vhd).try(:uri) || os_disk.try(:managed_disk).try(:id)
add_instance_disk(hardware_hash[:disks], instance)

# No data available on swap disk? Called temp or resource disk.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delete this comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -350,13 +353,55 @@ def populate_hardware_hash_with_series_attributes(hardware_hash, instance, serie
hardware_hash[:memory_mb] = series[:memory] / 1.megabyte
hardware_hash[:disk_capacity] = series[:root_disk_size] + series[:swap_disk_size]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the disk capacity correct? I do not think we should get this value from the series.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have to know the difference between size and disk_capacity. And that's not part of the disks table. It may actually be correct.

@bronaghs
Copy link

bronaghs commented Nov 9, 2017

I think, in a separate PR, a disk should be added for a resource disk. Thoughts?
A description of a resource disk:

Resource disk is a locally attached disk, typically an SSD
It is a host disk (or rather part of one on the host depending on the VM size) and is not backed by any storage account. The contents of this drive is lost upon host reallocation. Agent creates a temp drive on it with a warning txt file with this message.

@djberg96
Copy link
Collaborator Author

djberg96 commented Nov 9, 2017

@bronaghs I'd like to get a storage manager implemented, and we can take a more holistic view of what and how we would like stuff integrated.

@bronaghs
Copy link

bronaghs commented Nov 9, 2017

@djberg96 Spoke to PM (Brad Ascar). He recommends adding a setting to the settings.yml file that allows the user to enable or disable setting the tier on unmanaged disks. Similar to how we enable/disable the gathering of public images. The default would be true. A documentation BZ would have to be filed describing this.

@bronaghs
Copy link

bronaghs commented Nov 9, 2017

👍
Once commits are squashed I'll merge once green

Added api-version for ResourceService.

Added a resource_service and resources_for method.

Added add_azure_instance_disk, and modified hardware population methods to use it.

Add an api-version for storage_disk.

Added the storage_disk_service method.

Collect managed disk information and use that to set managed disk size.

Get information for unmanaged storage.

Add storage type as mode.

Remove unused methods.

Redefine add_instance_disk instead of adding a new method.

Update disk size specs and flavor count.

Rebuilt cassette.

Make disk argument to add_instance_disk mandatory, update method to pass it explicitly, and remove an old comment.

Add the :get_unmanaged_disk_space: property.

Only collect unmanaged disk details based on settings.
@miq-bot
Copy link
Member

miq-bot commented Nov 9, 2017

Checked commit https://github.com/djberg96/manageiq-providers-azure/commit/106ff47459aa1f2565b9a0dc7f0ac6ef97a92b56 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 3 offenses detected

app/models/manageiq/providers/azure/cloud_manager/refresh_parser.rb

spec/models/manageiq/providers/azure/cloud_manager/refresher_spec.rb

@bronaghs bronaghs self-assigned this Nov 9, 2017
@bronaghs bronaghs merged commit f8d65fc into ManageIQ:master Nov 9, 2017
@bronaghs bronaghs added this to the Sprint 73 Ending Nov 13, 2017 milestone Nov 9, 2017
@simaishi
Copy link
Contributor

@djberg96 Tried to backport to Fine branch, but spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher.yml is conflicting. Should I take the yml file from this PR as is, ignoring all the conflicts?

@djberg96
Copy link
Collaborator Author

@simaishi yes, just use the .yml file from this PR please.

simaishi pushed a commit that referenced this pull request Nov 14, 2017
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit b19e9c1844c16ece5c8bcb352ff15eb06f545e31
Author: Bronagh Sorota <[email protected]>
Date:   Thu Nov 9 16:40:21 2017 -0500

    Merge pull request #158 from djberg96/disk_information
    
    Correct and update disk information
    (cherry picked from commit f8d65fcd1ca49ab286e980d62f2a9ad2d62ae7b2)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1512728

@simaishi simaishi removed the fine/yes label Nov 14, 2017
simaishi pushed a commit that referenced this pull request Nov 14, 2017
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit e29a5fb43f8c3f55baca86cf8f2d60660a630e26
Author: Bronagh Sorota <[email protected]>
Date:   Thu Nov 9 16:40:21 2017 -0500

    Merge pull request #158 from djberg96/disk_information
    
    Correct and update disk information
    (cherry picked from commit f8d65fcd1ca49ab286e980d62f2a9ad2d62ae7b2)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1512727

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

Successfully merging this pull request may close these issues.

5 participants