YannickRe / azuredevops-buildagents

Generate self-hosted build agents for Azure DevOps, just like Microsoft does.
MIT License
151 stars 90 forks source link

Unable to create Packer VM - "The platform image 'canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest' is not available.' #30

Closed ianjirka closed 1 year ago

ianjirka commented 1 year ago

This is not an issue with the code here or in the runner-images repo - I'm here looking for advice.

When I try and run the packer template in the runner-images repo, first via this tooling and later standalone, VM creation fails indicating it can't find the platform image: The platform image 'canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest' is not available.

If I alter the Packer template to produce managed disks, it creates just fine. This works for me, but I then need to maintain a fork.

What I'm curious about is this approach seems to work fine for your users. Microsoft tells me that this is due to unmanaged disks being deprecated and no longer available via the marketplace. If that's true though, this should break everyone. I suspect there may be a flag on older subscriptions that allows the creation of VHDs from marketplace images.

Did you/anyone else run into this? Thanks much for any advice.

YannickRe commented 1 year ago

Hi @ianjirka , I have not experienced this myself but I'm currently only running this on "old/legacy/long-existing" subscriptions and I haven't tried on a new subscription. I have no idea if it has to do with unmanaged disks but looking at the documentation (https://learn.microsoft.com/en-us/azure/virtual-machines/unmanaged-disks-deprecation?WT.mc_id=M365-MVP-5003400), changes should only start affecting us in 6 months:

How does this affect me?

  • As of June 30th, 2023, new subscriptions won't be eligible to create unmanaged disks.
  • As of September 30, 2023, existing customers won't be able to create new unmanaged disks.
  • On September 30, 2025, customers will no longer be able to start IaaS VMs by using unmanaged disks. Any VMs that are still running or allocated will be stopped and deallocated.

Two things:

ianjirka commented 1 year ago

Thanks for the response @YannickRe. I do agree, based on the timeline that MSFT laid out, this shouldn't be impacting. That said, Microsoft told me to expect this behavior. Their documentation also hints that there are subscription level flags: Item 3 in this section but I haven't gotten a confirmation on what this means yet.

I've confirmed the regions I'm using (EastUS2) has those images - I used the same reference - it's also no issue to create VMs as long as I use managed disks.

Anyway, I have a workaround for now. Since your pipeline converts the VHD to a managed image for use in the VMSS anyway, I wouldn't think there is a big impact unless folks are using the VHD for other purposes. But I'm not too familiar with users of this project.

The feature request you mention isn't quite related - the requestor is asking to support an (presumably private) Managed Image Gallery for sharing the resulting images. I do think it would be great if the azuredevops-buildagents team just published their images to the Azure Marketplace directly. That would simplify things for me, for sure.

I've asked Microsoft about the feature flag directly, I'll let you know if I find anything useful.

YannickRe commented 1 year ago

First of all, thanks for the information! Please let me know whatever you find out from MS, it might help me adjust this project.

Can you share the changes you made to generate a Managed Disk directly? Because you are right, I'm converting to Managed after generating the VHD and then I'm deleting the VHD. I could eliminate that second step by directly generating the Managed Disk, it would help you and would future-proof this project.

Ah yes, that Managed Image Gallery is different. I don't have much experience with this so I'm not totally sure what I'd need to do to support this. After a switch to generating Managed Disks directly, I might be able to support that too.

ianjirka commented 1 year ago

Finally found the root cause for the issue - Unmanaged disks do not support ZRS and it gives that misleading error message. Took quite some time with Azure to track it down.

For future reference, It's not documented under unmanaged disks, but it is documented in storage documentation here : https://learn.microsoft.com/en-us/azure/storage/common/storage-redundancy?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json#locally-redundant-storage

To make the packer template work with unmanaged disks, you need to change the following. It's quite finnicky and you need to make all these changes or it'll give you misleading error messages

remove: capture_container_name capture_name_prefix resource_group_name storage_account temp_resoure_group_name

add: managed_image_name managed_image_resource_group_name

I would prefer the template generate managed images directly - but I prefer even more not to fork the template and maintain it. I assume Azure will update to create managed images since unmanaged images are currently in deprecation. They might wait until the last minute though.

@YannickRe, you can close this issue!

YannickRe commented 1 year ago

I'm glad you figured out the reason behind this, but I'd like to keep this open as a reminder to implement Managed VM's with packer instead of converting.

YannickRe commented 1 year ago

After some investigation, this needs to be done at the runners-images level, and is not something I can implement just from this end.