Skip to content

Commit 4edc2a4

Browse files
authored
Merge pull request #8357 from shirady/nsfs-nc-versioning-head-object-with-tagging
NC | NSFS | Fix Bug | Head Object on a Tagged Object Does Not Return `x-amz-tagging-count` Header
2 parents 0e8c024 + cacce05 commit 4edc2a4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/sdk/namespace_fs.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const multi_buffer_pool = new buffer_utils.MultiSizeBuffersPool({
5252

5353
const XATTR_USER_PREFIX = 'user.';
5454
const XATTR_NOOBAA_INTERNAL_PREFIX = XATTR_USER_PREFIX + 'noobaa.';
55-
const XATTR_NOOBAA_CUSTOM_PREFIX = XATTR_NOOBAA_INTERNAL_PREFIX + 'tag.';
5655
// TODO: In order to verify validity add content_md5_mtime as well
5756
const XATTR_MD5_KEY = XATTR_USER_PREFIX + 'content_md5';
5857
const XATTR_CONTENT_TYPE = XATTR_NOOBAA_INTERNAL_PREFIX + 'content_type';
@@ -63,6 +62,7 @@ const XATTR_VERSION_ID = XATTR_NOOBAA_INTERNAL_PREFIX + 'version_id';
6362
const XATTR_PREV_VERSION_ID = XATTR_NOOBAA_INTERNAL_PREFIX + 'prev_version_id';
6463
const XATTR_DELETE_MARKER = XATTR_NOOBAA_INTERNAL_PREFIX + 'delete_marker';
6564
const XATTR_DIR_CONTENT = XATTR_NOOBAA_INTERNAL_PREFIX + 'dir_content';
65+
const XATTR_TAG = XATTR_NOOBAA_INTERNAL_PREFIX + 'tag.';
6666
const HIDDEN_VERSIONS_PATH = '.versions';
6767
const NULL_VERSION_ID = 'null';
6868
const NULL_VERSION_SUFFIX = '_' + NULL_VERSION_ID;
@@ -1967,9 +1967,9 @@ class NamespaceFS {
19671967
const stat = await file.stat(fs_context);
19681968
if (stat.xattr) {
19691969
for (const [xattr_key, xattr_value] of Object.entries(stat.xattr)) {
1970-
if (xattr_key.includes(XATTR_NOOBAA_CUSTOM_PREFIX)) {
1970+
if (xattr_key.includes(XATTR_TAG)) {
19711971
tag_set.push({
1972-
key: xattr_key.replace(XATTR_NOOBAA_CUSTOM_PREFIX, ''),
1972+
key: xattr_key.replace(XATTR_TAG, ''),
19731973
value: xattr_value,
19741974
});
19751975
}
@@ -1993,7 +1993,7 @@ class NamespaceFS {
19931993
}
19941994
const fs_context = this.prepare_fs_context(object_sdk);
19951995
try {
1996-
await this._clear_user_xattr(fs_context, file_path, XATTR_NOOBAA_CUSTOM_PREFIX);
1996+
await this._clear_user_xattr(fs_context, file_path, XATTR_TAG);
19971997
} catch (err) {
19981998
dbg.error(`NamespaceFS.delete_object_tagging: failed in dir ${file_path} with error: `, err);
19991999
throw native_fs_utils.translate_error_codes(err, native_fs_utils.entity_enum.OBJECT);
@@ -2005,7 +2005,7 @@ class NamespaceFS {
20052005
const fs_xattr = {};
20062006
const tagging = params.tagging && Object.fromEntries(params.tagging.map(tag => ([tag.key, tag.value])));
20072007
for (const [xattr_key, xattr_value] of Object.entries(tagging)) {
2008-
fs_xattr[XATTR_NOOBAA_CUSTOM_PREFIX + xattr_key] = xattr_value;
2008+
fs_xattr[XATTR_TAG + xattr_key] = xattr_value;
20092009
}
20102010
let file_path;
20112011
if (params.version_id && this._is_versioning_enabled()) {
@@ -2017,7 +2017,7 @@ class NamespaceFS {
20172017
dbg.log0('NamespaceFS.put_object_tagging: fs_xattr ', fs_xattr, 'file_path :', file_path);
20182018
try {
20192019
// remove existng tag before putting new tags
2020-
await this._clear_user_xattr(fs_context, file_path, XATTR_NOOBAA_CUSTOM_PREFIX);
2020+
await this._clear_user_xattr(fs_context, file_path, XATTR_TAG);
20212021
await this.set_fs_xattr_op(fs_context, file_path, fs_xattr, undefined);
20222022
} catch (err) {
20232023
dbg.error(`NamespaceFS.put_object_tagging: failed in dir ${file_path} with error: `, err);
@@ -2316,6 +2316,10 @@ class NamespaceFS {
23162316
return xattr[XATTR_MD5_KEY];
23172317
}
23182318

2319+
_number_of_tags_fs_xttr(xattr) {
2320+
return Object.keys(xattr).filter(xattr_key => xattr_key.includes(XATTR_TAG)).length;
2321+
}
2322+
23192323
/**
23202324
* @param {string} bucket
23212325
* @param {string} key
@@ -2336,6 +2340,7 @@ class NamespaceFS {
23362340
mime.getType(key) || 'application/octet-stream';
23372341
const storage_class = s3_utils.parse_storage_class(stat.xattr?.[XATTR_STORAGE_CLASS_KEY]);
23382342
const size = Number(stat.xattr?.[XATTR_DIR_CONTENT] || stat.size);
2343+
const tag_count = stat.xattr ? this._number_of_tags_fs_xttr(stat.xattr) : 0;
23392344

23402345
return {
23412346
obj_id: etag,
@@ -2352,9 +2357,9 @@ class NamespaceFS {
23522357
storage_class,
23532358
restore_status: GlacierBackend.get_restore_status(stat.xattr, new Date(), this._get_file_path({key})),
23542359
xattr: to_xattr(stat.xattr),
2360+
tag_count,
23552361

23562362
// temp:
2357-
tag_count: 0,
23582363
lock_settings: undefined,
23592364
md5_b64: undefined,
23602365
num_parts: undefined,

src/test/system_tests/ceph_s3_tests/s3-tests-lists/nsfs_s3_tests_pending_list.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ s3tests_boto3/functional/test_s3.py::test_bucketv2_policy
177177
s3tests_boto3/functional/test_s3.py::test_bucket_policy_another_bucket
178178
s3tests_boto3/functional/test_s3.py::test_bucketv2_policy_another_bucket
179179
s3tests_boto3/functional/test_s3.py::test_get_obj_tagging
180-
s3tests_boto3/functional/test_s3.py::test_get_obj_head_tagging
181180
s3tests_boto3/functional/test_s3.py::test_put_max_tags
182181
s3tests_boto3/functional/test_s3.py::test_bucket_policy_put_obj_s3_noenc
183182
s3tests_boto3/functional/test_s3.py::test_copy_object_ifmatch_failed

0 commit comments

Comments
 (0)