Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "openio container purge" command, remove unused code #1250

Merged
merged 3 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion meta2v2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ add_executable(meta2_server
meta2_filters_extract.c
meta2_filters_check.c
meta2_filters_misc.c
meta2_filters_action_url.c
meta2_filters_action_container.c
meta2_filters_action_content.c
meta2_filter_context.c
Expand Down
66 changes: 0 additions & 66 deletions meta2v2/meta2_filters_action_url.c

This file was deleted.

11 changes: 1 addition & 10 deletions meta2v2/meta2_gridd_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ static gridd_filter M2V2_PURGE_FILTERS[] =
meta2_filter_check_ns_name,
meta2_filter_check_ns_is_master,
meta2_filter_action_purge_container,
meta2_filter_reply_success,
NULL
};

Expand Down Expand Up @@ -396,14 +397,6 @@ static gridd_filter M2V2_PROPDEL_FILTERS[] =
NULL
};

static gridd_filter M2V2_EXITELECTION_FILTERS[] =
{
meta2_filter_extract_header_url,
meta2_filter_action_exit_election,
meta2_filter_reply_success,
NULL
};

static gridd_filter M2V2_RAW_DEL_filters[] =
{
meta2_filter_extract_header_url,
Expand Down Expand Up @@ -522,8 +515,6 @@ meta2_gridd_get_v2_requests(void)
{NAME_MSGNAME_M2V2_RAW_ADD, (hook) meta2_dispatch_all, M2V2_RAW_ADD_filters},
{NAME_MSGNAME_M2V2_RAW_SUBST, (hook) meta2_dispatch_all, M2V2_RAW_SUBST_filters},

{NAME_MSGNAME_M2V2_EXITELECTION, (hook) meta2_dispatch_all, M2V2_EXITELECTION_FILTERS},

/* AGENT EVENTS */
{NAME_MSGNAME_M2V1_TOUCH_CONTAINER, (hook) meta2_dispatch_all, M2V2_FILTERS_touch_container},
{NAME_MSGNAME_M2V1_TOUCH_CONTENT, (hook) meta2_dispatch_all, M2V2_FILTERS_touch_content},
Expand Down
1 change: 0 additions & 1 deletion meta2v2/meta2_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define NAME_MSGNAME_M2V2_RAW_DEL "M2_RAWDEL"
# define NAME_MSGNAME_M2V2_RAW_ADD "M2_RAWADD"
# define NAME_MSGNAME_M2V2_RAW_SUBST "M2_RAWSUBST"
# define NAME_MSGNAME_M2V2_EXITELECTION "M2_LEAVE"
# define NAME_MSGNAME_M2V1_TOUCH_CONTENT "M2_CTOUCH"
# define NAME_MSGNAME_M2V1_TOUCH_CONTAINER "M2_BTOUCH"

Expand Down
23 changes: 23 additions & 0 deletions oio/cli/container/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,29 @@ def take_action(self, parsed_args):
return zip(*sorted(info.iteritems()))


class PurgeContainer(command.Command):
"""Purge exceeding object versions."""

log = getLogger(__name__ + '.PurgeContainer')

def get_parser(self, prog_name):
parser = super(PurgeContainer, self).get_parser(prog_name)
parser.add_argument(
'container',
metavar='<container>',
help='Container to purge',
)
return parser

def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)

account = self.app.client_manager.account
self.app.client_manager.storage.container.container_purge(
account, parsed_args.container
)


class RefreshContainer(command.Command):
""" Refresh counters of an account (triggers asynchronous treatments) """

Expand Down
6 changes: 0 additions & 6 deletions proxy/meta2v2_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,6 @@ m2v2_remote_pack_PROP_GET(struct oio_url_s *url, guint32 flags)
return _m2v2_pack_request_with_flags(NAME_MSGNAME_M2V2_PROP_GET, url, NULL, flags);
}

GByteArray*
m2v2_remote_pack_EXITELECTION(struct oio_url_s *url)
{
return _m2v2_pack_request(NAME_MSGNAME_M2V2_EXITELECTION, url, NULL);
}

