Skip to content

Commit 1f45c29

Browse files
committed
Add support for GLACIER_DA and forced GLACIER
Signed-off-by: Utkarsh Srivastava <[email protected]>
1 parent 7521471 commit 1f45c29

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ config.STS_CORS_EXPOSE_HEADERS = 'ETag';
196196

197197
config.DENY_UPLOAD_TO_STORAGE_CLASS_STANDARD = false;
198198

199+
/**
200+
* NSFS_GLACIER_FORCE_STORAGE_CLASS when set to true
201+
* will force `GLACIER` storage class if no storage class
202+
* is provided and if `STANDARD` storage class is provided
203+
* @type {boolean}
204+
*/
205+
config.NSFS_GLACIER_FORCE_STORAGE_CLASS = false;
206+
199207
// S3_RESTORE_MAX_DAYS controls that for how many maximum number
200208
// of days an object can be restored using `restore-object` call.
201209
config.S3_RESTORE_REQUEST_MAX_DAYS = 30;

src/endpoint/s3/s3_utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const STORAGE_CLASS_STANDARD = 'STANDARD';
2020
const STORAGE_CLASS_GLACIER = 'GLACIER'; // "S3 Glacier Flexible Retrieval"
2121
/** @type {nb.StorageClass} */
2222
const STORAGE_CLASS_GLACIER_IR = 'GLACIER_IR'; // "S3 Glacier Instant Retrieval"
23+
/** @type {nb.StorageClass} */
24+
const STORAGE_CLASS_GLACIER_DA = 'GLACIER_DA'; // "DBS3 specific Storage Class"
2325

2426
const DEFAULT_S3_USER = Object.freeze({
2527
ID: '123',
@@ -382,6 +384,7 @@ function parse_storage_class(storage_class) {
382384
if (!storage_class) return STORAGE_CLASS_STANDARD;
383385
if (storage_class === STORAGE_CLASS_STANDARD) return STORAGE_CLASS_STANDARD;
384386
if (storage_class === STORAGE_CLASS_GLACIER) return STORAGE_CLASS_GLACIER;
387+
if (storage_class === STORAGE_CLASS_GLACIER_DA) return STORAGE_CLASS_GLACIER_DA;
385388
if (storage_class === STORAGE_CLASS_GLACIER_IR) return STORAGE_CLASS_GLACIER_IR;
386389
throw new Error(`No such s3 storage class ${storage_class}`);
387390
}
@@ -822,6 +825,7 @@ function parse_body_public_access_block(req) {
822825
exports.STORAGE_CLASS_STANDARD = STORAGE_CLASS_STANDARD;
823826
exports.STORAGE_CLASS_GLACIER = STORAGE_CLASS_GLACIER;
824827
exports.STORAGE_CLASS_GLACIER_IR = STORAGE_CLASS_GLACIER_IR;
828+
exports.STORAGE_CLASS_GLACIER_DA = STORAGE_CLASS_GLACIER_DA;
825829
exports.DEFAULT_S3_USER = DEFAULT_S3_USER;
826830
exports.DEFAULT_OBJECT_ACL = DEFAULT_OBJECT_ACL;
827831
exports.decode_chunked_upload = decode_chunked_upload;

src/sdk/namespace_fs.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,11 +3610,15 @@ class NamespaceFS {
36103610
}
36113611

36123612
async _is_storage_class_supported(storage_class) {
3613+
const glacier_storage_classes = [
3614+
s3_utils.STORAGE_CLASS_GLACIER,
3615+
s3_utils.STORAGE_CLASS_GLACIER_DA,
3616+
s3_utils.STORAGE_CLASS_GLACIER_IR,
3617+
];
3618+
36133619
if (!storage_class || storage_class === s3_utils.STORAGE_CLASS_STANDARD) return true;
36143620

3615-
if (storage_class === s3_utils.STORAGE_CLASS_GLACIER) {
3616-
// TODO: Upon integration with underlying systems, we should
3617-
// check if archiving is actually supported or not
3621+
if (!storage_class || glacier_storage_classes.includes(storage_class)) {
36183622
return config.NSFS_GLACIER_ENABLED || false;
36193623
}
36203624

src/sdk/nb.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type DigestType = 'sha1' | 'sha256' | 'sha384' | 'sha512';
1717
type CompressType = 'snappy' | 'zlib';
1818
type CipherType = 'aes-256-gcm';
1919
type ParityType = 'isa-c1' | 'isa-rs' | 'cm256';
20-
type StorageClass = 'STANDARD' | 'GLACIER' | 'GLACIER_IR';
20+
type StorageClass = 'STANDARD' | 'GLACIER' | 'GLACIER_IR' | 'GLACIER_DA';
2121
type ResourceType = 'HOSTS' | 'CLOUD' | 'INTERNAL';
2222
type NodeType =
2323
'BLOCK_STORE_S3' |

src/util/http_utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const net_utils = require('./net_utils');
2323
const time_utils = require('./time_utils');
2424
const cloud_utils = require('./cloud_utils');
2525
const ssl_utils = require('../util/ssl_utils');
26+
const s3_utils = require('../endpoint/s3/s3_utils');
2627
const lifecycle_utils = require('../../src/util/lifecycle_utils');
2728
const RpcError = require('../rpc/rpc_error');
2829
const S3Error = require('../endpoint/s3/s3_errors').S3Error;
@@ -654,6 +655,13 @@ function check_headers(req, options) {
654655
if (!is_presigned_url && (Math.abs(Date.now() - req_time) > config.AMZ_DATE_MAX_TIME_SKEW_MILLIS)) {
655656
throw new options.ErrorClass(options.error_request_time_too_skewed);
656657
}
658+
659+
if (
660+
config.NSFS_GLACIER_FORCE_STORAGE_CLASS &&
661+
s3_utils.parse_storage_class_header(req) === s3_utils.STORAGE_CLASS_STANDARD
662+
) {
663+
req.headers['x-amz-storage-class'] = s3_utils.STORAGE_CLASS_GLACIER;
664+
}
657665
}
658666

659667
/**

0 commit comments

Comments
 (0)