aws / ec2-macos-init

EC2 macOS Init is the launch daemon used to initialize Mac instances within EC2.
https://aws.amazon.com/ec2/instance-types/mac/
Apache License 2.0
148 stars 19 forks source link

GrowRootAPFSVolume module errors if there's no space to grow #41

Open mattcataws opened 1 year ago

mattcataws commented 1 year ago

The addition of the GrowRootAPFSVolume in version 1.5.7 calls ec2-macos-utils to attempt to grow the root APFS volume to the maximum size of the EBS volume. An error is returned by ec2-macos-utils in the case that there isn't enough space to grow the root volume. For example, the default EBS volume size for EC2 mac instances is 100GB and there's no additional room to expand the APFS volume.

The error logs look like the following:

2023/06/07 22:39:42.931118 Error while running module [GrowRootAPFSVolume] (type: command, group: 3) with message:  and err: ec2macosinit: error executing command [[/bin/zsh -c ec2-macos-utils grow --id root]] with stdout [] and stderr [time="07 Jun 23 22:39 GMT" level=info msg="Configuring diskutil for product" product="macOS Ventura 13.4.0"
time="07 Jun 23 22:39 GMT" level=info msg="Attempting to grow container..." device_id=diskXsX
time="07 Jun 23 22:39 GMT" level=info msg="Checking if device can be APFS resized..." device_id=diskXsX
time="07 Jun 23 22:39 GMT" level=info msg="Device can be resized"
time="07 Jun 23 22:39 GMT" level=info msg="Repairing the parent disk..."
time="07 Jun 23 22:39 GMT" level=info msg="Repairing parent disk..." parent_id=diskY
time="07 Jun 23 22:39 GMT" level=info msg="Successfully repaired the parent disk"
time="07 Jun 23 22:39 GMT" level=info msg="Fetching amount of free space on device..." device_id=diskX
time="07 Jun 23 22:39 GMT" level=warning msg="Available free space does not meet required minimum to grow" required_minimum="1.0 MB" total_free="41 kB"
Error: not enough space to resize container: 40960 bytes available]: exit status 1

This causes unnecessary error logs for ec2-macos-init since it is an expected use case now and isn't a "real" error. It would be best to add support to suppress error messages in ec2-macos-utils to prevent it from reporting as an error in ec2-macos-init.

shepting commented 1 year ago

We are seeing this error as well:

2023/08/11 16:43:47.630235 Error while running module [GrowRootAPFSVolume] (type: command, group: 3) with message:  and err: ec2macosinit: error executing command [[/bin/zsh -c ec2-macos-utils grow --id root]] with stdout [] and stderr [time="11 Aug 23 16:43 PDT" level=info msg="Configuring diskutil for product" product="macOS Ventura 13.4.1"
time="11 Aug 23 16:43 PDT" level=info msg="Attempting to grow container..." device_id=disk5s2s1
time="11 Aug 23 16:43 PDT" level=info msg="Checking if device can be APFS resized..." device_id=disk5s2s1
time="11 Aug 23 16:43 PDT" level=info msg="Device can be resized"
time="11 Aug 23 16:43 PDT" level=info msg="Repairing the parent disk..."
time="11 Aug 23 16:43 PDT" level=info msg="Repairing parent disk..." parent_id=disk4
time="11 Aug 23 16:43 PDT" level=info msg="Successfully repaired the parent disk"
time="11 Aug 23 16:43 PDT" level=info msg="Fetching amount of free space on device..." device_id=disk5
time="11 Aug 23 16:43 PDT" level=warning msg="Available free space does not meet required minimum to grow" required_minimum="1.0 MB" total_free="41 kB"
Error: not enough space to resize container: 40960 bytes available]: exit status 1
2023/08/11 16:43:47.630350 Successfully completed processing of priority level 3

Interestingly, this didn't seem to be an issue on macOS 13.2.1

mattcataws commented 1 year ago

Hi @shepting, thanks for sharing your impact. This became an issue in the macOS 13.4 and later AMIs as that's when we started including ec2-macos-init version 1.5.7 into the AMIs.