Skip to content

Commit

Permalink
handle ENOENT in _finalize_restore
Browse files Browse the repository at this point in the history
Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com>

handle ENOENT in open

Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com>
  • Loading branch information
tangledbytes committed Aug 5, 2024
1 parent a7069fc commit ed61d22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/sdk/nsfs_glacier_backend/tapecloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,17 @@ class TapeCloudGlacierBackend extends GlacierBackend {
const entry = new NewlineReaderEntry(fs_context, entry_path);
let fh = null;
try {
fh = await entry.open("r");
try {
fh = await entry.open("r");
} catch (error) {
// restore does check if a file exist or not before triggering eeadm call but the file could get deleted
// after `restore` performs that check so check it here once again
if (error.code === 'ENOENT') {
dbg.warn(`TapeCloudGlacierBackend._finalize_restore: log entry unexpectedly not found: ${entry.path}`);
return;
}
throw error;
}

const stat = await fh.stat(fs_context, {
xattr_get_keys: [
Expand Down
5 changes: 5 additions & 0 deletions src/test/unit_tests/test_nsfs_glacier_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ mocha.describe('nsfs_glacier', async () => {
assert(failure_stats.xattr[GlacierBackend.XATTR_RESTORE_REQUEST]);
});

mocha.it('_finalize_restore should tolerate deleted objects', async () => {
// should not throw error if the path does not exist
await backend._finalize_restore(glacier_ns.prepare_fs_context(dummy_object_sdk), '/path/does/not/exist');
});

mocha.it('generate_expiry should round up the expiry', () => {
const now = new Date();
const pivot_time = new Date(now);
Expand Down

0 comments on commit ed61d22

Please sign in to comment.