-
Notifications
You must be signed in to change notification settings - Fork 89
[NSFS | GLACIER] Add support for GLACIER_DA and forced GLACIER #9219
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ const STORAGE_CLASS_STANDARD = 'STANDARD'; | |
const STORAGE_CLASS_GLACIER = 'GLACIER'; // "S3 Glacier Flexible Retrieval" | ||
/** @type {nb.StorageClass} */ | ||
const STORAGE_CLASS_GLACIER_IR = 'GLACIER_IR'; // "S3 Glacier Instant Retrieval" | ||
/** @type {nb.StorageClass} */ | ||
const STORAGE_CLASS_GLACIER_DA = 'GLACIER_DA'; // "DBS3 specific Storage Class" | ||
|
||
const DEFAULT_S3_USER = Object.freeze({ | ||
ID: '123', | ||
|
@@ -382,6 +384,7 @@ function parse_storage_class(storage_class) { | |
if (!storage_class) return STORAGE_CLASS_STANDARD; | ||
if (storage_class === STORAGE_CLASS_STANDARD) return STORAGE_CLASS_STANDARD; | ||
if (storage_class === STORAGE_CLASS_GLACIER) return STORAGE_CLASS_GLACIER; | ||
if (storage_class === STORAGE_CLASS_GLACIER_DA) return STORAGE_CLASS_GLACIER_DA; | ||
if (storage_class === STORAGE_CLASS_GLACIER_IR) return STORAGE_CLASS_GLACIER_IR; | ||
throw new Error(`No such s3 storage class ${storage_class}`); | ||
} | ||
|
@@ -819,9 +822,19 @@ function parse_body_public_access_block(req) { | |
return parsed; | ||
} | ||
|
||
function override_storage_class(req) { | ||
if ( | ||
config.NSFS_GLACIER_FORCE_STORAGE_CLASS && | ||
parse_storage_class_header(req) === STORAGE_CLASS_STANDARD | ||
) { | ||
req.headers['x-amz-storage-class'] = STORAGE_CLASS_GLACIER; | ||
} | ||
} | ||
Comment on lines
+825
to
+832
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add JSDoc documentation for side effects and behavior. The Apply this diff to add JSDoc documentation: +/**
+ * override_storage_class rewrites the storage class header to GLACIER when
+ * NSFS_GLACIER_FORCE_STORAGE_CLASS is enabled and the incoming storage class
+ * is STANDARD (or not specified, which defaults to STANDARD).
+ *
+ * This function mutates req.headers as a side effect.
+ *
+ * @param {nb.S3Request} req - The S3 request object
+ */
function override_storage_class(req) {
if (
config.NSFS_GLACIER_FORCE_STORAGE_CLASS &&
parse_storage_class_header(req) === STORAGE_CLASS_STANDARD
) {
req.headers['x-amz-storage-class'] = STORAGE_CLASS_GLACIER;
}
} 🤖 Prompt for AI Agents
|
||
|
||
exports.STORAGE_CLASS_STANDARD = STORAGE_CLASS_STANDARD; | ||
exports.STORAGE_CLASS_GLACIER = STORAGE_CLASS_GLACIER; | ||
exports.STORAGE_CLASS_GLACIER_IR = STORAGE_CLASS_GLACIER_IR; | ||
exports.STORAGE_CLASS_GLACIER_DA = STORAGE_CLASS_GLACIER_DA; | ||
exports.DEFAULT_S3_USER = DEFAULT_S3_USER; | ||
exports.DEFAULT_OBJECT_ACL = DEFAULT_OBJECT_ACL; | ||
exports.decode_chunked_upload = decode_chunked_upload; | ||
|
@@ -863,5 +876,6 @@ exports.key_marker_to_cont_tok = key_marker_to_cont_tok; | |
exports.parse_sse_c = parse_sse_c; | ||
exports.verify_string_byte_length = verify_string_byte_length; | ||
exports.parse_body_public_access_block = parse_body_public_access_block; | ||
exports.override_storage_class = override_storage_class; | ||
exports.OBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES; | ||
exports.OBJECT_ATTRIBUTES_UNSUPPORTED = OBJECT_ATTRIBUTES_UNSUPPORTED; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3612,11 +3612,15 @@ class NamespaceFS { | |
} | ||
|
||
async _is_storage_class_supported(storage_class) { | ||
const glacier_storage_classes = [ | ||
s3_utils.STORAGE_CLASS_GLACIER, | ||
s3_utils.STORAGE_CLASS_GLACIER_DA, | ||
s3_utils.STORAGE_CLASS_GLACIER_IR, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newly added storage class in STORAGE_CLASS_GLACIER_DA, And STORAGE_CLASS_GLACIER_IR was missing in previous check? Is there any reason for adding it now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, these are newly added. |
||
]; | ||
|
||
if (!storage_class || storage_class === s3_utils.STORAGE_CLASS_STANDARD) return true; | ||
|
||
if (storage_class === s3_utils.STORAGE_CLASS_GLACIER) { | ||
// TODO: Upon integration with underlying systems, we should | ||
// check if archiving is actually supported or not | ||
if (glacier_storage_classes.includes(storage_class)) { | ||
return config.NSFS_GLACIER_ENABLED || false; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not mutate headers before SigV4 auth; move override after authenticate_request()
Changing x-amz-storage-class pre-auth can invalidate AWS SigV4 when that header is signed. Apply override after authenticate_request(req) and before authorize_request(req); also limit to relevant ops.
Apply this diff:
Place this block immediately after
authenticate_request(req);
:📝 Committable suggestion
🤖 Prompt for AI Agents