Skip to content

Commit

Permalink
Merge pull request #625 from cgalibern/fix-817b97660894971e18689393c6…
Browse files Browse the repository at this point in the history
…090d1a57a901c6

Fix purge --local regression
  • Loading branch information
cgalibern committed Jul 31, 2023
2 parents 11917cf + 1b535d7 commit c7703de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions opensvc/core/objects/svc.py
Expand Up @@ -730,6 +730,12 @@ def freezer(self):

@lazy
def id(self):
"""
return object id:
When object has no id a new id is created and if object is not volatile
the object config file is updated.
id should not be called on deleted object else new empty object will be created
"""
try:
return self.conf_get("DEFAULT", "id")
except ex.OptNotFound as exc:
Expand Down Expand Up @@ -2638,6 +2644,9 @@ def print_status(self):
format_instance(self.path, data, mon_data=mon_data, discard_disabled=discard_disabled, nodename=nodename)

def purge(self):
# Set volatile value to True to prevent config file re-creation after deletion (call to self.id will
# update/create config file when DEFAULT.id option is not found)
self.volatile = True
self.options.unprovision = True
self.delete()

Expand Down
13 changes: 13 additions & 0 deletions opensvc/tests/commands/svc/test_svc.py
Expand Up @@ -4,6 +4,19 @@
from commands.svc import Mgr


@pytest.mark.ci
@pytest.mark.usefixtures("osvc_path_tests")
@pytest.mark.usefixtures("has_euid_0")
class TestPurgeLocal:
@staticmethod
def test_object_is_not_recreated_after_local_purge():
svcname = "pytest"
assert Mgr()(argv=["-s", svcname, "create"]) == 0
assert Mgr()(argv=["-s", svcname, "ls"]) == 0
assert Mgr()(argv=["-s", svcname, "purge", "--local"]) == 0
assert Mgr()(argv=["-s", svcname, "ls"]) > 0


@pytest.mark.ci
@pytest.mark.usefixtures("osvc_path_tests")
@pytest.mark.usefixtures("has_euid_0")
Expand Down

0 comments on commit c7703de

Please sign in to comment.