Skip to content

Commit

Permalink
fix(terraform): externalhosterror for 503 (#12760)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
rarkins and viceice committed Dec 8, 2021
1 parent 65ed85a commit 052e92e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 14 additions & 0 deletions lib/datasource/terraform-module/base.ts
@@ -1,4 +1,6 @@
import { ExternalHostError } from '../../types/errors/external-host-error';
import { cache } from '../../util/cache/package/decorator';
import type { HttpError } from '../../util/http/types';
import { ensureTrailingSlash } from '../../util/url';
import { Datasource } from '../datasource';
import type { ServiceDiscoveryResult } from './types';
Expand Down Expand Up @@ -26,4 +28,16 @@ export abstract class TerraformDatasource extends Datasource {
private static getDiscoveryUrl(registryUrl: string): string {
return `${ensureTrailingSlash(registryUrl)}.well-known/terraform.json`;
}

override handleSpecificErrors(err: HttpError): void {
const failureCodes = ['EAI_AGAIN'];
// istanbul ignore if
if (failureCodes.includes(err.code)) {
throw new ExternalHostError(err);
}
// istanbul ignore if
if (err.response?.statusCode === 503) {
throw new ExternalHostError(err);
}
}
}
10 changes: 0 additions & 10 deletions lib/datasource/terraform-module/index.ts
@@ -1,7 +1,5 @@
import { logger } from '../../logger';
import { ExternalHostError } from '../../types/errors/external-host-error';
import { cache } from '../../util/cache/package/decorator';
import type { HttpError } from '../../util/http/types';
import { regEx } from '../../util/regex';
import * as hashicorpVersioning from '../../versioning/hashicorp';
import type { GetReleasesConfig, ReleaseResult } from '../types';
Expand Down Expand Up @@ -83,14 +81,6 @@ export class TerraformModuleDatasource extends TerraformDatasource {
return dep;
}

override handleSpecificErrors(err: HttpError): void {
const failureCodes = ['EAI_AGAIN'];
// istanbul ignore if
if (failureCodes.includes(err.code)) {
throw new ExternalHostError(err);
}
}

private static getRegistryRepository(
lookupName: string,
registryUrl: string
Expand Down

0 comments on commit 052e92e

Please sign in to comment.