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

Add error handling for unsupported disk conversion #705

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

s4heid
Copy link
Contributor

@s4heid s4heid commented Nov 21, 2024

Summary

Certain Azure storage account types, such as PremiumV2, can't be converted automatically, as detailed in issue #699. Attempting to change the storage type would result in an error from the Azure API, e.g.:

{
  "error": {
    "code": "OperationNotAllowed",
    "message": "Changing a disk's account type from 'PremiumV2_LRS' to 'Premium_LRS' is not supported."
  }
}

Currently, bosh does not specifically handles this error, but interprets it as a general Azure error, which causes a deployment failure when attempting to switch to a storage type that is incompatible with conversion in the manifest.

Example
Task 22 | 15:52:07 | Updating instance zookeeper: zookeeper/54cdcdc2-8494-4ad3-9283-034a5047766b (0) (canary)
Task 22 | 15:52:08 | L executing pre-stop: zookeeper/54cdcdc2-8494-4ad3-9283-034a5047766b (0) (canary)
Task 22 | 15:52:08 | L executing drain: zookeeper/54cdcdc2-8494-4ad3-9283-034a5047766b (0) (canary)
Task 22 | 15:52:09 | L stopping jobs: zookeeper/54cdcdc2-8494-4ad3-9283-034a5047766b (0) (canary)
Task 22 | 15:52:11 | L executing post-stop: zookeeper/54cdcdc2-8494-4ad3-9283-034a5047766b (0) (canary) (00:00:31)
                   L Error: Unknown CPI error 'Bosh::AzureCloud::AzureError' with message 'http_patch - http code: 400
x-ms-client-request-id: 18dffbfb-6d70-482a-b3aa-9bbb98bcc9a1
x-ms-request-id: 54356faf-4aa6-4441-895c-716af9b122vf
x-ms-correlation-request-id: 5fcdc82d-c27f-4f66-accb-4b151aab4dxq
x-ms-routing-request-id: EASTUS2:20241122T155238Z:5fcdc82d-c27f-4f66-accb-4b151aab4fb
Error message: {
  "error": {
    "code": "OperationNotAllowed",
    "message": "Changing a disk's account type from 'PremiumV2_LRS' to 'Premium_LRS' is not supported."
  }
}' in 'update_disk' CPI method (CPI request ID: 'cpi-303168')

In response to such errors from the Azure API, we now raise a NotSupported exception. This instructs bosh to follow the standard disk update process, which involves creating a new disk, attaching both the new and the old disks to the VM, copying the data to the new disk, and then detaching the old disk.

This approach prevents issues for users who might have accidentally chosen such a disk type and wish to revert, avoiding a scenario where the deployment fails and cannot be fixed in any other way.

Checklist:

Please check each of the boxes below for which you have completed the corresponding task:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All unit tests pass locally (after my changes)
  • Rubocop reports zero errors (after my changes)

Please include below the summary portions of the output from the following 2 scripts:

pushd src/bosh_azure_cpi
  bundle install
  bundle exec rake spec:unit
  bundle exec rake rubocop
popd

NOTE: Please see how to setup dev environment and run unit tests in docs/development.md.

Unit Test output:

Unit tests

Finished in 4.8 seconds (files took 5.17 seconds to load)
1034 examples, 0 failures

Coverage report generated for RSpec to /workspaces/bosh-azure-cpi-release/src/bosh_azure_cpi/coverage.
Line Coverage: 49.5% (19089 / 38564)
/workspaces/bosh-azure-cpi-release/src/bosh_azure_cpi

Rubocop output:

There are 52 offenses. None of them were introduced by the code changes of this PR.

Changelog

  • Handle unsupported disk conversion operations by defaulting to the default copy mechanism.

@rkoster rkoster requested review from a team, selzoc and lnguyen and removed request for a team November 28, 2024 15:58
Copy link
Contributor

@fmoehler fmoehler left a comment

Choose a reason for hiding this comment

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

LGTM

@ystros ystros merged commit 5830524 into cloudfoundry:master Dec 2, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants