Publish should not be blocked on inability to list

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2021-08-09 14:38:33 +02:00
parent bc405be6ed
commit c2d6c8054d
3 changed files with 28 additions and 14 deletions
@@ -178,11 +178,18 @@ export class AwsS3Publish implements PublisherBase {
* Directory structure used in the bucket is - entityNamespace/entityKind/entityName/index.html
*/
async publish({ entity, directory }: PublishRequest): Promise<void> {
// First, retrieve a list of all individual files in currently existing
const remoteFolder = getCloudPathForLocalPath(entity);
const existingFiles = await this.getAllObjectsFromBucket({
prefix: remoteFolder,
});
// First, try to retrieve a list of all individual files currently existing
let existingFiles: string[] = [];
try {
const remoteFolder = getCloudPathForLocalPath(entity);
existingFiles = await this.getAllObjectsFromBucket({
prefix: remoteFolder,
});
} catch (e) {
this.logger.error(
`Unable to list files for Entity ${entity.metadata.name}: ${e.message}`,
);
}
// Then, merge new files into the same folder
let absoluteFilesToUpload;
@@ -137,18 +137,18 @@ export class AzureBlobStoragePublish implements PublisherBase {
* Directory structure used in the container is - entityNamespace/entityKind/entityName/index.html
*/
async publish({ entity, directory }: PublishRequest): Promise<void> {
// First, retrieve a list of all individual files in currently existing
// First, try to retrieve a list of all individual files currently existing
const remoteFolder = getCloudPathForLocalPath(entity);
let existingFiles: string[];
let existingFiles: string[] = [];
try {
existingFiles = await this.getAllBlobsFromContainer({
prefix: remoteFolder,
maxPageSize: BATCH_CONCURRENCY,
});
} catch (e) {
const errorMessage = `Unable to list file(s) to Azure. ${e}`;
this.logger.error(errorMessage);
throw new Error(errorMessage);
this.logger.error(
`Unable to list files for Entity ${entity.metadata.name}: ${e.message}`,
);
}
// Then, merge new files into the same folder
@@ -395,7 +395,7 @@ export class AzureBlobStoragePublish implements PublisherBase {
let response = (await iterator.next()).value;
do {
for (const blob of response.segment.blobItems) {
for (const blob of response?.segment?.blobItems ?? []) {
blobs.push(blob.name);
}
iterator = container
@@ -117,9 +117,16 @@ export class GoogleGCSPublish implements PublisherBase {
async publish({ entity, directory }: PublishRequest): Promise<void> {
const bucket = this.storageClient.bucket(this.bucketName);
// First, retrieve a list of all individual files in currently existing
const remoteFolder = getCloudPathForLocalPath(entity);
const existingFiles = await this.getFilesForFolder(remoteFolder);
// First, try to retrieve a list of all individual files currently existing
let existingFiles: string[] = [];
try {
const remoteFolder = getCloudPathForLocalPath(entity);
existingFiles = await this.getFilesForFolder(remoteFolder);
} catch (e) {
this.logger.error(
`Unable to list files for Entity ${entity.metadata.name}: ${e.message}`,
);
}
// Then, merge new files into the same folder
let absoluteFilesToUpload;