-
Notifications
You must be signed in to change notification settings - Fork 72
Fix NVMe raw_instance_storage device enumeration for all instance families #196
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 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8040fef
Update NVMe device path calculation and adjust test expectations for …
neddp 60cbe25
Enhance NVMe storage tests to cover all instance families and improve…
neddp 5a9018a
Update block device mappings to exclude auto-attached NVMe instance s…
neddp 580ef4c
Fix integration test expectation for NVMe raw ephemeral device path
neddp 9d29a70
Remove unnecessary comments
neddp d7b36a3
Refactor raw ephemeral device handling
neddp 56e8ef0
Update NVMe device paths in tests to match simplified hints
neddp 5d94f59
Update raw ephemeral device path to match NVMe instance storage
neddp ede758f
Replace hardcoded NVMe instance families with EC2 DescribeInstanceTyp…
neddp 738d1f1
Enhance NVMe support in tests by mocking EC2 instance type descriptio…
neddp a885f10
Refactor mappings method to conditionally exclude raw ephemeral devic…
neddp d25033a
Refactor fetch method to streamline caching logic and reduce mutex usage
neddp 368e41f
Remove Unused nvm_device_path
neddp 17a18cf
Refactor NVMe support handling in InstanceTypeInfo and its tests
neddp a74d911
Include 'supported' in instance_storage_nvme_naming? for future-proofing
neddp 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
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
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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| module Bosh::AwsCloud | ||
| # Provides instance type metadata by querying the EC2 DescribeInstanceTypes API. | ||
| # Results are cached for the lifetime of the CPI process so each instance type | ||
| # is queried at most once. | ||
| class InstanceTypeInfo | ||
| def initialize(ec2_client, logger) | ||
| @ec2_client = ec2_client | ||
| @logger = logger | ||
| @cache = {} | ||
| end | ||
|
|
||
| # Returns true if EBS volumes on this instance type are exposed exclusively via | ||
| # NVMe and must be located using the /dev/disk/by-id/nvme-Amazon_Elastic_Block_Store_* | ||
| # symlink. This is true only for Nitro instances (nvme_support = 'required'). | ||
| # Xen instances with NVMe instance storage (e.g. i3, nvme_support = 'supported') | ||
| # still use traditional /dev/xvd* paths for EBS volumes. | ||
| def ebs_requires_nvme_path?(instance_type) | ||
| info = fetch(instance_type) | ||
| return false if info.nil? | ||
|
|
||
| info.ebs_info&.nvme_support == 'required' | ||
| end | ||
|
|
||
| # Returns true if instance storage (local NVMe SSDs) on this instance type uses | ||
| # /dev/nvme*n1 device naming. | ||
| # Returns true when nvme_support is 'required'. | ||
| def instance_storage_nvme_naming?(instance_type) | ||
| info = fetch(instance_type) | ||
| return false if info.nil? | ||
|
|
||
| info.instance_storage_info&.nvme_support == 'required' | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| end | ||
|
|
||
| private | ||
|
|
||
| # Fetches and caches the DescribeInstanceTypes response for the given instance type. | ||
| # Returns the instance type info struct, or nil if the type is unknown/invalid. | ||
| def fetch(instance_type) | ||
| instance_type = instance_type.nil? ? 'unspecified' : instance_type | ||
|
|
||
| return @cache[instance_type] if @cache.key?(instance_type) | ||
|
|
||
| result = query(instance_type) | ||
| @cache[instance_type] = result | ||
| result | ||
| end | ||
|
|
||
| def query(instance_type) | ||
| @logger.debug("DescribeInstanceTypes for '#{instance_type}'") | ||
|
|
||
| response = nil | ||
| errors = [Aws::EC2::Errors::RequestLimitExceeded, Aws::EC2::Errors::InternalError, Aws::EC2::Errors::ServiceUnavailable] | ||
| Bosh::Common.retryable(tries: 5, sleep: 1, on: errors) do |_tries, error| | ||
| @logger.warn("DescribeInstanceTypes retrying for '#{instance_type}': #{error.message}") if error | ||
| response = @ec2_client.describe_instance_types( | ||
| instance_types: [instance_type], | ||
| ) | ||
| true | ||
| end | ||
|
neddp marked this conversation as resolved.
|
||
|
|
||
| if response.instance_types.empty? | ||
| @logger.warn("DescribeInstanceTypes returned no data for '#{instance_type}'") | ||
| return nil | ||
| end | ||
|
|
||
| response.instance_types.first | ||
| rescue Aws::EC2::Errors::InvalidInstanceType, Aws::EC2::Errors::InvalidParameterValue => e | ||
| @logger.warn("DescribeInstanceTypes failed for '#{instance_type}': #{e.message}") | ||
| nil | ||
| rescue Aws::Errors::ServiceError => e | ||
| raise Bosh::Clouds::CloudError, "DescribeInstanceTypes API error for '#{instance_type}': #{e.message}" | ||
| end | ||
| end | ||
| end | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.