Skip to content

Commit

Permalink
feat: enable arm64 on AWS
Browse files Browse the repository at this point in the history
Refs HMS-1135
  • Loading branch information
ezr-ondrej committed Oct 17, 2023
1 parent 80a8e3d commit 4137605
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
24 changes: 11 additions & 13 deletions internal/services/aws_reservation_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,17 @@ func CreateAWSReservation(w http.ResponseWriter, r *http.Request) {
return
}

// Validate architecture match (hardcoded since image builder currently only supports x86_64). This can be only done
// when launch template is not set.
if payload.LaunchTemplateID == "" {
supportedArch := "x86_64"
it := preload.EC2InstanceType.FindInstanceType(clients.InstanceTypeName(payload.InstanceType))
if it == nil {
renderError(w, r, payloads.NewInvalidRequestError(r.Context(), fmt.Sprintf("unknown type: %s", payload.InstanceType), ErrUnknownInstanceTypeName))
return
}
if it.Architecture.String() != supportedArch {
renderError(w, r, payloads.NewWrongArchitectureUserError(r.Context(), ErrArchitectureMismatch))
return
}
// Validate architecture match.
supportedArch := "x86_64"
it := preload.EC2InstanceType.FindInstanceType(clients.InstanceTypeName(payload.InstanceType))
if it == nil {
renderError(w, r, payloads.NewInvalidRequestError(r.Context(), fmt.Sprintf("unknown type: %s", payload.InstanceType), ErrUnknownInstanceTypeName))
return
}
logger.Debug().Msgf("Arch is %s", it.Architecture.String())
if it.Architecture.String() != supportedArch && it.Architecture.String() != "arm64" {
renderError(w, r, payloads.NewWrongArchitectureUserError(r.Context(), ErrArchitectureMismatch))
return
}

detail := &models.AWSDetail{
Expand Down
15 changes: 15 additions & 0 deletions scripts/rest_examples/reservation-create-aws-arm.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @no-log
POST http://{{hostname}}:{{port}}/{{prefix}}/reservations/aws HTTP/1.1
Content-Type: application/json
X-Rh-Identity: {{identity}}

{
"name": "amz-linux-us-east-1",
"source_id": "{{source_id_aws}}",
"image_id": "c1257188-3462-48ca-b8c0-bbd061e99ab2",
"amount": 1,
"launch_template_id": "{{launch_template_id}}",
"instance_type": "t4g.nano",
"pubkey_id": {{pubkey_id}},
"poweroff": true
}

0 comments on commit 4137605

Please sign in to comment.