Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

fix(INT-6744): add debug log if timeout error #576

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Changes from 1 commit
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
40 changes: 25 additions & 15 deletions src/steps/cloud-build/steps/fetch-cloud-build-bb-repos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const fetchCloudBuildBitbucketRepositoriesStep: GoogleCloudIntegrationSte
context: IntegrationStepContext,
): Promise<void> {
const {
logger,
jobState,
instance: { config },
} = context;
Expand All @@ -40,22 +41,31 @@ export const fetchCloudBuildBitbucketRepositoriesStep: GoogleCloudIntegrationSte
serverConfigEntity,
);

await client.iterateBuildBitbucketRepositories(
serverConfig!,
async (repository) => {
const repositoryEntity =
createGoogleCloudBuildBitbucketRepoEntity(repository);
await jobState.addEntity(repositoryEntity);

await jobState.addRelationship(
createDirectRelationship({
_class: RelationshipClass.HAS,
from: serverConfigEntity,
to: repositoryEntity,
}),
try {
await client.iterateBuildBitbucketRepositories(
serverConfig!,
async (repository) => {
const repositoryEntity =
createGoogleCloudBuildBitbucketRepoEntity(repository);
await jobState.addEntity(repositoryEntity);
await jobState.addRelationship(
createDirectRelationship({
_class: RelationshipClass.HAS,
from: serverConfigEntity,
to: repositoryEntity,
}),
);
},
);
} catch (err) {
if (err.code === 'ATTEMPT_TIMEOUT') {
logger.warn(
`${CloudBuildEntitiesSpec.BUILD_BITBUCKET_SERVER_CONFIG._type} - Unable to fetch BitBucket repositories. This might be caused by expired credentials in the GCP console (Cloud Build).`,
);
},
);
}

throw err;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to try/catch inside client.iterateBuildBitBucketRepositories(). If we encounter ATTEMPT_TIMEOUT here, let's not throw (but throw if encountering any other errors).

}
},
);
},
Expand Down