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

Vagrant: Improve VPC Performance For Windows Server 2022 #3644

Merged
merged 13 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 52 additions & 5 deletions ansible/pbTestScripts/vagrantPlaybookCheck.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ vmHalt=true
cleanWorkspace=false
newVagrantFiles=false
fastMode=false
useAdopt=false
skipFullSetup=''
jdkToBuild=''
buildHotspot=''
Expand Down Expand Up @@ -51,6 +52,8 @@ processArgs()
newVagrantFiles=true;;
"--skip-more" | "-sm" )
fastMode=true;;
"--use-adopt" | "-ua" )
useAdopt=true;;
"--build-fork" | "-bf" )
buildFork="--fork $1"; shift;;
"--build-branch" | "-bb" )
Expand Down Expand Up @@ -86,6 +89,7 @@ usage()
--no-halt | -nh Option to stop the vagrant VMs halting
--new-vagrant-files | -nv Use vagrantfiles from the the specified git repository
--skip-more | -sm Run playbook faster by excluding things not required by buildJDK
--use-adopt | -ua Use the local Adoptium vagrantfile instead of the standard (.Adopt extension on Vagrantfile)
--help | -h Displays this help message
-V Apply verbose option to 'ansible-playbook', up to '-VVVV'"
}
Expand Down Expand Up @@ -134,13 +138,43 @@ checkVars()
skipFullSetup=",nvidia_cuda_toolkit"
case "$jdkToBuild" in
"jdk8" )
skipFullSetup="$skipFullSetup,MSVS_2017";
skipFullSetup="$skipFullSetup,MSVS_2017,MSVS_2019,MSVS_2022";
if [ "$buildHotspot" != "" ]; then
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1"
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1,MSVS_2017,MSVS_2019,MSVS_2022"
fi
;;
"jdk11" )
skipFullSetup="$skipFullSetup,MSVS_2013,MSVS_2019,MSVS_2022";
if [ "$buildHotspot" != "" ]; then
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1,MSVS_2013,MSVS_2019,MSVS_2022"
fi
;;
"jdk17" )
skipFullSetup="$skipFullSetup,MSVS_2013,MSVS_2017,MSVS_2022";
if [ "$buildHotspot" != "" ]; then
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1,MSVS_2013,MSVS_2017,MSVS_2022"
fi
;;
"jdk21" )
skipFullSetup="$skipFullSetup,MSVS_2013,MSVS_2017,MSVS_2019";
if [ "$buildHotspot" != "" ]; then
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1,MSVS_2013,MSVS_2017,MSVS_2019"
fi
;;
"jdk22" )
skipFullSetup="$skipFullSetup,MSVS_2013,MSVS_2017,MSVS_2019";
if [ "$buildHotspot" != "" ]; then
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1,MSVS_2013,MSVS_2017,MSVS_2019"
fi
;;
"jdk" )
skipFullSetup="$skipFullSetup,MSVS_2013,MSVS_2017,MSVS_2019";
if [ "$buildHotspot" != "" ]; then
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1,MSVS_2013,MSVS_2017,MSVS_2019"
fi
;;
*)
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1,MSVS_2013";;
skipFullSetup="$skipFullSetup,MSVS_2010,VS2010_SP1";;
esac
fi
jdkToBuild="--version $jdkToBuild"
Expand All @@ -164,6 +198,7 @@ checkVagrantOS()
echo $vagrantOSList
exit 1
fi

