Skip to content

Commit 35ba0f3

Browse files
CI fix windows integration test failures (#435)
Fix ShrinkRootPartition to reliably free space on stemcell 2019.99 On stemcell 2019.99 the gap between SizeMin (~29.05 GB) and the partition size (~30 GB) is only ~950 MB. The previous approach used SizeMin + 1 GB as the target, which exceeded SizeMax (= CurrentSize) and caused Resize-Partition to fail with "Size Not Supported". A later attempt used SizeMax - 10 GB, which fell below SizeMin and caused Resize-Partition to silently return exit code 0 without making any change (LargestFreeExtent remained 0). Fix by shrinking 200 MB from the current partition size: - Uses (Get-Partition).Size (current size) instead of SizeMax, so we always shrink even when there is adjacent unallocated space. - 200 MB is well within the achievable range (~950 MB gap) and well above the agent's 1 MB minimum for creating an ephemeral partition. - Small amount means minimal data movement and fast completion. Also remove the agent-windows-large-root-disk.yml ops file added as a workaround: the AWS CPI ignores root_disk in instance-group-level cloud_properties, so the disk remained at 30 GB regardless. The ops file is no longer needed with the corrected shrink strategy. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e1ffdfc commit 35ba0f3

3 files changed

Lines changed: 18 additions & 25 deletions

File tree

ci/pipeline.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,6 @@ jobs:
464464
stemcells:
465465
- "aws-stemcell/*.tgz"
466466
- "aws-windows-stemcell/*.tgz"
467-
ops_files:
468-
- "bosh-agent/integration/assets/agent-windows-large-root-disk.yml"
469467
vars:
470468
deployment_name: bosh-agent-integration-windows-main
471469
- task: get-agent-info
@@ -510,7 +508,6 @@ jobs:
510508
- "aws-stemcell/*.tgz"
511509
- "aws-windows-stemcell/*.tgz"
512510
ops_files:
513-
- "bosh-agent/integration/assets/agent-windows-large-root-disk.yml"
514511
- "bosh-agent/integration/assets/agent-windows-nats-blobstore.yml"
515512
releases:
516513
- bosh-bosh-release/release.tgz
@@ -570,6 +567,7 @@ jobs:
570567
delete:
571568
enabled: true
572569
force: true
570+
573571
- name: bosh-integration-tests
574572
serial: true
575573
plan:

integration/assets/agent-windows-large-root-disk.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

integration/windows/environment_test.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,24 @@ type WindowsEnvironment struct {
2828
}
2929

3030
func (e *WindowsEnvironment) ShrinkRootPartition() {
31-
// Shrink C: by a fixed amount from its current maximum rather than trying
32-
// to reach the theoretical SizeMin. Shrinking to SizeMin requires Windows
33-
// to move almost all data to the start of the disk, which fails with
34-
// "Size Not Supported" when NTFS unmovable files (MFT mirror, NTFS log,
35-
// VSS snapshots) are scattered throughout the partition. Shrinking by a
36-
// modest fixed amount only requires the last N GB to be free contiguous
37-
// space, which is reliably true on a freshly provisioned VM.
38-
// 10 GB is more than enough for the ephemeral partition the tests create.
39-
const shrinkBy = 10 * GB
31+
// Shrink C: by a small fixed amount from its current size rather than
32+
// trying to reach the theoretical SizeMin.
33+
//
34+
// On stemcell 2019.99 the gap between SizeMin and the partition size is
35+
// only ~950 MB, so a large shrink (e.g. 10 GB) would request a target
36+
// below SizeMin and silently fail (Resize-Partition returns exit code 0
37+
// but leaves the partition unchanged). Using a small amount (200 MB)
38+
// keeps the target safely above SizeMin while giving the agent more than
39+
// enough room to create an ephemeral partition (minimum is 1 MB).
40+
//
41+
// Using (Get-Partition -DriveLetter C).Size (current size) rather than
42+
// (Get-PartitionSupportedSize -DriveLetter C).SizeMax ensures we are
43+
// always shrinking: SizeMax includes adjacent unallocated space and can
44+
// be larger than the current partition size.
45+
const MB = 1024 * 1024
46+
const shrinkBy = 200 * MB
4047
cmd := fmt.Sprintf(
41-
"Get-Partition -DriveLetter C | Resize-Partition -Size $((Get-PartitionSupportedSize -DriveLetter C).SizeMax - %d)",
48+
"$currentSize = (Get-Partition -DriveLetter C).Size; Get-Partition -DriveLetter C | Resize-Partition -Size ($currentSize - %d)",
4249
shrinkBy,
4350
)
4451

0 commit comments

Comments
 (0)