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

Add job to clean expired console auth tokens #179

Merged
merged 1 commit into from
Dec 9, 2024
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
7 changes: 7 additions & 0 deletions esi_leap/manager/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from esi_leap.common import statuses
import esi_leap.conf
from esi_leap.manager import utils
from esi_leap.objects import console_auth_token as cat_obj
from esi_leap.objects import lease as lease_obj
from esi_leap.objects import offer as offer_obj
from oslo_context import context as ctx
Expand Down Expand Up @@ -53,6 +54,8 @@ def start(self):
self.tg.add_timer(EVENT_INTERVAL, self._cancel_leases)
LOG.info("Starting _expire_offers periodic job")
self.tg.add_timer(EVENT_INTERVAL, self._expire_offers)
LOG.info("Starting _clean_expired_console_tokens periodic job")
self.tg.add_timer(EVENT_INTERVAL, self._clean_expired_console_tokens)

def stop(self):
super(ManagerService, self).stop()
Expand Down Expand Up @@ -137,6 +140,10 @@ def _expire_offers(self):
offer.status = statuses.ERROR
offer.save()

def _clean_expired_console_tokens(self):
LOG.info("Cleaning expired console tokens")
cat_obj.ConsoleAuthToken.clean_expired_console_tokens()


class ManagerEndpoint(object):
target = utils.get_target()
9 changes: 9 additions & 0 deletions esi_leap/tests/manager/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,12 @@ def test__expire_offers_error(self, mock_ga, mock_utcnow, mock_expire, mock_save
)
self.assertEqual(statuses.ERROR, error_offer.status)
mock_save.assert_called_once()

@mock.patch(
"esi_leap.objects.console_auth_token.ConsoleAuthToken.clean_expired_console_tokens"
)
def test__clean_expired_console_tokens(self, mock_cect):
s = ManagerService()
s._clean_expired_console_tokens()

mock_cect.assert_called_once
Loading