Skip to content

Commit 5f95df5

Browse files
committed
NSFS | fix copy_object issues
1 parent 8961f1d commit 5f95df5

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/sdk/namespace_fs.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class NamespaceFS {
483483
}
484484

485485
/**
486-
* @param {nb.ObjectSDK} object_sdk
486+
* @param {nb.ObjectSDK} object_sdk
487487
* @returns {nb.NativeFSContext}
488488
*/
489489
prepare_fs_context(object_sdk) {
@@ -1090,7 +1090,7 @@ class NamespaceFS {
10901090
// end the stream
10911091
res.end();
10921092

1093-
await stream_utils.wait_finished(res, { signal: object_sdk.abort_controller.signal });
1093+
await stream_utils.wait_finished(res, { readable: false, signal: object_sdk.abort_controller.signal });
10941094
object_sdk.throw_if_aborted();
10951095

10961096
dbg.log0('NamespaceFS: read_object_stream completed file', file_path, {
@@ -1209,9 +1209,7 @@ class NamespaceFS {
12091209
}
12101210

12111211
if (copy_res) {
1212-
if (copy_res === copy_status_enum.FALLBACK) {
1213-
params.copy_source.nsfs_copy_fallback();
1214-
} else {
1212+
if (copy_res !== copy_status_enum.FALLBACK) {
12151213
// open file after copy link/same inode should use read open mode
12161214
open_mode = config.NSFS_OPEN_READ_MODE;
12171215
if (copy_res === copy_status_enum.SAME_INODE) open_path = file_path;
@@ -1294,10 +1292,8 @@ class NamespaceFS {
12941292
let stat = await target_file.stat(fs_context);
12951293
this._verify_encryption(params.encryption, this._get_encryption_info(stat));
12961294

1297-
// handle xattr
1298-
// assign user xattr on non copy / copy with xattr_copy header provided
12991295
const copy_xattr = params.copy_source && params.xattr_copy;
1300-
let fs_xattr = copy_xattr ? undefined : to_fs_xattr(params.xattr);
1296+
let fs_xattr = to_fs_xattr(params.xattr);
13011297

13021298
// assign noobaa internal xattr - content type, md5, versioning xattr
13031299
if (params.content_type) {
@@ -1510,7 +1506,7 @@ class NamespaceFS {
15101506
// Can be finetuned further on if needed and inserting the Semaphore logic inside
15111507
// Instead of wrapping the whole _upload_stream function (q_buffers lives outside of the data scope of the stream)
15121508
async _upload_stream({ fs_context, params, target_file, object_sdk, offset }) {
1513-
const { source_stream } = params;
1509+
const { source_stream, copy_source } = params;
15141510
try {
15151511
// Not using async iterators with ReadableStreams due to unsettled promises issues on abort/destroy
15161512
const md5_enabled = this._is_force_md5_enabled(object_sdk);
@@ -1525,8 +1521,12 @@ class NamespaceFS {
15251521
large_buf_size: multi_buffer_pool.get_buffers_pool(undefined).buf_size
15261522
});
15271523
chunk_fs.on('error', err1 => dbg.error('namespace_fs._upload_stream: error occured on stream ChunkFS: ', err1));
1528-
await stream_utils.pipeline([source_stream, chunk_fs]);
1529-
await stream_utils.wait_finished(chunk_fs);
1524+
if (copy_source) {
1525+
await this.read_object_stream(copy_source, object_sdk, chunk_fs);
1526+
} else {
1527+
await stream_utils.pipeline([source_stream, chunk_fs]);
1528+
await stream_utils.wait_finished(chunk_fs);
1529+
}
15301530
return { digest: chunk_fs.digest, total_bytes: chunk_fs.total_bytes };
15311531
} catch (error) {
15321532
dbg.error('_upload_stream had error: ', error);
@@ -1812,6 +1812,7 @@ class NamespaceFS {
18121812
upload_params.params.xattr = create_params_parsed.xattr;
18131813
upload_params.params.storage_class = create_params_parsed.storage_class;
18141814
upload_params.digest = MD5Async && (((await MD5Async.digest()).toString('hex')) + '-' + multiparts.length);
1815+
upload_params.params.content_type = create_params_parsed.content_type;
18151816

18161817
const upload_info = await this._finish_upload(upload_params);
18171818

src/sdk/object_sdk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ class ObjectSDK {
642642
params.content_type = source_md.content_type;
643643
}
644644
try {
645-
if (params.xattr) params.xattr = _.omitBy(params.xattr, (val, name) => name.startsWith('noobaa-namespace'));
645+
if (params.xattr) params.xattr = _.omitBy(params.xattr, (val, name) => name.startsWith?.('noobaa-namespace'));
646646
} catch (e) {
647647
dbg.log3("Got an error while trying to omitBy param.xattr:", params.xattr, "error:", e);
648648
}

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
@@ -157,7 +157,6 @@ s3tests_boto3/functional/test_s3.py::test_object_copy_to_itself_with_metadata
157157
s3tests_boto3/functional/test_s3.py::test_object_copy_canned_acl
158158
s3tests_boto3/functional/test_s3.py::test_object_copy_retaining_metadata
159159
s3tests_boto3/functional/test_s3.py::test_object_copy_replacing_metadata
160-
s3tests_boto3/functional/test_s3.py::test_object_copy_versioning_multipart_upload
161160
s3tests_boto3/functional/test_s3.py::test_list_multipart_upload
162161
s3tests_boto3/functional/test_s3.py::test_multipart_upload_missing_part
163162
s3tests_boto3/functional/test_s3.py::test_multipart_upload_incorrect_etag

0 commit comments

Comments
 (0)