Skip to content

Commit

Permalink
Regression fix: not purged object is not purged after 'purge --local'
Browse files Browse the repository at this point in the history
call_action -> self.setup_environ -> os.environ['OPENSVC_SVC_ID'] = self.id -> create object if object is absent and not self.volatile

So after purge/delete action the object is recreated

The regression was introduced by #817b97660894971e18689393c6090d1a57a901c6

Reproduce bug with:
   om foo create
   om foo purge --local
   om foo ls
  • Loading branch information
cgalibern committed Jul 27, 2023
1 parent 11917cf commit 025b64d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion opensvc/core/objects/svc.py
Original file line number Diff line number Diff line change
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 @@ -1793,7 +1799,11 @@ def restore():
os.environ.update(prev_env)
os.environ['OPENSVC_SVCPATH'] = self.path
os.environ['OPENSVC_SVCNAME'] = self.name
os.environ['OPENSVC_SVC_ID'] = self.id
try:
os.environ['OPENSVC_SVC_ID'] = self.conf_get("DEFAULT", "id")
except:
# don't call self.id (to avoid create object side effect when object is deleted)
pass
os.environ['OPENSVC_KIND'] = self.kind
if self.namespace:
os.environ['OPENSVC_NAMESPACE'] = self.namespace
Expand Down

0 comments on commit 025b64d

Please sign in to comment.