github.com/openshift/installer@v1.4.17/pkg/terraform/diagnose.go (about)

     1  package terraform
     2  
     3  import (
     4  	"regexp"
     5  
     6  	"github.com/openshift/installer/pkg/diagnostics"
     7  )
     8  
     9  // diagnoseApplyError accepts an error from terraform runs and tries to diagnose the
    10  // underlying cause.
    11  func diagnoseApplyError(err error) error {
    12  	if err == nil {
    13  		return nil
    14  	}
    15  
    16  	message := err.Error()
    17  	for _, cand := range conditions {
    18  		if cand.match.MatchString(message) {
    19  			return &diagnostics.Err{
    20  				Source:  "Infrastructure Provider",
    21  				Reason:  cand.reason,
    22  				Message: cand.message,
    23  			}
    24  		}
    25  	}
    26  
    27  	return err
    28  }
    29  
    30  type condition struct {
    31  	match *regexp.Regexp
    32  
    33  	reason  string
    34  	message string
    35  }
    36  
    37  // conditions is a list matches for the error string from terraform.
    38  // specific on the top, generic matches on the bottom.
    39  var conditions = []condition{{
    40  	match: regexp.MustCompile(`Error: Error creating Blob .*: Error copy/waiting`),
    41  
    42  	reason:  "Timeout",
    43  	message: `Copying the VHD to user environment was too slow, and timeout was reached for the success.`,
    44  }, {
    45  	match: regexp.MustCompile(`Error: Error Creating/Updating Subnet .*: network.SubnetsClient#CreateOrUpdate: .* Code="AnotherOperationInProgress" Message="Another operation on this or dependent resource is in progress`),
    46  
    47  	reason:  "AzureMultiOperationFailure",
    48  	message: `Creating Subnets failed because Azure could not process multiple operations.`,
    49  }, {
    50  	match: regexp.MustCompile(`Error: Error Creating/Updating Public IP .*: network.PublicIPAddressesClient#CreateOrUpdate: .* Code="PublicIPCountLimitReached" Message="Cannot create more than .* public IP addresses for this subscription in this region`),
    51  
    52  	reason:  "AzureQuotaLimitExceeded",
    53  	message: `Service limits exceeded for Public IPs in the the subscriptions for the region. Requesting increase in quota should fix the error.`,
    54  }, {
    55  	match: regexp.MustCompile(`Error: compute\.VirtualMachinesClient#CreateOrUpdate: .* Code="OperationNotAllowed" Message="Operation could not be completed as it results in exceeding approved Total Regional Cores quota`),
    56  
    57  	reason:  "AzureQuotaLimitExceeded",
    58  	message: `Service limits exceeded for Virtual Machine cores in the the subscriptions for the region. Requesting increase in quota should fix the error.`,
    59  }, {
    60  	match: regexp.MustCompile(`Error: Code="OSProvisioningTimedOut"`),
    61  
    62  	reason:  "AzureVirtualMachineFailure",
    63  	message: `Some virtual machines failed to provision in alloted time. Virtual machines can fail to provision if the bootstap virtual machine has failing services.`,
    64  }, {
    65  	match: regexp.MustCompile(`Status=404 Code="ResourceGroupNotFound"`),
    66  
    67  	reason:  "AzureEventualConsistencyFailure",
    68  	message: `Failed to find a resource that was recently created usualy caused by Azure's eventual consistency delays.`,
    69  }, {
    70  	match: regexp.MustCompile(`Error: Error applying IAM policy to project .*: Too many conflicts`),
    71  
    72  	reason:  "GCPTooManyIAMUpdatesInFlight",
    73  	message: `There are a lot of IAM updates to the project in flight. Failed after reaching a limit of read-modify-write on conflict backoffs.`,
    74  }, {
    75  	match: regexp.MustCompile(`Error: .*: googleapi: Error 503: .*, backendError`),
    76  
    77  	reason:  "GCPBackendInternalError",
    78  	message: `GCP is experiencing backend service interuptions. Please try again or contact Google Support`,
    79  }, {
    80  	match: regexp.MustCompile(`Error: Error waiting for instance to create: Internal error`),
    81  
    82  	reason:  "GCPComputeBackendTimeout",
    83  	message: `GCP is experiencing backend service interuptions, the compute instance failed to create in reasonable time.`,
    84  }, {
    85  	match: regexp.MustCompile(`Error: could not contact Ironic API: timeout reached`),
    86  
    87  	reason:  "BaremetalIronicAPITimeout",
    88  	message: `Unable to the reach provisioning service. This failure can be caused by incorrect network/proxy settings, inability to download the machine operating system images, or other misconfiguration. Please check access to the bootstrap host, and for any failing services.`,
    89  }, {
    90  	match: regexp.MustCompile(`Error: could not inspect: could not inspect node, node is currently 'inspect failed', last error was 'timeout reached while inspecting the node'`),
    91  
    92  	reason:  "BaremetalIronicInspectTimeout",
    93  	message: `Timed out waiting for node inspection to complete. Please check the console on the host for more details.`,
    94  }}