Skip to content

Commit ae51010

Browse files
committed
replace GLACIER_DA with DEEP_ARCHIVE
Signed-off-by: Utkarsh Srivastava <[email protected]> drop support for GLACIER_IR and fix migration and restore path Signed-off-by: Utkarsh Srivastava <[email protected]>
1 parent d3c091e commit ae51010

File tree

7 files changed

+34
-38
lines changed

7 files changed

+34
-38
lines changed

config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ config.STS_CORS_EXPOSE_HEADERS = 'ETag';
197197
config.DENY_UPLOAD_TO_STORAGE_CLASS_STANDARD = false;
198198

199199
/**
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}
200+
* NSFS_GLACIER_FORCE_STORAGE_CLASS controls which storage
201+
* class to be used if no storage class or `STANDARD` storage
202+
* class is provided.
203+
* @type {nb.StorageClass}
204204
*/
205-
config.NSFS_GLACIER_FORCE_STORAGE_CLASS = false;
205+
config.NSFS_GLACIER_FORCE_STORAGE_CLASS = undefined;
206206

207207
// S3_RESTORE_MAX_DAYS controls that for how many maximum number
208208
// of days an object can be restored using `restore-object` call.

src/endpoint/s3/ops/s3_get_object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function get_object(req, res) {
4141

4242
s3_utils.set_response_object_md(res, object_md);
4343
s3_utils.set_encryption_response_headers(req, res, object_md.encryption);
44-
if (object_md.storage_class === s3_utils.STORAGE_CLASS_GLACIER) {
44+
if (s3_utils.GLACIER_STORAGE_CLASSES.includes(object_md.storage_class)) {
4545
if (object_md.restore_status?.ongoing || !object_md.restore_status?.expiry_time) {
4646
// Don't try to read the object if it's not restored yet
4747
dbg.warn('Object is not restored yet', req.path, object_md.restore_status);

src/endpoint/s3/s3_rest.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ async function handle_request(req, res) {
107107
}
108108
http_utils.check_headers(req, headers_options);
109109

110-
// Will override the storage class if configured
111-
s3_utils.override_storage_class(req);
112-
113110
const redirect = await populate_request_additional_info_or_redirect(req);
114111
if (redirect) {
115112
res.setHeader('Location', redirect);

src/endpoint/s3/s3_utils.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ 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"
2323
/** @type {nb.StorageClass} */
24-
const STORAGE_CLASS_GLACIER_DA = 'GLACIER_DA'; // "DBS3 specific Storage Class"
24+
const STORAGE_CLASS_DEEP_ARCHIVE = 'DEEP_ARCHIVE'; // "S3 Deep Archive Storage Class"
2525

2626
const DEFAULT_S3_USER = Object.freeze({
2727
ID: '123',
@@ -44,6 +44,17 @@ const X_NOOBAA_AVAILABLE_STORAGE_CLASSES = 'x-noobaa-available-storage-classes';
4444
const OBJECT_ATTRIBUTES = Object.freeze(['ETag', 'Checksum', 'ObjectParts', 'StorageClass', 'ObjectSize']);
4545
const OBJECT_ATTRIBUTES_UNSUPPORTED = Object.freeze(['Checksum', 'ObjectParts']);
4646

47+
/**
48+
* Set of storage classes which support RestoreObject S3 API
49+
*
50+
* GLACIER_IR is omitted as it doesn't require a restore.
51+
* @type {nb.StorageClass[]}
52+
*/
53+
const GLACIER_STORAGE_CLASSES = [
54+
STORAGE_CLASS_GLACIER,
55+
STORAGE_CLASS_DEEP_ARCHIVE,
56+
];
57+
4758
/**
4859
* get_default_object_owner returns bucket_owner info if exists
4960
* else it'll return the default owner
@@ -381,10 +392,12 @@ function parse_storage_class_header(req) {
381392
* @returns {nb.StorageClass}
382393
*/
383394
function parse_storage_class(storage_class) {
384-
if (!storage_class) return STORAGE_CLASS_STANDARD;
385-
if (storage_class === STORAGE_CLASS_STANDARD) return STORAGE_CLASS_STANDARD;
395+
if (config.NSFS_GLACIER_FORCE_STORAGE_CLASS) {
396+
storage_class = config.NSFS_GLACIER_FORCE_STORAGE_CLASS;
397+
}
398+
if (!storage_class || storage_class === STORAGE_CLASS_STANDARD) return STORAGE_CLASS_STANDARD;
386399
if (storage_class === STORAGE_CLASS_GLACIER) return STORAGE_CLASS_GLACIER;
387-
if (storage_class === STORAGE_CLASS_GLACIER_DA) return STORAGE_CLASS_GLACIER_DA;
400+
if (storage_class === STORAGE_CLASS_DEEP_ARCHIVE) return STORAGE_CLASS_DEEP_ARCHIVE;
388401
if (storage_class === STORAGE_CLASS_GLACIER_IR) return STORAGE_CLASS_GLACIER_IR;
389402
throw new Error(`No such s3 storage class ${storage_class}`);
390403
}
@@ -822,19 +835,11 @@ function parse_body_public_access_block(req) {
822835
return parsed;
823836
}
824837

825-
function override_storage_class(req) {
826-
if (
827-
config.NSFS_GLACIER_FORCE_STORAGE_CLASS &&
828-
parse_storage_class_header(req) === STORAGE_CLASS_STANDARD
829-
) {
830-
req.headers['x-amz-storage-class'] = STORAGE_CLASS_GLACIER;
831-
}
832-
}
833838

834839
exports.STORAGE_CLASS_STANDARD = STORAGE_CLASS_STANDARD;
835840
exports.STORAGE_CLASS_GLACIER = STORAGE_CLASS_GLACIER;
836841
exports.STORAGE_CLASS_GLACIER_IR = STORAGE_CLASS_GLACIER_IR;
837-
exports.STORAGE_CLASS_GLACIER_DA = STORAGE_CLASS_GLACIER_DA;
842+
exports.STORAGE_CLASS_DEEP_ARCHIVE = STORAGE_CLASS_DEEP_ARCHIVE;
838843
exports.DEFAULT_S3_USER = DEFAULT_S3_USER;
839844
exports.DEFAULT_OBJECT_ACL = DEFAULT_OBJECT_ACL;
840845
exports.decode_chunked_upload = decode_chunked_upload;
@@ -876,6 +881,6 @@ exports.key_marker_to_cont_tok = key_marker_to_cont_tok;
876881
exports.parse_sse_c = parse_sse_c;
877882
exports.verify_string_byte_length = verify_string_byte_length;
878883
exports.parse_body_public_access_block = parse_body_public_access_block;
879-
exports.override_storage_class = override_storage_class;
880884
exports.OBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES;
881885
exports.OBJECT_ATTRIBUTES_UNSUPPORTED = OBJECT_ATTRIBUTES_UNSUPPORTED;
886+
exports.GLACIER_STORAGE_CLASSES = GLACIER_STORAGE_CLASSES;

src/sdk/glacier.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ class Glacier {
339339
*/
340340
static get_restore_status(xattr, now, file_path) {
341341
const storage_class = Glacier.storage_class_from_xattr(xattr);
342-
if (storage_class !== s3_utils.STORAGE_CLASS_GLACIER) {
342+
if (!s3_utils.GLACIER_STORAGE_CLASSES.includes(storage_class)) {
343343
return;
344344
}
345345

src/sdk/namespace_fs.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ class NamespaceFS {
10771077
// Disallow read if the object is in Glacier storage class and isn't restored
10781078
const obj_storage_class = Glacier.storage_class_from_xattr(stat.xattr);
10791079
const obj_restore_status = Glacier.get_restore_status(stat.xattr, new Date(), file_path);
1080-
if (obj_storage_class === s3_utils.STORAGE_CLASS_GLACIER) {
1080+
if (s3_utils.GLACIER_STORAGE_CLASSES.includes(obj_storage_class)) {
10811081
if (obj_restore_status?.ongoing || !obj_restore_status?.expiry_time) {
10821082
dbg.warn('read_object_stream: object is not restored yet', obj_restore_status);
10831083
throw new S3Error(S3Error.InvalidObjectState);
@@ -1307,7 +1307,7 @@ class NamespaceFS {
13071307
const src_storage_class = Glacier.storage_class_from_xattr(stat.xattr);
13081308
const src_restore_status = Glacier.get_restore_status(stat.xattr, new Date(), src_file_path);
13091309

1310-
if (src_storage_class === s3_utils.STORAGE_CLASS_GLACIER) {
1310+
if (s3_utils.GLACIER_STORAGE_CLASSES.includes(src_storage_class)) {
13111311
if (src_restore_status?.ongoing || !src_restore_status?.expiry_time) {
13121312
dbg.warn('_validate_upload: object is not restored yet', src_restore_status);
13131313
throw new S3Error(S3Error.InvalidObjectState);
@@ -1317,7 +1317,7 @@ class NamespaceFS {
13171317
}
13181318
}
13191319

1320-
return params.copy_source && params.storage_class === s3_utils.STORAGE_CLASS_GLACIER;
1320+
return params.copy_source && s3_utils.GLACIER_STORAGE_CLASSES.includes(params.storage_class);
13211321
}
13221322

13231323
// on put part - file path is equal to upload path
@@ -1363,7 +1363,7 @@ class NamespaceFS {
13631363
[Glacier.STORAGE_CLASS_XATTR]: params.storage_class
13641364
});
13651365

1366-
if (params.storage_class === s3_utils.STORAGE_CLASS_GLACIER) {
1366+
if (s3_utils.GLACIER_STORAGE_CLASSES.includes(params.storage_class)) {
13671367
await this.append_to_migrate_wal(file_path);
13681368
}
13691369
}
@@ -2297,7 +2297,7 @@ class NamespaceFS {
22972297
return {
22982298
accepted: false,
22992299
expires_on,
2300-
storage_class: s3_utils.STORAGE_CLASS_GLACIER
2300+
storage_class: Glacier.storage_class_from_xattr(stat.xattr)
23012301
};
23022302
}
23032303
} catch (error) {
@@ -3539,15 +3539,9 @@ class NamespaceFS {
35393539
}
35403540

35413541
async _is_storage_class_supported(storage_class) {
3542-
const glacier_storage_classes = [
3543-
s3_utils.STORAGE_CLASS_GLACIER,
3544-
s3_utils.STORAGE_CLASS_GLACIER_DA,
3545-
s3_utils.STORAGE_CLASS_GLACIER_IR,
3546-
];
3547-
35483542
if (!storage_class || storage_class === s3_utils.STORAGE_CLASS_STANDARD) return true;
35493543

3550-
if (glacier_storage_classes.includes(storage_class)) {
3544+
if (s3_utils.GLACIER_STORAGE_CLASSES.includes(storage_class)) {
35513545
return config.NSFS_GLACIER_ENABLED || false;
35523546
}
35533547

@@ -3619,7 +3613,7 @@ class NamespaceFS {
36193613
if (!config.NSFS_GLACIER_FORCE_EXPIRE_ON_GET) return;
36203614

36213615
const storage_class = s3_utils.parse_storage_class(stat.xattr[Glacier.STORAGE_CLASS_XATTR]);
3622-
if (storage_class !== s3_utils.STORAGE_CLASS_GLACIER) return;
3616+
if (!s3_utils.GLACIER_STORAGE_CLASSES.includes(storage_class)) return;
36233617

36243618
// Remove all the restore related xattrs
36253619
await file.replacexattr(fs_context, {

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' | 'GLACIER_DA';
20+
type StorageClass = 'STANDARD' | 'GLACIER' | 'GLACIER_IR' | 'DEEP_ARCHIVE';
2121
type ResourceType = 'HOSTS' | 'CLOUD' | 'INTERNAL';
2222
type NodeType =
2323
'BLOCK_STORE_S3' |

0 commit comments

Comments
 (0)