-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Why?
It happens from time to time that the final Xcode version is just the exact same as the last RC.
For example, xcode-16.3 was exactly the same as xcode-16.3-rc-2
Right now to support that use case, we duplicate the .vmtemplate bundle in S3 with the new name, so that both xcode-16.3-rc-2.vmtemplate.aar and xcode-16.3.vmtemplate.aar are present in S3 and thus found by hostmgr vm fetch / hostmgr vm start.
But this obviously leads to waste of space in the S3 bucket, but also extra S3 data transfers and Mac hosts' disk space (because if a Mac host already had xcode-16.3-rc-2 from a previous job that requested it, and a new job requires IMAGE_ID: xcode-16.3, it will download it all over again instead of realizing they're the same and it could reuse the RC2 it already has locally).
How
Implement some mechanism to support alias names for VMs.
Some random ideas:
- We could have a text file named
xcode-16.3.alias, that would contain the single linexcode-16.3-rc-2, and that we'd upload to the S3 bucket instead of the whole duplication of thevmtemplate.aar.- Then when
hostmgr vm fetch xcode-16.3tries to fetch thexcode-16.3.vmtemplate.aarfile from S3 and fails to find it, instead of erroring right away it'd then check forxcode-16.3.aliasfile as a fallback, and if it exists use its content as the new VM to fetch… - Then it'd have to remember it in some local config file so that
hostmgr vm start xcode-16.3would know to use thexcode-16.3-rc-2.vmtemplateas a template to start the VM
- Then when
- Or have a file in S3 named
aliases.ymlthat contains the map of all VM name aliases.- Then both
hostmgr vm fetchandhostmgr vm startwill check that local file/mapping first, to do any potential substitution of the IMAGE_ID alias to the VM real name to fetch/start, then they'd do the same business as usual (but with the real VM name) - As for keeping that
aliases.ymlfile in sync on Mac hosts, we could:- Either have a cron job fetching it from S3 on a regular basis (meh)
- Or have
hostmgrfetch it from S3 if thehostmgr vm fetchfailed to find the VM. Meaninghostmgr vm fetchwould do (1) check in localaliases.ymlif the requestedIMAGE_IDhas an alias defined in this mapping, and if so use the resolved name (2) do the fetch as usual (3) if the fetch fails, download thealiases.ymlfrom S3 (just in case the local one was not up-to-date), and recheck if there is a new mapping, and if so try the fetch again one last time with that new mapped name - Or have
hostmgr vm fetchfetch the file from S3 each time before it tries to fetch a VM… but with aETag/If-Modified-Sincerequest that only fetches it if it's more recent than the local one
- Then both
Additional use case
In addition to the typical case of avoiding to duplicate VM templates when having a final Xcode version be the same as the last RC, another use case for this aliasing system would be for when we end up building multiple versions of a VMs for the same Xcode because we messed up along the way (e.g. xcode-16.0-v7/xcode-16.0-v9/xcode-16.0-v10).
For such cases, we could define the alias xcode-16.0 to be the latest version of those VMs, and then if a job requests IMAGE_ID: xcode-16.0 it'd automatically point to the latest version of that VM.
Currently for those cases we can't just rename the latest VM in S3 to just xcode-16.0 to achieve such a behavior, because that'd mean that Mac hosts that might have already downloaded a previous version of the VM would (eg. the v7 of the VM) would not realize that they should download the new version if both the old and new version were named xcode-16.0 without a v suffix (it's not like we validate the checksum of the VM is still valid every time we vm fetch/vm start to check if the same IMAGE_ID name still points to the exact same VM as before). But with the aliasing system, a job having IMAGE_ID: xcode-16.0 would still first use the alias mapping to substitute the real name of the VM to fetch/start to be xcode-16.0-v10, and then the rest of the process would be unchanged, thus still downloading the latest VM if that alias points to a new VM now (even if it previously pointed to xcode-16.0-v7 before and we do have that v7 VM locally)