diff --git a/service-level-sidecar/bucketd.js b/service-level-sidecar/bucketd.js index 5c20b7c2..6e634d46 100644 --- a/service-level-sidecar/bucketd.js +++ b/service-level-sidecar/bucketd.js @@ -17,7 +17,12 @@ const params = { const metadata = new BucketClientInterface(params, bucketclient, rootLogger); -const listObjects = utils.retryable(metadata.listObject.bind(metadata)); +const listObjects = utils.retryable((bucket, params, log, cb) => metadata.listObject(bucket, params, log, (err, res) => { + if (err && err.NoSuchBucket) { + return cb(null, []); + } + return cb(err, res); +})); /** * List all s3 buckets implemented as a async generator @@ -36,6 +41,10 @@ async function* listBuckets(log) { // eslint-disable-next-line no-await-in-loop res = await listObjects(usersBucket, { ...listingParams, gt }, log); } catch (error) { + if (error.NoSuchBucket) { + log.info('no buckets found'); + return; + } log.error('Error during listing', { error }); throw error; } diff --git a/service-level-sidecar/scuba.js b/service-level-sidecar/scuba.js index d3df96f3..3770616f 100644 --- a/service-level-sidecar/scuba.js +++ b/service-level-sidecar/scuba.js @@ -15,7 +15,12 @@ const params = { const metadata = new BucketClientInterface(params, bucketclient, rootLogger); -const listObjects = utils.retryable(metadata.listObject.bind(metadata)); +const listObjects = utils.retryable((bucket, params, log, cb) => metadata.listObject(bucket, params, log, (err, res) => { + if (err && err.NoSuchBucket) { + return cb(null, []); + } + return cb(err, res); +})); function roundToDay(timestamp) { return new Date( @@ -53,10 +58,7 @@ async function getMetrics(classType, resourceName, sessionId, timestamp, log) { value: JSON.parse(value), }; } catch (error) { - if (error.NoSuchBucket) { - return null; - } - log.error('error during metric listing', { error: error.message }); + log.error('error during metric listing', { bucket, error: error.message }); throw error; } }