Skip to content

Commit

Permalink
Merge pull request #8491 from shirady/nsfs-nc-put-object-error
Browse files Browse the repository at this point in the history
NC | NSFS | Versioning | Avoid Errors On Put Object of Directory Content
  • Loading branch information
shirady authored Nov 7, 2024
2 parents 8171306 + 3120d3d commit 19f68c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sdk/namespace_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ class NamespaceFS {
dbg.log1('NamespaceFS._finish_upload:', open_mode, file_path, upload_path, fs_xattr);

if (!same_inode && !part_upload) {
await this._move_to_dest(fs_context, upload_path, file_path, target_file, open_mode, params.key);
await this._move_to_dest(fs_context, upload_path, file_path, target_file, open_mode, params.key, is_dir_content);
}

// when object is a dir, xattr are set on the folder itself and the content is in .folder file
Expand Down Expand Up @@ -1421,13 +1421,16 @@ class NamespaceFS {
}

// move to dest GPFS (wt) / POSIX (w / undefined) - non part upload
async _move_to_dest(fs_context, source_path, dest_path, target_file, open_mode, key) {
async _move_to_dest(fs_context, source_path, dest_path, target_file, open_mode, key, is_dir_content) {
dbg.log2('_move_to_dest', fs_context, source_path, dest_path, target_file, open_mode, key, is_dir_content);
let retries = config.NSFS_RENAME_RETRIES;
// will retry renaming a file in case of parallel deleting of the destination path
for (;;) {
try {
await native_fs_utils._make_path_dirs(dest_path, fs_context);
if (this._is_versioning_disabled()) {
if (this._is_versioning_disabled() ||
(this._is_versioning_enabled() && is_dir_content)) {
// dir_content is not supported in versioning, hence we will treat it like versioning disabled
if (open_mode === 'wt') {
await target_file.linkfileat(fs_context, dest_path);
} else {
Expand Down
15 changes: 15 additions & 0 deletions src/test/unit_tests/test_bucketspace_versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,21 @@ mocha.describe('bucketspace namespace_fs - versioning', function() {
}
assert.deepEqual(res_version_ids, res_put_version_ids);
});

// dir_content is not supported in versioning, but we want to make sure there are no errors
mocha.it('put object - versioning enabled - directory content', async function() {
await s3_uid6.putBucketVersioning({ Bucket: nested_keys_bucket_name, VersioningConfiguration: { MFADelete: 'Disabled', Status: 'Enabled' } });
const key_as_dir_content = '/a/b/c/';
const size = 4; // in the original issue the error started on the 3rd PUT of dir content
const res_put_object = [];
for (let i = 0; i < size; i++) {
const res = await s3_uid6.putObject({ Bucket: nested_keys_bucket_name, Key: key_as_dir_content, Body: body1 });
res_put_object.push(res);
}
assert(res_put_object.length === size);
const check_version_id_exists = res_put_object.every(res => res.VersionId !== undefined);
assert.ok(check_version_id_exists);
});
});

mocha.describe('mpu object', function() {
Expand Down

0 comments on commit 19f68c0

Please sign in to comment.