From cff826bff87be7e8f76a24c7340d824a0b167545 Mon Sep 17 00:00:00 2001 From: liranmauda Date: Thu, 8 Feb 2024 09:35:23 +0200 Subject: [PATCH] convert activity logs in the object server to dbg1 convert activity logs in the object server to dbg1 Signed-off-by: liranmauda --- src/server/object_services/object_server.js | 28 +++++---------------- src/test/unit_tests/test_lifecycle.js | 20 ++++----------- 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/src/server/object_services/object_server.js b/src/server/object_services/object_server.js index 4b5b582288..2b47beb746 100644 --- a/src/server/object_services/object_server.js +++ b/src/server/object_services/object_server.js @@ -451,17 +451,11 @@ async function complete_object_upload(req) { const upload_duration = time_utils.format_time_duration(took_ms); const upload_size = size_utils.human_size(set_updates.size); const upload_speed = size_utils.human_size(set_updates.size / took_ms * 1000); - Dispatcher.instance().activity({ - system: req.system._id, - level: 'info', - event: 'obj.uploaded', - obj: obj._id, - actor: req.account && req.account._id, - desc: `${obj.key} was uploaded by ${req.account && req.account.email.unwrap()} into bucket ${req.bucket.name.unwrap()}.` + - `\nUpload size: ${upload_size}.` + - `\nUpload duration: ${upload_duration}.` + - `\nUpload speed: ${upload_speed}/sec.`, - }); + dbg.log1(`${obj.key} was uploaded by ${req.account && req.account.email.unwrap()} into bucket ${req.bucket.name.unwrap()}.` + + `\nUpload size: ${upload_size}.` + + `\nUpload duration: ${upload_duration}.` + + `\nUpload speed: ${upload_speed}/sec.`, + ); return { etag: get_etag(obj, set_updates), version_id: MDStore.instance().get_object_version_id(set_updates), @@ -884,19 +878,9 @@ async function delete_object(req) { const { reply, obj } = req.rpc_params.version_id ? await _delete_object_version(req) : await _delete_object_only_key(req); - if (obj) { - Dispatcher.instance().activity({ - system: req.system._id, - level: 'info', - event: 'obj.deleted', - obj: obj._id, - actor: req.account && req.account._id, - desc: `${obj.key} was deleted by ${req.account && req.account.email.unwrap()}`, - }); - + dbg.log1(`${obj.key} was deleted by ${req.account && req.account.email.unwrap()}`); } - return reply; } diff --git a/src/test/unit_tests/test_lifecycle.js b/src/test/unit_tests/test_lifecycle.js index fa17e04b47..80d468d149 100644 --- a/src/test/unit_tests/test_lifecycle.js +++ b/src/test/unit_tests/test_lifecycle.js @@ -126,22 +126,12 @@ mocha.describe('lifecycle', () => { async function verify_object_deleted(key) { await P.delay(100); // 0.1sec - await rpc_client.system.read_system(); - /* read_activity_log fails w/postgres - see https://github.com/noobaa/noobaa-core/runs/5750698669 - */ - if (config.DB_TYPE === 'mongodb') { - const eventLogs = await rpc_client.events.read_activity_log({limit: 32}); - console.log('read_activity_log logs: ', util.inspect(eventLogs)); - const found = eventLogs.logs.find(e => (e.event === 'obj.deleted') && (e.obj.key === key)); - console.log('read_activity_log found log: ', found); - assert(found && found.obj.key === key, `find deleted actual ${util.inspect(found)} expected ${key}`); - } const listObjectResult = await rpc_client.object.list_objects_admin({ bucket: Bucket, prefix: key }); console.log('list_objects_admin objects: ', util.inspect(listObjectResult.objects)); const actualLength = listObjectResult.objects.length; assert.strictEqual(actualLength, 0, `listObjectResult actual ${actualLength} !== expected 0`); } + mocha.it('test prefix, absolute date expiration', async () => { const key = uuid(); const prefix = key.split('-')[0]; @@ -160,11 +150,11 @@ mocha.describe('lifecycle', () => { const prefix = key.split('-')[0]; const age = 17; const bucket = Bucket; - const tagging = [ {key: 'tagname1', value: 'tagvalue1'}, {key: 'tagname2', value: 'tagvalue2'}, {key: 'tagname3', value: 'tagvalue3'}]; + const tagging = [{ key: 'tagname1', value: 'tagvalue1' }, { key: 'tagname2', value: 'tagvalue2' }, { key: 'tagname3', value: 'tagvalue3' }]; await create_mock_object(key, bucket, age, undefined, tagging); // match by tags subset, out of order - const filter_tagging = [ {key: 'tagname3', value: 'tagvalue3'}, {key: 'tagname2', value: 'tagvalue2'} ]; + const filter_tagging = [{ key: 'tagname3', value: 'tagvalue3' }, { key: 'tagname2', value: 'tagvalue2' }]; const putLifecycleParams = commonTests.date_lifecycle_configuration_and_tags(bucket, prefix, filter_tagging); await s3.putBucketLifecycleConfiguration(putLifecycleParams); await lifecycle.background_worker(); @@ -213,8 +203,8 @@ mocha.describe('lifecycle', () => { const key = uuid(); const object_age = 2; const days = 1; - const tag = { key: 'tagname', value: 'tagvalue'}; - const tagging = [ tag ]; + const tag = { key: 'tagname', value: 'tagvalue' }; + const tagging = [tag]; const bucket = Bucket; await create_mock_object(key, bucket, object_age, undefined, tagging);