Skip to content

Commit 65c6c42

Browse files
committed
replace GLACIER_DA with DEEP_ARCHIVE
Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com> drop support for GLACIER_IR and fix migration and restore path Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com>
1 parent ed6b491 commit 65c6c42

File tree

6 files changed

+25
-33
lines changed

6 files changed

+25
-33
lines changed

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: 15 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,12 @@ 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+
/** @type {nb.StorageClass[]} */
48+
const GLACIER_STORAGE_CLASSES = [
49+
STORAGE_CLASS_GLACIER,
50+
STORAGE_CLASS_DEEP_ARCHIVE,
51+
];
52+
4753
/**
4854
* get_default_object_owner returns bucket_owner info if exists
4955
* else it'll return the default owner
@@ -381,10 +387,13 @@ function parse_storage_class_header(req) {
381387
* @returns {nb.StorageClass}
382388
*/
383389
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;
390+
if (!storage_class || storage_class === STORAGE_CLASS_STANDARD) {
391+
if (config.NSFS_GLACIER_FORCE_STORAGE_CLASS) return STORAGE_CLASS_GLACIER;
392+
return STORAGE_CLASS_STANDARD;
393+
}
394+
386395
if (storage_class === STORAGE_CLASS_GLACIER) return STORAGE_CLASS_GLACIER;
387-
if (storage_class === STORAGE_CLASS_GLACIER_DA) return STORAGE_CLASS_GLACIER_DA;
396+
if (storage_class === STORAGE_CLASS_DEEP_ARCHIVE) return STORAGE_CLASS_DEEP_ARCHIVE;
388397
if (storage_class === STORAGE_CLASS_GLACIER_IR) return STORAGE_CLASS_GLACIER_IR;
389398
throw new Error(`No such s3 storage class ${storage_class}`);
390399
}
@@ -822,19 +831,11 @@ function parse_body_public_access_block(req) {
822831
return parsed;
823832
}
824833

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-
}
833834

834835
exports.STORAGE_CLASS_STANDARD = STORAGE_CLASS_STANDARD;
835836
exports.STORAGE_CLASS_GLACIER = STORAGE_CLASS_GLACIER;
836837
exports.STORAGE_CLASS_GLACIER_IR = STORAGE_CLASS_GLACIER_IR;
837-
exports.STORAGE_CLASS_GLACIER_DA = STORAGE_CLASS_GLACIER_DA;
838+
exports.STORAGE_CLASS_DEEP_ARCHIVE = STORAGE_CLASS_DEEP_ARCHIVE;
838839
exports.DEFAULT_S3_USER = DEFAULT_S3_USER;
839840
exports.DEFAULT_OBJECT_ACL = DEFAULT_OBJECT_ACL;
840841
exports.decode_chunked_upload = decode_chunked_upload;
@@ -876,6 +877,6 @@ exports.key_marker_to_cont_tok = key_marker_to_cont_tok;
876877
exports.parse_sse_c = parse_sse_c;
877878
exports.verify_string_byte_length = verify_string_byte_length;
878879
exports.parse_body_public_access_block = parse_body_public_access_block;
879-
exports.override_storage_class = override_storage_class;
880880
exports.OBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES;
881881
exports.OBJECT_ATTRIBUTES_UNSUPPORTED = OBJECT_ATTRIBUTES_UNSUPPORTED;
882+
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)