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

Return only supported instances-types with describe-instance-type-offing #22399

Merged

Conversation

austincunningham
Copy link
Member

@austincunningham austincunningham commented Sep 30, 2021

WHAT

Issue provision prow clusters on us-east-1e m5.large not supported

level=info msg=Creating infrastructure resources...
level=error
level=error msg=Error: Error launching source instance: Unsupported: Your requested instance type (m5.large) is not supported in your requested Availability Zone (us-east-1e). Please retry your request by not specifying an Availability Zone or choosing us-east-1a, us-east-1b, us-east-1c, us-east-1d, us-east-1f.
level=error msg=	status code: 400, request id: accd0930-a445-4132-b322-6dd268503bbc
level=error
level=error msg=  on ../tmp/openshift-install-312116039/bootstrap/main.tf line 110, in resource "aws_instance" "bootstrap":
level=error msg= 110: resource "aws_instance" "bootstrap" {
level=error
level=error
level=fatal msg=failed to fetch Cluster: failed to generate asset "Cluster": failed to create cluster: failed to apply Terraform: failed to complete the change
Setup phase finished, prepare env for next steps

HOW

Setting the filter to use sort and uniq -c allows ec2 describe-instance-type-offerings to return the correct values

below script can be used to test the conditionals

#!/bin/bash
BOOTSTRAP_NODE_TYPE=m5.large
master_type=null
COMPUTE_NODE_TYPE=m4.xlarge
REGION=us-east-1

if [[ "${BOOTSTRAP_NODE_TYPE}" == "${COMPUTE_NODE_TYPE}" && "${COMPUTE_NODE_TYPE}" == "${master_type}" ]]; then ##"three same regions"
  echo "three same regions"
  aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 1 ' | awk '{print $2}'
elif [[ "${master_type}" == null && "${COMPUTE_NODE_TYPE}" == null  ]]; then 
  echo "two null regions"
  aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 1 ' | awk '{print $2}'
elif [[ "${master_type}" == null || "${COMPUTE_NODE_TYPE}" == null ]]; then
  if [[ "${BOOTSTRAP_NODE_TYPE}" == "${COMPUTE_NODE_TYPE}" || "${BOOTSTRAP_NODE_TYPE}" == "${master_type}" || "${master_type}" == "${COMPUTE_NODE_TYPE}" ]]; then 
    echo "one null region and duplicates"
    aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 1 ' | awk '{print $2}'
  else
    echo "one null region and no duplicates"
    aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 2 ' | awk '{print $2}'
  fi 
elif [[ "${BOOTSTRAP_NODE_TYPE}" == "${COMPUTE_NODE_TYPE}" || "${BOOTSTRAP_NODE_TYPE}" == "${master_type}" || "${master_type}" == "${COMPUTE_NODE_TYPE}" ]]; then 
  echo "duplicates regions no null"
  aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 2 ' | awk '{print $2}'
elif [[ "${BOOTSTRAP_NODE_TYPE}" != "${COMPUTE_NODE_TYPE}" && "${COMPUTE_NODE_TYPE}" != "${master_type}" ]]; then
  echo "three different regions"
  aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 3 ' | awk '{print $2}'
fi
us-east-1a
us-east-1b
us-east-1c
us-east-1d
us-east-1f

@openshift-ci openshift-ci bot requested review from csrwng and wking September 30, 2021 15:20
@austincunningham austincunningham changed the title populate COMPUTE_NODE_TYPE before calling describe-instance-type-offring Return only supported instances-types with describe-instance-type-offing Oct 1, 2021
@@ -42,7 +42,7 @@ fi
# Generate working availability zones from the region
mapfile -t AVAILABILITY_ZONES < <(aws --region "${REGION}" ec2 describe-availability-zones | jq -r '.AvailabilityZones[] | select(.State == "available") | .ZoneName' | sort -u)
# Generate availability zones with OpenShift Installer required instance types
mapfile -t INSTANCE_ZONES < <(aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort -u)
mapfile -t INSTANCE_ZONES < <(aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -d)
Copy link
Member

Choose a reason for hiding this comment

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

uniq -d will fail in two cases:

  • Only a single available instance type is requested, e.g. m5.large,m5.large,null or m5.large,null,null.
  • Three separate instance types are requested, and there are regions where only two are available.

I think what we want is some pre-processing to build a Values argument without dups or null, and then jq post-processing to only accept zones which have the expected count of entries.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

@austincunningham austincunningham Oct 4, 2021

Choose a reason for hiding this comment

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

As ${master_type} is always set to null in this script

${BOOTSTRAP_NODE_TYPE} is defaulted to m5.large #14350
The only var we need to check is ${COMPUTE_NODE_TYPE}

so either

${BOOTSTRAP_NODE_TYPE} ${master_type} ${COMPUTE_NODE_TYPE}
m5.large null m5.large
m5.large null null
m5.large null m4.xlarge (or some other type)

if ${COMPUTE_NODE_TYPE} is a duplicate of BOOTSTRAP_NODE_TYPE or a null then the original sort works
if not then the uniq -d sort works

Copy link
Member Author

@austincunningham austincunningham Oct 4, 2021

Choose a reason for hiding this comment

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

actually I'm wrong master_type and BOOTSTRAP_NODE_TYPE are subject to change.

@e-tienne
Copy link
Contributor

e-tienne commented Oct 4, 2021

/cc e-tienne

@openshift-ci openshift-ci bot requested a review from e-tienne October 4, 2021 17:32
@briangallagher
Copy link

/retest-required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 6, 2021

@austincunningham: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/rehearse/periodic-ci-openshift-release-master-nightly-4.9-e2e-aws-workers-rhel7 a540758b1ea29da0d609827484d14f46780d83c7 link unknown /test pj-rehearse
ci/rehearse/periodic-ci-openshift-release-master-ci-4.9-e2e-aws-calico a540758b1ea29da0d609827484d14f46780d83c7 link unknown /test pj-rehearse
ci/rehearse/periodic-ci-openshift-release-master-ci-4.9-e2e-aws-upgrade-single-node 5f8d172 link unknown /test pj-rehearse
ci/rehearse/periodic-ci-openshift-release-master-ci-4.9-e2e-aws-techpreview-serial 5f8d172 link unknown /test pj-rehearse
ci/rehearse/periodic-ci-openshift-release-master-ci-4.9-upgrade-from-stable-4.8-e2e-aws-uwm 5f8d172 link unknown /test pj-rehearse
ci/rehearse/openshift/origin/release-4.5/e2e-aws-csi 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/origin/release-4.1/e2e-aws-builds 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/origin/release-4.1/e2e-aws-image-ecosystem 69aa769 link unknown /test pj-rehearse
ci/rehearse/tnozicka/openshift-acme/master/e2e-cluster-wide 69aa769 link unknown /test pj-rehearse
ci/rehearse/redhat-developer/jenkins-operator/main/e2e 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/cluster-logging-operator/tech-preview/e2e-operator 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/cloud-credential-operator/release-4.9/e2e-aws-manual-oidc 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/aws-efs-csi-driver-operator/release-4.9/operator-e2e 69aa769 link unknown /test pj-rehearse
ci/rehearse/periodic-ci-openshift-release-master-ci-4.9-e2e-aws-techpreview 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/origin/release-4.2/e2e-cmd 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/ovn-kubernetes/release-4.9/e2e-ovn-hybrid-step-registry 69aa769 link unknown /test pj-rehearse
ci/rehearse/operator-framework/operator-marketplace/release-4.9/e2e-aws-upgrade 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/cluster-kube-controller-manager-operator/release-4.10/e2e-aws-ccm 69aa769 link unknown /test pj-rehearse
ci/rehearse/periodic-ci-openshift-release-master-nightly-4.9-e2e-aws-ovn-local-gateway 69aa769 link unknown /test pj-rehearse
ci/rehearse/openshift/origin/release-4.9/e2e-aws-disruptive 69aa769 link unknown /test pj-rehearse
ci/rehearse/periodic-ci-openshift-release-master-ci-4.9-upgrade-from-stable-4.8-e2e-aws-ovn-upgrade 69aa769 link unknown /test pj-rehearse
ci/prow/pj-rehearse 69aa769 link false /test pj-rehearse

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link
Contributor

@e-tienne e-tienne left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 6, 2021
@e-tienne
Copy link
Contributor

e-tienne commented Oct 6, 2021

/lgtm

Let's just keep an eye on the CI results as soon as it merges to make sure it's working as expected.

@austincunningham
Copy link
Member Author

@e-tienne looks like tide needs an /approve

@austincunningham
Copy link
Member Author

/test build-farm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 21, 2021

@austincunningham: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test app-ci-config-dry
  • /test boskos-config
  • /test boskos-config-generation
  • /test build-clusters
  • /test build01-dry
  • /test build02-dry
  • /test build03-dry
  • /test ci-operator-config
  • /test ci-operator-config-metadata
  • /test ci-operator-registry
  • /test ci-secret-bootstrap-config-validation
  • /test ci-testgrid-allow-list
  • /test config
  • /test core-valid
  • /test correctly-sharded-config
  • /test deprecate-templates
  • /test generated-config
  • /test generated-dashboards
  • /test hive-dry
  • /test openshift-image-mirror-mappings
  • /test ordered-prow-config
  • /test owners
  • /test pj-rehearse-blocking
  • /test prow-config
  • /test prow-config-filenames
  • /test prow-config-semantics
  • /test pylint
  • /test release-config
  • /test release-controller-config
  • /test secret-generator-config-valid
  • /test services-valid
  • /test step-registry-metadata
  • /test step-registry-shellcheck
  • /test yamllint

The following commands are available to trigger optional jobs:

  • /test arm01-dry
  • /test pj-rehearse
  • /test vsphere-dry

Use /test all to run the following jobs that were automatically triggered:

  • pull-ci-openshift-release-ci-secret-bootstrap-config-validation
  • pull-ci-openshift-release-master-app-ci-config-dry
  • pull-ci-openshift-release-master-arm01-dry
  • pull-ci-openshift-release-master-boskos-config
  • pull-ci-openshift-release-master-boskos-config-generation
  • pull-ci-openshift-release-master-build-clusters
  • pull-ci-openshift-release-master-build01-dry
  • pull-ci-openshift-release-master-build02-dry
  • pull-ci-openshift-release-master-build03-dry
  • pull-ci-openshift-release-master-ci-operator-config
  • pull-ci-openshift-release-master-ci-operator-config-metadata
  • pull-ci-openshift-release-master-ci-operator-registry
  • pull-ci-openshift-release-master-config
  • pull-ci-openshift-release-master-core-valid
  • pull-ci-openshift-release-master-correctly-sharded-config
  • pull-ci-openshift-release-master-deprecate-templates
  • pull-ci-openshift-release-master-generated-config
  • pull-ci-openshift-release-master-generated-dashboards
  • pull-ci-openshift-release-master-hive-dry
  • pull-ci-openshift-release-master-ordered-prow-config
  • pull-ci-openshift-release-master-owners
  • pull-ci-openshift-release-master-pj-rehearse
  • pull-ci-openshift-release-master-prow-config
  • pull-ci-openshift-release-master-prow-config-filenames
  • pull-ci-openshift-release-master-prow-config-semantics
  • pull-ci-openshift-release-master-release-config
  • pull-ci-openshift-release-master-release-controller-config
  • pull-ci-openshift-release-master-secret-generator-config-valid
  • pull-ci-openshift-release-master-services-valid
  • pull-ci-openshift-release-master-step-registry-metadata
  • pull-ci-openshift-release-master-step-registry-shellcheck
  • pull-ci-openshift-release-master-vsphere-dry
  • pull-ci-openshift-release-openshift-image-mirror-mappings
  • pull-ci-openshift-release-yamllint

In response to this:

/test build-farm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@austincunningham
Copy link
Member Author

/test build03-dry

@laurafitzgerald
Copy link
Contributor

laurafitzgerald commented Nov 1, 2021

@e-tienne do you have some time to take a look at this one? I see that you've lgtm'd it but it needs an approve to merge. Until this merges our e2e tests are non functional on all of our prs so it is a high priority for us atm. If you had some time that would be great. 🙏

@laurafitzgerald
Copy link
Contributor

ping @csrwng do you have some time to take a look at this pr?

@briangallagher
Copy link

Hi, @wking @e-tienne @csrwng can anyone approve this PR? Or maybe let us know if it can not be merged for some reason? It is open quite a while now. thanks.

@dgoodwin
Copy link
Contributor

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 29, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: austincunningham, dgoodwin, e-tienne

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 29, 2021
@openshift-merge-robot openshift-merge-robot merged commit ed1cadb into openshift:master Nov 29, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 29, 2021

@austincunningham: Updated the step-registry configmap in namespace ci at cluster app.ci using the following files:

  • key ipi-conf-aws-commands.sh using file ci-operator/step-registry/ipi/conf/aws/ipi-conf-aws-commands.sh

In response to this:

WHAT

Issue provision prow clusters on us-east-1e m5.large not supported

level=info msg=Creating infrastructure resources...
level=error
level=error msg=Error: Error launching source instance: Unsupported: Your requested instance type (m5.large) is not supported in your requested Availability Zone (us-east-1e). Please retry your request by not specifying an Availability Zone or choosing us-east-1a, us-east-1b, us-east-1c, us-east-1d, us-east-1f.
level=error msg=	status code: 400, request id: accd0930-a445-4132-b322-6dd268503bbc
level=error
level=error msg=  on ../tmp/openshift-install-312116039/bootstrap/main.tf line 110, in resource "aws_instance" "bootstrap":
level=error msg= 110: resource "aws_instance" "bootstrap" {
level=error
level=error
level=fatal msg=failed to fetch Cluster: failed to generate asset "Cluster": failed to create cluster: failed to apply Terraform: failed to complete the change
Setup phase finished, prepare env for next steps

HOW

Setting the filter to use sort and uniq -c allows ec2 describe-instance-type-offerings to return the correct values

below script can be used to test the conditionals

#!/bin/bash
BOOTSTRAP_NODE_TYPE=m5.large
master_type=null
COMPUTE_NODE_TYPE=m4.xlarge
REGION=us-east-1

if [[ "${BOOTSTRAP_NODE_TYPE}" == "${COMPUTE_NODE_TYPE}" && "${COMPUTE_NODE_TYPE}" == "${master_type}" ]]; then ##"three same regions"
 echo "three same regions"
 aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 1 ' | awk '{print $2}'
elif [[ "${master_type}" == null && "${COMPUTE_NODE_TYPE}" == null  ]]; then 
 echo "two null regions"
 aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 1 ' | awk '{print $2}'
elif [[ "${master_type}" == null || "${COMPUTE_NODE_TYPE}" == null ]]; then
 if [[ "${BOOTSTRAP_NODE_TYPE}" == "${COMPUTE_NODE_TYPE}" || "${BOOTSTRAP_NODE_TYPE}" == "${master_type}" || "${master_type}" == "${COMPUTE_NODE_TYPE}" ]]; then 
   echo "one null region and duplicates"
   aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 1 ' | awk '{print $2}'
 else
   echo "one null region and no duplicates"
   aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 2 ' | awk '{print $2}'
 fi 
elif [[ "${BOOTSTRAP_NODE_TYPE}" == "${COMPUTE_NODE_TYPE}" || "${BOOTSTRAP_NODE_TYPE}" == "${master_type}" || "${master_type}" == "${COMPUTE_NODE_TYPE}" ]]; then 
 echo "duplicates regions no null"
 aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 2 ' | awk '{print $2}'
elif [[ "${BOOTSTRAP_NODE_TYPE}" != "${COMPUTE_NODE_TYPE}" && "${COMPUTE_NODE_TYPE}" != "${master_type}" ]]; then
 echo "three different regions"
 aws --region "${REGION}" ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values="${BOOTSTRAP_NODE_TYPE}","${master_type}","${COMPUTE_NODE_TYPE}" | jq -r '.InstanceTypeOfferings[].Location' | sort | uniq -c | grep ' 3 ' | awk '{print $2}'
fi
us-east-1a
us-east-1b
us-east-1c
us-east-1d
us-east-1f

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants