Skip to content

Commit

Permalink
convert activity logs in the object server to dbg1
Browse files Browse the repository at this point in the history
convert activity logs in the object server to dbg1

Signed-off-by: liranmauda <liran.mauda@gmail.com>
  • Loading branch information
liranmauda committed Feb 13, 2024
1 parent f038322 commit cff826b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
28 changes: 6 additions & 22 deletions src/server/object_services/object_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}

Expand Down
20 changes: 5 additions & 15 deletions src/test/unit_tests/test_lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit cff826b

Please sign in to comment.