Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTEGRATION [PR#1823 > development/8.1] feature: ARSN-164 rpc error utils missing is #1824

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export const zenkoSeparator = ':';
/* eslint-disable camelcase */
export const externalBackends = { aws_s3: true, azure: true, gcp: true, pfs: true };
export const replicationBackends = { aws_s3: true, azure: true, gcp: true };

// hex digest of sha256 hash of empty string:
export const emptyStringHash = crypto.createHash('sha256')
.update('', 'binary').digest('hex');
Expand Down
4 changes: 3 additions & 1 deletion lib/network/rpc/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ module.exports.reconstructError = function reconstructError(err) {
return err;
}
const reconstructedErr = new Error(err.message);

reconstructedErr.is = {
[err.message]: true,
};
Object.keys(err).forEach(k => {
reconstructedErr[k] = err[k];
});
Expand Down
4 changes: 2 additions & 2 deletions lib/storage/data/DataWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class DataWrapper {
return;
}
this._retryDelete(clientGetInfo, log, 0, err => {
if (err && !err.ObjNotFound) {
if (err && !err.is.ObjNotFound) {
log.error('delete error from datastore',
{ error: err, key: objectGetInfo.key, moreRetries: 'no' });
}
Expand Down Expand Up @@ -984,7 +984,7 @@ class DataWrapper {
return this.client.delete(objectGetInfo, log.getSerializedUids(),
err => {
if (err) {
if (err.ObjNotFound) {
if (err.is.ObjNotFound) {
log.info('no such key in datastore', {
objectGetInfo,
implName: this.implName,
Expand Down
22 changes: 9 additions & 13 deletions lib/storage/metadata/file/BucketFileInterface.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const cluster = require('cluster');
const async = require('async');

const errors = require('../../../errors').default;
Expand All @@ -20,7 +19,6 @@ class BucketFileInterface {
/**
* @constructor
* @param {object} [params] - constructor params
* @param {boolean} [params.noDbOpen=false] - true to skip DB open
* @param {object} logger - logger
* (for unit tests only)
*/
Expand All @@ -29,9 +27,6 @@ class BucketFileInterface {
const { host, port } = params.metadataClient;
this.constants = params.constants;
this.mdClient = new MetadataFileClient({ host, port });
if (params && params.noDbOpen) {
return;
}
this.lastItemScanTime = null;
this.lastItemScanResult = null;
}
Expand All @@ -44,16 +39,17 @@ class BucketFileInterface {
// the metastore sublevel is used to store bucket attributes
this.mdDB = value;
this.metastore = this.mdDB.openSub(METASTORE);
if (cluster.isMaster) {
this.setupMetadataServer(done);
}
this.setupMetadataServer(done);
});
}

setupMetadataServer(done) {
/* Since the bucket creation API is expecting the
usersBucket to have attributes, we pre-create the
usersBucket attributes here */
usersBucket attributes here.
This call is idempotent so we are ok calling it many times
when using multiple workers.
*/
this.mdClient.logger.debug('setting up metadata server');
const usersBucketAttr = new BucketInfo(this.constants.usersBucket,
'admin', 'admin', new Date().toJSON(),
Expand Down Expand Up @@ -95,7 +91,7 @@ class BucketFileInterface {

createBucket(bucketName, bucketMD, log, cb) {
this.getBucketAttributes(bucketName, log, err => {
if (err && err !== errors.NoSuchBucket) {
if (err && !err.is.NoSuchBucket) {
return cb(err);
}
if (err === undefined) {
Expand All @@ -114,7 +110,7 @@ class BucketFileInterface {
.withRequestLogger(log)
.get(bucketName, {}, (err, data) => {
if (err) {
if (err.ObjNotFound) {
if (err.is.ObjNotFound) {
return cb(errors.NoSuchBucket);
}
const logObj = {
Expand All @@ -138,7 +134,7 @@ class BucketFileInterface {
db.withRequestLogger(log)
.get(objName, params, (err, objAttr) => {
if (err) {
if (err.ObjNotFound) {
if (err.is.ObjNotFound) {
return cb(null, {
bucket: bucketAttr.serialize(),
});
Expand Down Expand Up @@ -232,7 +228,7 @@ class BucketFileInterface {
}
db.withRequestLogger(log).get(objName, params, (err, data) => {
if (err) {
if (err.ObjNotFound) {
if (err.is.ObjNotFound) {
return cb(errors.NoSuchKey);
}
const logObj = {
Expand Down