-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[VM/VMSS] Improved disk caching support #2522
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,7 +253,7 @@ def build_vm_resource( # pylint: disable=too-many-locals | |
| name, location, tags, size, storage_profile, nics, admin_username, | ||
| availability_set_id=None, admin_password=None, ssh_key_value=None, ssh_key_path=None, | ||
| image_reference=None, os_disk_name=None, custom_image_os_type=None, | ||
| storage_caching=None, storage_sku=None, | ||
| os_caching=None, data_caching=None, storage_sku=None, | ||
| os_publisher=None, os_offer=None, os_sku=None, os_version=None, os_vhd_uri=None, | ||
| attach_os_disk=None, data_disk_sizes_gb=None, image_data_disks=None, | ||
| custom_data=None, secrets=None): | ||
|
|
@@ -296,7 +296,7 @@ def _build_storage_profile(): | |
| 'osDisk': { | ||
| 'createOption': 'fromImage', | ||
| 'name': os_disk_name, | ||
| 'caching': storage_caching, | ||
| 'caching': os_caching, | ||
| 'osType': custom_image_os_type, | ||
| 'image': {'uri': image_reference}, | ||
| 'vhd': {'uri': os_vhd_uri} | ||
|
|
@@ -306,7 +306,7 @@ def _build_storage_profile(): | |
| 'osDisk': { | ||
| 'createOption': 'fromImage', | ||
| 'name': os_disk_name, | ||
| 'caching': storage_caching, | ||
| 'caching': os_caching, | ||
| 'vhd': {'uri': os_vhd_uri} | ||
| }, | ||
| 'imageReference': { | ||
|
|
@@ -328,7 +328,7 @@ def _build_storage_profile(): | |
| 'osDisk': { | ||
| 'createOption': 'fromImage', | ||
| 'name': os_disk_name, | ||
| 'caching': storage_caching, | ||
| 'caching': os_caching, | ||
| 'managedDisk': {'storageAccountType': storage_sku} | ||
| }, | ||
| 'imageReference': { | ||
|
|
@@ -342,7 +342,7 @@ def _build_storage_profile(): | |
| 'osDisk': { | ||
| 'createOption': 'fromImage', | ||
| 'name': os_disk_name, | ||
| 'caching': storage_caching, | ||
| 'caching': os_caching, | ||
| 'managedDisk': {'storageAccountType': storage_sku} | ||
| }, | ||
| "imageReference": { | ||
|
|
@@ -361,7 +361,7 @@ def _build_storage_profile(): | |
| } | ||
| profile = storage_profiles[storage_profile.name] | ||
| return _build_data_disks(profile, data_disk_sizes_gb, image_data_disks, | ||
| storage_caching, storage_sku) | ||
| data_caching, storage_sku) | ||
|
|
||
| vm_properties = { | ||
| 'hardwareProfile': {'vmSize': size}, | ||
|
|
@@ -389,21 +389,22 @@ def _build_storage_profile(): | |
|
|
||
|
|
||
| def _build_data_disks(profile, data_disk_sizes_gb, image_data_disks, | ||
| storage_caching, storage_sku): | ||
| data_caching, storage_sku): | ||
| if data_disk_sizes_gb is not None: | ||
| profile['dataDisks'] = [] | ||
| for image_data_disk in image_data_disks or []: | ||
| profile['dataDisks'].append({ | ||
| 'lun': image_data_disk.lun, | ||
| 'createOption': "fromImage", | ||
| 'caching': data_caching | ||
| }) | ||
| lun = max([d.lun for d in image_data_disks]) + 1 if image_data_disks else 0 | ||
| for size in data_disk_sizes_gb: | ||
| profile['dataDisks'].append({ | ||
| 'lun': lun, | ||
| 'createOption': "empty", | ||
| 'diskSizeGB': int(size), | ||
| 'caching': storage_caching, | ||
| 'caching': data_caching, | ||
|
||
| 'managedDisk': {'storageAccountType': storage_sku} | ||
| }) | ||
| lun = lun + 1 | ||
|
|
@@ -498,7 +499,8 @@ def build_vmss_resource(name, naming_prefix, location, tags, overprovision, upgr | |
| vm_sku, instance_count, ip_config_name, nic_name, subnet_id, | ||
| admin_username, authentication_type, | ||
| storage_profile, os_disk_name, | ||
| storage_caching, storage_sku, data_disk_sizes_gb, image_data_disks, os_type, | ||
| os_caching, data_caching, storage_sku, data_disk_sizes_gb, | ||
| image_data_disks, os_type, | ||
| image=None, admin_password=None, ssh_key_value=None, ssh_key_path=None, | ||
| os_publisher=None, os_offer=None, os_sku=None, os_version=None, | ||
| backend_address_pool_id=None, inbound_nat_pool_id=None, | ||
|
|
@@ -526,7 +528,7 @@ def build_vmss_resource(name, naming_prefix, location, tags, overprovision, upgr | |
| if storage_profile in [StorageProfile.SACustomImage, StorageProfile.SAPirImage]: | ||
| storage_properties['osDisk'] = { | ||
| 'name': os_disk_name, | ||
| 'caching': storage_caching, | ||
| 'caching': os_caching, | ||
| 'createOption': 'FromImage', | ||
| } | ||
|
|
||
|
|
@@ -539,10 +541,10 @@ def build_vmss_resource(name, naming_prefix, location, tags, overprovision, upgr | |
| }) | ||
| else: | ||
| storage_properties['osDisk']['vhdContainers'] = "[variables('vhdContainers')]" | ||
| elif storage_profile in [StorageProfile.ManagedPirImage, StorageProfile.ManagedPirImage]: | ||
| elif storage_profile in [StorageProfile.ManagedPirImage, StorageProfile.ManagedCustomImage]: | ||
| storage_properties['osDisk'] = { | ||
| 'createOption': 'FromImage', | ||
| 'caching': storage_caching, | ||
| 'caching': os_caching, | ||
| 'managedDisk': {'storageAccountType': storage_sku} | ||
| } | ||
|
|
||
|
|
@@ -559,7 +561,7 @@ def build_vmss_resource(name, naming_prefix, location, tags, overprovision, upgr | |
| } | ||
|
|
||
| storage_profile = _build_data_disks(storage_properties, data_disk_sizes_gb, | ||
| image_data_disks, storage_caching, | ||
| image_data_disks, data_caching, | ||
| storage_sku) | ||
|
|
||
| # Build OS Profile | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest exposing
--os-disk-cachingand--data-disk-caching. Were this PR out last month, these short names look pretty good; but now withcustomdataandsecretsupport, it is necessary to be a bit complete to avoid potential confusions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep this short. It is consistent with
--os-type(which refers to a disk) and is in the storage argument group, so I think it's pretty clear.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With help it will be clear, but there is also a scenario that when you read existing commands, the meaning should be clear w/o referring to help.
There are lots and lots of caching mechanisms in the whole stack from CPU cache to the web page cache at the top, so when I talk about cache, I have to be very specific on the term and context, otherwise people would not understand. This is why I am not quite into the argument naming of
--os-caching, and--data-cache, because they could mean lots of different things.However, I would not let my own experience/knowledge to determine the naming for wide audience. So /cc: @gbowerman @gatneil, if they are fine with this short naming, I will be fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although longer, we probably need 'disk' in the names for clarity, e.g. --os-disk-caching, --data-disk-caching, or --os-disk-cache, --data-disk-cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done