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

Make windows gradle check server using proper amount of memory in WinRM #242

Merged
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
2 changes: 1 addition & 1 deletion lib/compute/agent-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class AgentNodes {
maxTotalUses: 1,
minimumNumberOfSpareInstances: 1,
numExecutors: 1,
amiId: 'ami-0d4be8badb668a87c',
amiId: 'ami-060fb9c217a5ec76a',
initScript: 'echo',
remoteFs: 'C:/Users/Administrator/jenkins',
};
Expand Down
96 changes: 96 additions & 0 deletions packer/jenkins-agent-win2019-x64-gradle-check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"variables": {
"name-base":"Jenkins-Agent-Windows2019-X64",
"os-version": "Windows2019",
"build-region":"us-east-1",
"build-vpc":"vpc-<>",
"build-subnet":"subnet-<>",
"build-secgrp":"sg-<>",
"build-time":"{{isotime \"2006-01-02T03-04-05Z\"}}",
"aws_ami_region":"us-east-1"
},
"builders": [
{
"name":"{{user `name-base`}}-{{user `build-time`}}" ,
"ami_description":"{{user `name-base`}}",
"type":"amazon-ebs",
"encrypt_boot":"false",
"region":"{{user `build-region`}}",
"ami_regions":"{{user `aws_ami_region`}}",
"instance_type":"c5.24xlarge",
"ami_name":"{{user `name-base`}}-{{user `build-time`}}",
"vpc_id":"{{user `build-vpc`}}",
"subnet_id":"{{user `build-subnet`}}",
"security_group_ids":"{{user `build-secgrp`}}",
"source_ami_filter": {
"filters": {
"virtualization-type":"hvm",
"architecture":"x86_64",
"name": "Windows_Server-2019-English-Full-Base-20*",
"block-device-mapping.volume-type":"gp2",
"root-device-type":"ebs"
},
"owners": [
"amazon"
],
"most_recent":true
},
"user_data_file":"scripts/windows/userdata.ps1",
"associate_public_ip_address":true,
"communicator":"winrm",
"winrm_username":"Administrator",
"winrm_timeout":"40m",
"windows_password_timeout":"30m",
"winrm_insecure":true,
"tags": {
"Name": "{{user `name-base`}}-{{user `build-time`}}",
"OS_Version":"{{user `os-version`}}",
"User":"Packer",
"Encrypted_AMI":"False",
"Created":"{{user `build-time`}}"
},
"launch_block_device_mappings": [
{
"device_name":"/dev/sda1",
"volume_size":100,
"delete_on_termination":true,
"volume_type":"gp3"
}
]
}
],
"provisioners": [
{
"type": "file",
"source": "scripts/windows/winrm_max_memory.ps1",
"destination": "C:\\Users\\Administrator\\jenkins\\winrm_max_memory.ps1"
},
{
"type":"powershell",
"inline": [
"C:\\Users\\Administrator\\jenkins\\winrm_max_memory.ps1 190"
]
},
{
"type":"powershell",
"scripts": [
"scripts/windows/smb-setup-2019-plus.ps1",
"scripts/windows/longpath-setup.ps1",
"scripts/windows/scoop-setup.ps1",
"scripts/windows/scoop-install-commons.ps1",
"scripts/windows/pip-install.ps1"
],
"max_retries": 3
},
{
"type": "windows-restart"
},
{
"type":"powershell",
"inline": [
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule",
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown"
]
}
]
}
11 changes: 11 additions & 0 deletions packer/jenkins-agent-win2019-x64.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@
}
],
"provisioners": [
{
"type": "file",
"source": "scripts/windows/winrm_max_memory.ps1",
"destination": "C:\\Users\\Administrator\\jenkins\\winrm_max_memory.ps1"
},
{
"type":"powershell",
"inline": [
"C:\\Users\\Administrator\\jenkins\\winrm_max_memory.ps1 30"
]
},
{
"type":"powershell",
"scripts": [
Expand Down
7 changes: 7 additions & 0 deletions packer/scripts/windows/longpath-setup.ps1
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

echo "Enable Long Path"
set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled -Type DWORD -Value 1 -Force
1 change: 1 addition & 0 deletions packer/scripts/windows/pip-install.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
1 change: 1 addition & 0 deletions packer/scripts/windows/scoop-install-alpinewsl.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
1 change: 1 addition & 0 deletions packer/scripts/windows/scoop-install-commons.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
1 change: 1 addition & 0 deletions packer/scripts/windows/scoop-setup.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
1 change: 1 addition & 0 deletions packer/scripts/windows/smb-setup-2019-plus.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
1 change: 1 addition & 0 deletions packer/scripts/windows/smb-setup.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
7 changes: 7 additions & 0 deletions packer/scripts/windows/userdata.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<powershell>

# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

############################## With HTTP ######################################
## Setup winrm
cmd /c winrm quickconfig -q
Expand Down
18 changes: 18 additions & 0 deletions packer/scripts/windows/winrm_max_memory.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

$memorygb = [int]$args[0]
$memorygb

if ($memorygb) {
$memorymb = $memorygb * 1024
}
else {
$memorymb = 30 * 1024
}
cmd /c winrm set "winrm/config/winrs" "@{MaxMemoryPerShellMB=\`"$memorymb\`"}"
cmd /c winrm get winrm/config
Comment on lines +8 to +18
Copy link
Member

Choose a reason for hiding this comment

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

Can you please explain this? What it is trying to do?
Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

It is trying to get user input in GB and convert to MB and apply to WinRM max memory allocation during Jenkins agent node communications.

When Jenkins communicate with Windows node through WinRM it can only allocate the max number of memory in MBs that WinRM allows it to allocate.

This make sure the value is assigned dynamically based on the AMI requirements. Thanks.

1 change: 1 addition & 0 deletions packer/scripts/windows/wsl-setup.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down