GByteArray*
m2v2_remote_pack_TOUCHC(struct oio_url_s *url)
{
Expand Down
1 change: 0 additions & 1 deletion proxy/meta2v2_remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ GByteArray* m2v2_remote_pack_PROP_SET(
/* accepts M2V2_FLAG_MASTER */
GByteArray* m2v2_remote_pack_PROP_GET(struct oio_url_s *url, guint32 flags);

GByteArray* m2v2_remote_pack_EXITELECTION(struct oio_url_s *url);
GByteArray* m2v2_remote_pack_TOUCHB(struct oio_url_s *url, guint32 flags);
GByteArray* m2v2_remote_pack_TOUCHC(struct oio_url_s *url);

Expand Down
9 changes: 5 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ openio.account =
openio.container =
container_create = oio.cli.container.container:CreateContainer
container_delete = oio.cli.container.container:DeleteContainer
container_touch = oio.cli.container.container:TouchContainer
container_list = oio.cli.container.container:ListContainer
container_locate = oio.cli.container.container:LocateContainer
container_purge = oio.cli.container.container:PurgeContainer
container_refresh = oio.cli.container.container:RefreshContainer
container_save = oio.cli.container.container:SaveContainer
container_set = oio.cli.container.container:SetContainer
container_locate = oio.cli.container.container:LocateContainer
container_show = oio.cli.container.container:ShowContainer
container_unset = oio.cli.container.container:UnsetContainer
container_refresh = oio.cli.container.container:RefreshContainer
container_snapshot = oio.cli.container.container:SnapshotContainer
container_touch = oio.cli.container.container:TouchContainer
container_unset = oio.cli.container.container:UnsetContainer
openio.lifecycle =
lifecycle_apply = oio.cli.lifecycle.lifecycle:LifecycleApply
lifecycle_get = oio.cli.lifecycle.lifecycle:LifecycleGet
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/cli/container/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ def test_container_snapshot(self):
self.assertRaises(CommandFailed,
self.openio,
('container snapshot ' + self.NAME + opts))

def test_container_purge(self):
output = self.openio('container purge ' + self.NAME)
self.assertEqual('', output)
65 changes: 65 additions & 0 deletions tests/functional/content/test_content_versioning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (C) 2017 OpenIO SAS, as part of OpenIO SDS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library.

from oio.api.object_storage import ObjectStorageApi
from tests.utils import BaseTestCase, random_str


class TestContentVersioning(BaseTestCase):

def setUp(self):
super(TestContentVersioning, self).setUp()
self.api = ObjectStorageApi(self.conf['namespace'])
self.container = random_str(8)
system = {'sys.m2.policy.version': '3'}
self.api.container_create(self.account, self.container, system=system)

def test_versioning_enabled(self):
props = self.api.container_get_properties(
self.account, self.container)
self.assertEqual('3', props['system']['sys.m2.policy.version'])

def test_list_versions(self):
self.api.object_create(self.account, self.container,
obj_name="versioned", data="content0")
self.api.object_create(self.account, self.container,
obj_name="versioned", data="content1")
listing = self.api.object_list(self.account, self.container,
versions=True)
objects = listing['objects']
self.assertEqual(2, len(objects))
self.assertNotEqual(objects[0]['version'], objects[1]['version'])

def test_purge(self):
self.api.object_create(self.account, self.container,
obj_name="versioned", data="content0")
self.api.object_create(self.account, self.container,
obj_name="versioned", data="content1")
self.api.object_create(self.account, self.container,
obj_name="versioned", data="content2")
self.api.object_create(self.account, self.container,
obj_name="versioned", data="content3")
listing = self.api.object_list(self.account, self.container,
versions=True)
objects = listing['objects']
self.assertEqual(4, len(objects))
oldest_version = min(objects, lambda x: x['version'])

self.api.container.container_purge(self.account, self.container)
listing = self.api.object_list(self.account, self.container,
versions=True)
objects = listing['objects']
self.assertEqual(3, len(objects))
self.assertNotIn(oldest_version, [x['version'] for x in objects])