summaryrefslogtreecommitdiff
path: root/zuul/driver
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-09-18 07:32:50 +0000
committerGerrit Code Review <review@openstack.org>2021-09-18 07:32:50 +0000
commitfc4324e4a4d19f5d2c6ce669241faacb8a1b2294 (patch)
tree5ee9d2dcd5152a4b66f16954d7d86243031cda52 /zuul/driver
parent7af43971f25c594f0f95a976f8eeb4027c584b78 (diff)
parent0d635181f8d693c57b59d5144b997c0c8fe715ed (diff)
downloadzuul-fc4324e4a4d19f5d2c6ce669241faacb8a1b2294.tar.gz
Merge "Periodically maintain connection caches"
Diffstat (limited to 'zuul/driver')
-rw-r--r--zuul/driver/gerrit/gerritconnection.py10
-rw-r--r--zuul/driver/git/gitconnection.py7
-rw-r--r--zuul/driver/github/githubconnection.py7
-rw-r--r--zuul/driver/gitlab/gitlabconnection.py7
-rw-r--r--zuul/driver/pagure/pagureconnection.py7
5 files changed, 10 insertions, 28 deletions
diff --git a/zuul/driver/gerrit/gerritconnection.py b/zuul/driver/gerrit/gerritconnection.py
index 29a3eec79..ba7beb411 100644
--- a/zuul/driver/gerrit/gerritconnection.py
+++ b/zuul/driver/gerrit/gerritconnection.py
@@ -738,14 +738,8 @@ class GerritConnection(BaseConnection):
except KeyError:
pass
- def maintainCache(self, relevant):
- # This lets the user supply a list of change objects that are
- # still in use. Anything in our cache that isn't in the supplied
- # list should be safe to remove from the cache.
- for change in self._change_cache:
- if change not in relevant:
- self._change_cache.delete(change.cache_stat.key)
- # TODO: remove entries older than X
+ def maintainCache(self, relevant, max_age):
+ self._change_cache.prune(relevant, max_age)
self._change_cache.cleanup()
def updateChangeAttributes(self, change, **attrs):
diff --git a/zuul/driver/git/gitconnection.py b/zuul/driver/git/gitconnection.py
index 36b7242cd..61796a50b 100644
--- a/zuul/driver/git/gitconnection.py
+++ b/zuul/driver/git/gitconnection.py
@@ -103,11 +103,8 @@ class GitConnection(BaseConnection):
refs[ref] = sha
return refs
- def maintainCache(self, relevant):
- for change in self._change_cache:
- if change not in relevant:
- self._change_cache.delete(change.cache_stat.key)
- # TODO: remove entries older than X
+ def maintainCache(self, relevant, max_age):
+ self._change_cache.prune(relevant, max_age)
self._change_cache.cleanup()
def getChange(self, event, refresh=False):
diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py
index 9fd9c0a2e..f6a45732f 100644
--- a/zuul/driver/github/githubconnection.py
+++ b/zuul/driver/github/githubconnection.py
@@ -1262,11 +1262,8 @@ class GithubConnection(CachedBranchConnection):
return self._github_client_manager.getGithubClient(
project_name=project_name, zuul_event_id=zuul_event_id)
- def maintainCache(self, relevant):
- for change in self._change_cache:
- if change not in relevant:
- self._change_cache.delete(change.cache_stat.key)
- # TODO: remove entries older than X
+ def maintainCache(self, relevant, max_age):
+ self._change_cache.prune(relevant, max_age)
self._change_cache.cleanup()
def updateChangeAttributes(self, change, **attrs):
diff --git a/zuul/driver/gitlab/gitlabconnection.py b/zuul/driver/gitlab/gitlabconnection.py
index f26b19582..fed4eca21 100644
--- a/zuul/driver/gitlab/gitlabconnection.py
+++ b/zuul/driver/gitlab/gitlabconnection.py
@@ -459,11 +459,8 @@ class GitlabConnection(CachedBranchConnection):
if hasattr(self, 'gitlab_event_connector'):
self._stop_event_connector()
- def maintainCache(self, relevant):
- for change in self._change_cache:
- if change not in relevant:
- self._change_cache.delete(change.cache_stat.key)
- # TODO: remove entries older than X
+ def maintainCache(self, relevant, max_age):
+ self._change_cache.prune(relevant, max_age)
self._change_cache.cleanup()
def updateChangeAttributes(self, change, **attrs):
diff --git a/zuul/driver/pagure/pagureconnection.py b/zuul/driver/pagure/pagureconnection.py
index 084585d38..016ef82b8 100644
--- a/zuul/driver/pagure/pagureconnection.py
+++ b/zuul/driver/pagure/pagureconnection.py
@@ -545,11 +545,8 @@ class PagureConnection(BaseConnection):
"Fetching project %s webhook token from API" % project)
return token
- def maintainCache(self, relevant):
- for change in self._change_cache:
- if change not in relevant:
- self._change_cache.delete(change.cache_stat.key)
- # TODO: remove entries older than X
+ def maintainCache(self, relevant, max_age):
+ self._change_cache.prune(relevant, max_age)
self._change_cache.cleanup()
def updateChangeAttributes(self, change, **attrs):