Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(HMS-2640): machine type is required #734

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/services/gcp_reservation_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ func CreateGCPReservation(w http.ResponseWriter, r *http.Request) {
return
}

// Check machine type for "This organization policy prevents creating instances with exotic machine types. Contact the IT Public Cloud team at help.redhat.com for an exception"
if payload.MachineType == "" {
renderError(w, r, payloads.NewInvalidRequestError(r.Context(), "Machine type must be present even when a template is in use", ErrBothTypeAndTemplateMissing))
return
}

namePattern := "inst-####"
// Verify name pattern is lower cased and add #####
if payload.NamePattern != "" {
Expand Down
1 change: 1 addition & 0 deletions internal/services/reservations_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
ErrUnknownInstanceTypeName = errors.New("unknown instance type")
ErrArchitectureMismatch = errors.New("instance type and image architecture mismatch")
ErrBothTypeAndTemplateMissing = errors.New("instance type or launch template not set")
ErrMachineTypeMissing = errors.New("machine type missing")
ErrUnsupportedRegion = errors.New("unknown region/location/zone")
ErrInvalidNamePattern = errors.New("name pattern is not RFC-1035 compatible")
ErrPubkeyNotFound = errors.New("no pubkey found")
Expand Down
4 changes: 3 additions & 1 deletion scripts/rest_examples/http-client.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"source_id_gcp": "3",
"pubkey_id": "1",
"region": "us-east-1",
"launch_template_id": "",
"zone_gcp": "us-central1-a",
"launch_template_id_aws": "",
"launch_template_id_gcp": "",
"reservation-get-id": "1",
"azure-resource-group": "redhat-deployed"
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/rest_examples/reservation-create-aws.http
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ X-Rh-Identity: {{identity}}
"source_id": "{{source_id_aws}}",
"image_id": "ami-05fa00d4c63e32376",
"amount": 1,
"launch_template_id": "{{launch_template_id}}",
"launch_template_id_aws": "{{launch_template_id_aws}}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"launch_template_id_aws": "{{launch_template_id_aws}}",
"launch_template_id": "{{launch_template_id_aws}}",

"instance_type": "t2.nano",
"pubkey_id": {{pubkey_id}},
"poweroff": true
Expand Down
4 changes: 2 additions & 2 deletions scripts/rest_examples/reservation-create-gcp.http
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ X-Rh-Identity: {{identity}}

{
"name_pattern": "gcp-linux-eu-west8-c",
"zone": "europe-west8-c",
"zone": "{{zone_gcp}}",
"source_id": "{{source_id_gcp}}",
"image_id": "https://www.googleapis.com/compute/v1/projects/rhel-cloud/global/images/rhel-9-v20230411",
"amount": 1,
"machine_type": "e2-micro",
"launch_template_id": "{{launch_template_id}}",
"launch_template_id_gcp": "{{launch_template_id_gcp}}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"launch_template_id_gcp": "{{launch_template_id_gcp}}",
"launch_template_id": "{{launch_template_id_gcp}}",

"pubkey_id": {{pubkey_id}},
"poweroff": true
}