confidential-containers / cloud-api-adaptor

Ability to create Kata pods using cloud provider APIs aka the peer-pods approach
Apache License 2.0
44 stars 71 forks source link

ibmcloud: selectInstanceProfile and selectImage incorrectly handle "architecture" requirements #1795

Open skaegi opened 2 months ago

skaegi commented 2 months ago

We provide both amd64 and s390x instance profiles as well as amd64 and s390x images.

IBMCLOUD_PODVM_IMAGE_ID: r018-...(amd64-image-id),r018-...(s390x-image-id)
IBMCLOUD_PODVM_INSTANCE_PROFILE_LIST: bx2-2x8,bz2-2x8

If we use the "machine_type" annotation to select bz2-2x8 when CreateInstance is called then selectInstanceProfile will choose the correct vm flavour however selectImage will incorrectly choose the first (amd64) image as the spec.Arch check it does does not have the correct information. The creation will fail later with...

[adaptor/cloud] creating an instance : Image OS architecture amd64 is not supported by the instance profile bz2-2x8

To fix this: 1) updateInstanceProfileSpecList should populate the InstanceTypeSpecs with Arch from the GetInstanceProfileWithContext result 2) In CreateInstance after calling selectInstanceProfile the incoming spec should be merged with the instanceProfile spec 3) Call getImage with the new merged spec