Skip to content

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

Conversation

vermashi
Copy link
Contributor

@vermashi vermashi commented Aug 7, 2018

Fixed a bug where the correct status was not reported on native disk VMs when extension was removed.

Checklist

@vermashi vermashi requested a review from ejarvi August 7, 2018 00:39
@vermashi vermashi self-assigned this Aug 7, 2018
[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")]
Copy link
Member

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)
Copy link
Member

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/"))
Copy link
Member

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))
Copy link
Member

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))
Copy link
Member

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

Copy link
Contributor Author

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 markcowl changed the base branch from preview to release-2018-08-10 August 8, 2018 01:28
@vermashi
Copy link
Contributor Author

vermashi commented Aug 8, 2018

@markcowl Any further changes needed?

Copy link
Contributor

@ejarvi ejarvi left a comment

Choose a reason for hiding this comment

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

LGTM

@markcowl markcowl merged commit 7fdd943 into Azure:release-2018-08-10 Aug 9, 2018
@MiYanni MiYanni mentioned this pull request Aug 16, 2018
8 tasks
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.

4 participants