init share server updated_at field

to be able to always make a judgement about the age for automatic cleanup

Change-Id: Ic7d3925035b1563d8acc8f5f24a72231b49a2c89
Closes-Bug: #1993828
This commit is contained in:
Maurice Escher 2022-10-24 08:16:20 +02:00
parent 031fab2c8f
commit ed65c4bb1f
No known key found for this signature in database
GPG Key ID: CC56DEC23EE46750
3 changed files with 10 additions and 1 deletions

View File

@ -4525,6 +4525,8 @@ def share_server_create(context, values):
values = ensure_model_dict_has_id(values)
server_ref = models.ShareServer()
# updated_at is needed for judgement of automatic cleanup
server_ref.updated_at = timeutils.utcnow()
server_ref.update(values)
session = get_session()
with session.begin():

View File

@ -148,7 +148,7 @@ class ShareServerControllerTest(test.TestCase):
'share_server': {
'id': share_server['id'],
'project_id': 'fake',
'updated_at': None,
'updated_at': share_server['updated_at'],
'status': constants.STATUS_ACTIVE,
'host': 'fake_host',
'share_network_id':

View File

@ -0,0 +1,7 @@
---
fixes:
- |
On share server creation initialize the updated_at field with the current
timestamp to fix broken automatic cleanup in rare occasions where a share
server that would be an automatic cleanup target would be pending in state
`creating` forever.