-
Notifications
You must be signed in to change notification settings - Fork 4k
Added a fix and test for the removed-extension scenario for the Get-AzureDiskEncryptionStatus cmdlet #6861
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
Added a fix and test for the removed-extension scenario for the Get-AzureDiskEncryptionStatus cmdlet #6861
Conversation
[Fact(Skip = "Updated Storage, needs re-recorded")] | ||
[Trait(Category.RunType, Category.DesktopOnly)] | ||
#else | ||
[Fact(Skip = "TODO: only works for live mode due to key vault dependency")] |
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.
Why would it only work for live mode? KeyVault is just as mockable as network is.
private bool isVMRunning (VirtualMachine vm) | ||
{ | ||
string lastCode = ""; | ||
foreach (InstanceViewStatus ivs in vm.InstanceView.Statuses) |
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.
Do you know that instanceView is non-null in this case?
string lastCode = ""; | ||
foreach (InstanceViewStatus ivs in vm.InstanceView.Statuses) | ||
{ | ||
if (ivs.Code.StartsWith("PowerState/")) |
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.
Do you know that ivs.Code is non-null in this case?
@@ -495,7 +508,7 @@ private AzureDiskEncryptionStatusContext getStatusDualPass(VirtualMachine vm) | |||
}; | |||
break; | |||
case OperatingSystemTypes.Linux: | |||
if (!IsExtensionInstalled(vm)) | |||
if (!this.IsExtensionInstalled(vm) && this.isVMRunning(vm)) |
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.
You don't need the this.
@@ -560,7 +573,7 @@ private AzureDiskEncryptionStatusContext getStatusSinglePass(VirtualMachine vm) | |||
AzureDiskEncryptionStatusContext status = this.GetStatusFromInstanceView(vm); | |||
|
|||
// Get Data Disk status from extension for Native Disk VMs | |||
if (isNativeDiskVM(vm)) | |||
if ( status.DataVolumesEncrypted != EncryptionStatus.NoDiskFound && isNativeDiskVM(vm)) |
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.
GetStatusFromInstanceView can return null, so this should likely be status?.DataVolumesEncrypted
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.
GetStatusFromInstanceView never returns null.
@markcowl Any further changes needed? |
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.
LGTM
Fixed a bug where the correct status was not reported on native disk VMs when extension was removed.
Checklist
CONTRIBUTING.md
platyPS
module