Skip to content

Commit

Permalink
fix(plugins/jail): Bad caching on list_resource (#1535)
Browse files Browse the repository at this point in the history
* fix(plugins/jail): Bad caching on list_resource

This caused a remote cache to be consumed by a local cache. They are now distinct.

Ticket: #37706

* Address William's review
  • Loading branch information
Brandon Schneider committed Jul 13, 2018
1 parent 4ee448e commit e82eeff
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/middlewared/middlewared/plugins/jail.py
Expand Up @@ -283,23 +283,26 @@ def list_resource(self, resource, remote):
)
elif resource == "base":
try:
resource_list = self.middleware.call_sync(
'cache.get', 'iocage_remote_releases')
if remote:
resource_list = self.middleware.call_sync(
'cache.get', 'iocage_remote_releases')

return resource_list
return resource_list
except ClientException as e:
# The jail plugin runs in another process, it's seen as
# a client
if e.trace and e.trace['class'] == 'KeyError':
pass # It's either new or past cache date
else:
raise

resource_list = iocage.fetch(list=True, remote=remote, http=True)

self.middleware.call_sync(
'cache.put', 'iocage_remote_releases', resource_list,
86400
)
if remote:
self.middleware.call_sync(
'cache.put', 'iocage_remote_releases', resource_list,
86400
)
else:
resource_list = iocage.list(resource)

Expand Down

0 comments on commit e82eeff

Please sign in to comment.