# The Windows VM is setup to use 5GB of memory, which can be an issue on machines with only 8GB installed.
# See: https://github.com/adoptium/infrastructure/pull/1532#issue-481189847
if [[ "$vagrantOS" == "Win2012" && $(free | awk '/Mem:/ { print $2 }') -lt 8000000 ]]; then
Expand Down Expand Up @@ -220,6 +255,7 @@ startVMPlaybook()
else
ln -sf ${scriptPath%/*}/../vagrant/Vagrantfile.$OS Vagrantfile
fi

# Copy the machine's ssh key for the VMs to use, after removing prior files
rm -f id_rsa.pub id_rsa
ssh-keygen -q -f $PWD/id_rsa -t rsa -N ''
Expand Down Expand Up @@ -295,10 +331,21 @@ startVMPlaybookWin()
local vagrantPort=

cd $WORKSPACE/adoptopenjdkPBTests/${gitFork}-${newGitBranch}/ansible

if [ "$newVagrantFiles" = "true" ]; then
ln -sf vagrant/Vagrantfile.$OS Vagrantfile
if [[ "$useAdopt" == "true" ]] && [[ "$OS" == "Win2022" ]]; then
echo "Use Adoptium Box For Win2022"
ln -sf vagrant/Vagrantfile.$OS.Adopt Vagrantfile
else
ln -sf vagrant/Vagrantfile.$OS Vagrantfile
fi
else
ln -sf ${scriptPath%/*}/../vagrant/Vagrantfile.$OS Vagrantfile
if [[ "$useAdopt" == "true" ]] && [[ "$OS" == "Win2022" ]]; then
echo "Use Adoptium Box For Win2022"
ln -sf ${scriptPath%/*}/../vagrant/Vagrantfile.$OS.Adopt Vagrantfile
else
ln -sf ${scriptPath%/*}/../vagrant/Vagrantfile.$OS Vagrantfile
fi
fi

# Remove the Hosts files if they're found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@
dest: C:\TEMP
when: (vs2022_layout_ready.stat.exists)

# When Installing From The Layout, We Need To Ensure the x86 installer is not detected.
- name: Rename x86 Installer When Installing VS2022 from the Adoptium Layout
win_shell: |
Rename-Item -Path "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer" -NewName "Installer.old"
args:
executable: powershell
creates: "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer.old"
when: (vs2022_layout_ready.stat.exists)

- name: Run Visual Studio 2022 Installer From Layout
win_shell: |
Start-Process -Wait -FilePath 'C:\temp\VSLayout2022\vs_community.exe' -ArgumentList '--nocache --quiet --norestart --wait --noweb --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --includeOptional --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.ATL.ARM64 --add Microsoft.VisualStudio.Component.VC.MFC.ARM64'
Expand Down
53 changes: 53 additions & 0 deletions ansible/vagrant/Vagrantfile.Win2022.Adopt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Runs Powershell as an administator and does the following:
# - Gets/executes an Ansible provided script that configures WinRM to allow Ansible to communicate over it.
# - Resizes the disk to ~100GB, in line with the 'disksize.size = 100GB' option in the config below

$script = <<SCRIPT
Start-Process powershell -Verb runAs

wget https://raw.githubusercontent.com/ansible/ansible-documentation/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile .\\ConfigureRemotingForAnsible.ps1
.\\ConfigureRemotingForAnsible.ps1 -CertValidityDays 9999
.\\ConfigureRemotingForAnsible.ps1 -EnableCredSSP
.\\ConfigureRemotingForAnsible.ps1 -ForceNewSSLCert
.\\ConfigureRemotingForAnsible.ps1 -SkipNetworkProfileCheck

# Retrieving disk's current size
$currentDiskSize =(Get-Partition -DriveLetter c | select Size)
$currentDiskSize =($currentDiskSize -replace "[^0-9]" , "")
# The size the disk should be, in bytes (130GB)
$diskSizeBoundary = 139586437120
# Changing the disksize to max supported size (~130GB)
if ([long]$currentDiskSize -lt $diskSizeBoundary) {
echo "Resizing disk to max size"
$size = (Get-PartitionSupportedSize -DriveLetter c); Resize-Partition -DriveLetter c -Size $size.SizeMax
}else {
echo "Disk is already at max size"
}

Start-Process cmd -Verb runAs
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
SCRIPT

# 2 = version of configuration file for Vagrant 1.1+ leading up to 2.0.x
Vagrant.configure("2") do |config|

config.vm.define :adoptopenjdkW2022 do |adoptopenjdkW2022|
adoptopenjdkW2022.vm.box = "adoptium/windows2022"
adoptopenjdkW2022.vm.hostname = "adoptopenjdkW2022"
adoptopenjdkW2022.vm.communicator = "winrm"
adoptopenjdkW2022.vm.synced_folder ".", "/vagrant"
adoptopenjdkW2022.vm.network :private_network, type: "dhcp"
adoptopenjdkW2022.vm.provision "shell", inline: $script, privileged: false
adoptopenjdkW2022.disksize.size = '131GB'
end
config.vm.provider "virtualbox" do |v|
v.gui = false
v.memory = 8192
v.cpus = 2
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
end
config.vm.boot_timeout = 600
end