-
Notifications
You must be signed in to change notification settings - Fork 181
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
[Hyper-v platform] Use data disk as LISA working directory on Hyper-v host #3626
base: main
Are you sure you want to change the base?
Changes from all commits
089510f
f8fc1a8
4bd0369
df6128a
4b52c0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,6 +445,76 @@ def enable_internal_dhcp(self, dhcp_scope_name: str = "DHCPInternalNAT") -> None | |
# Restart the DHCP server to apply the changes | ||
service.restart_service("dhcpserver") | ||
|
||
# The default lisa working path is under 'C:/' which is not ideal for large data. | ||
# This method initializes an attached disk, creates a partition, formats it, | ||
# and mounts it to the lisa working directory | ||
# This method expects an un-initialized (RAW) disk to be available on Hyper-V host. | ||
def use_raw_disk_for_lisa_working_dir(self) -> None: | ||
powershell = self.node.tools[PowerShell] | ||
|
||
# Get the first disk that is not initialized | ||
raw_disks = powershell.run_cmdlet( | ||
"Get-Disk | Where-Object PartitionStyle -Eq 'RAW'", | ||
force_run=True, | ||
output_json=True, | ||
) | ||
# If no un-initialized disk is found, log a warning and return | ||
if not raw_disks: | ||
self._log.warning("No un-initialized disk found.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
self._log.warning("Skipping lisa working dir setup on additional disk.") | ||
return | ||
if isinstance(raw_disks, list): | ||
disk_number = raw_disks[0]["Number"] | ||
else: | ||
disk_number = raw_disks["Number"] | ||
# Initialize the disk | ||
powershell.run_cmdlet( | ||
f"Initialize-Disk -Number {disk_number}", | ||
force_run=True, | ||
) | ||
# Create a new partition | ||
powershell.run_cmdlet( | ||
f"New-Partition -DiskNumber {disk_number}" | ||
" -UseMaximumSize -AssignDriveLetter", | ||
force_run=True, | ||
) | ||
# Get the drive letter | ||
drive_letter = powershell.run_cmdlet( | ||
f"(Get-Partition -DiskNumber {disk_number}" | ||
" | Where-Object Type -Eq 'Basic').DriveLetter", | ||
force_run=True, | ||
) | ||
# Format the partition | ||
powershell.run_cmdlet( | ||
f"Format-Volume -DriveLetter {drive_letter}" | ||
" -FileSystem NTFS -NewFileSystemLabel 'DataDisk01'", | ||
force_run=True, | ||
) | ||
|
||
# Get the partition number | ||
partition_number = powershell.run_cmdlet( | ||
f"(Get-Partition | Where-Object DriveLetter" | ||
f" -Eq {drive_letter}).PartitionNumber", | ||
force_run=True, | ||
) | ||
|
||
lisa_working_path = r"$([System.Environment]::GetFolderPath('UserProfile'))\AppData\Local\Temp\lisa_working" # noqa: E501 | ||
|
||
# Create mount point if it doesn't exist | ||
powershell.run_cmdlet( | ||
f'if (-Not $(Test-Path -Path "{lisa_working_path}"))' | ||
f' {{New-Item -ItemType Directory -Path "{lisa_working_path}"}}', | ||
force_run=True, | ||
) | ||
|
||
# Mount the volume to the lisa working directory | ||
powershell.run_cmdlet( | ||
f"Add-PartitionAccessPath -DiskNumber {disk_number}" | ||
f" -PartitionNumber {partition_number}" | ||
f' -AccessPath "{lisa_working_path}"', | ||
force_run=True, | ||
) | ||
|
||
def _install(self) -> bool: | ||
assert isinstance(self.node.os, Windows) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,17 @@ def _internal_run(self) -> Dict[str, Any]: | |
# Enable Hyper-V | ||
hv = self._node.tools[HyperV] | ||
|
||
# Configure lisa working path to use free disk. | ||
hv.use_raw_disk_for_lisa_working_dir() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be the default way. What happened, if it's running on Azure? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is written and tested on azure. My use case is also Azure only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Please make it optional. Only if give a path in config, then create the data disk. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also use_raw_disk_for_lisa_working_dir() will skip if there is not raw disk available on the Host. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not flexible enough. Please create configurations in the runbook. For example,
|
||
|
||
# Create an internal switch. | ||
hv.create_switch(name=switch_name) | ||
|
||
hv.setup_nat_networking(switch_name=switch_name, nat_name=switch_name) | ||
|
||
# Configure Internal DHCP | ||
hv.enable_internal_dhcp() | ||
|
||
# Reboot the node to apply all the changes. | ||
self._node.reboot() | ||
return {} |
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.
Use a configurable path, instead of use the LISA working path. The big files should be tracked separately.
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.
These big files are vhds used as OS and data disks. They are stored by default under relevant test log folder. Its easier if we leave them that way so that its easier to map them to the test runs and clean them up once the tests are finished.
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 can use LISA working path as the default path, but it should be configurable for lab environments.