Project

General

Profile

Actions

Bug #54254

closed

when the remove-all parameter of rgw admin operation trim usage interface is set false, the usage is trimmed.

Added by peng liang about 2 years ago. Updated over 1 year ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
% Done:

0%

Source:
Development
Tags:
adminapi usage
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
rgw
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

when the remove-all parameter of rgw admin operation trim usage interface is set false, the usage is trimmed. i use the python3 rgwadmin package, the test code and output is following:
-------------------------------- the test code ----------------------------------

    def test_trim_usage_without_uid_remove_all_false(self):
        tmp_user = 'test_trim_usage_without_uid_remove_all_false'
        tmp_bucket = 'test_trim_usage_without_uid_remove_all_false'
        self.rgw.trim_usage(remove_all=True)
        user_info = {
            'uid': tmp_user,
            'display_name': tmp_user,
            'access_key': tmp_user,
            'secret_key': tmp_user,
            'suspended': False
        }
        self.rgw.create_user(**user_info)
        session = Session(
            aws_access_key_id=user_info['access_key'],
            aws_secret_access_key=user_info['secret_key']
        )
        s3_client = session.client(
            's3',
            endpoint_url='http://'+AdminConfig.host+':'+AdminConfig.port,
            config=Config(signature_version='s3v4')
        )
        s3_client.create_bucket(Bucket=tmp_bucket)
        # 造一个大小10M的文件
        if platform.system() == 'Windows':
            tmp_file = open('./tmp.txt', 'w')
            tmp_file.seek(1024 * 1024 * 10 - 1)
            tmp_file.write('\x00')
            tmp_file.close()
        elif platform.system() == 'Linux':
            os.system('dd if=/dev/zero of=./tmp.txt bs=1M count=10')
        with open('tmp.txt', 'rb') as test_file:
            content = test_file.read()
            s3_client.put_object(
                Bucket=tmp_bucket,
                Body=content,
                Key='tmp.txt'
            )
        os.remove('tmp.txt')
        time.sleep(60)
        res_before_trim = self.rgw.get_usage(show_entries=True, show_summary=True)
        print(res_before_trim)
        print('--------------')
        self.rgw.trim_usage()
        print('--------------')
        time.sleep(120)
        res_after_trim = self.rgw.get_usage(show_entries=True, show_summary=True)
        print(res_after_trim)

---------------------------------- output is following -------------------------

{'entries': [{'user': 'test_trim_usage_without_uid_remove_all_false', 'buckets': [{'bucket': 'test_trim_usage_without_uid_remove_all_false', 'time': '2022-02-11 02:00:00.000000Z', 'epoch': 1644544800, 'owner': 'test_trim_usage_without_uid_remove_all_false', 'categories': [{'category': 'create_bucket', 'bytes_sent': 0, 'bytes_received': 0, 'ops': 1, 'successful_ops': 1}, {'category': 'put_obj', 'bytes_sent': 0, 'bytes_received': 10485760, 'ops': 1, 'successful_ops': 1}]}]}], 'summary': [{'user': 'test_trim_usage_without_uid_remove_all_false', 'categories': [{'category': 'create_bucket', 'bytes_sent': 0, 'bytes_received': 0, 'ops': 1, 'successful_ops': 1}, {'category': 'put_obj', 'bytes_sent': 0, 'bytes_received': 10485760, 'ops': 1, 'successful_ops': 1}], 'total': {'bytes_sent': 0, 'bytes_received': 10485760, 'ops': 2, 'successful_ops': 2}}]}
--------------
-------------- {'entries': [], 'summary': []}

Actions #1

Updated by Casey Bodley about 2 years ago

  • Assignee set to Ali Maredia
Actions #3

Updated by Casey Bodley over 1 year ago

  • Status changed from New to Fix Under Review
  • Tags set to adminapi usage
  • Pull request ID set to 49402
Actions #4

Updated by Casey Bodley over 1 year ago

  • Status changed from Fix Under Review to Resolved
Actions

Also available in: Atom PDF