zuul/zuul/zk/cleanup.py
Simon Westphahl 9cbcf56e14 Clean up dangling cache data nodes more often
We need to periodically remove change data nodes that are not referenced
by any cache entry. This needs to happen more often than the periodic
cache maintenance (every 5min vs. every hour).

For this we need to introduce a new method `cleanupCache()` in the
connection interface.

In each run of the change cache's cleanup method we will identify
candidates of dangling data nodes to be cleaned up on the next run. The
reason for this delayed cleanup is that we don't want to remove data
nodes where a driver is in the process of creating/updating a new cache
entry.

Change-Id: I9abf7ac6fa117fe4a093ae7a0db1df0da5ae3ff3
2021-09-17 15:51:24 -07:00

58 lines
1.6 KiB
Python

# Copyright 2021 Acme Gating, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import kazoo.recipe.lock
class SemaphoreCleanupLock(kazoo.recipe.lock.Lock):
_path = '/zuul/cleanup/sempahores'
def __init__(self, client):
super().__init__(client.client, self._path)
class BuildRequestCleanupLock(kazoo.recipe.lock.Lock):
_path = '/zuul/cleanup/build_requests'
def __init__(self, client):
super().__init__(client.client, self._path)
class MergeRequestCleanupLock(kazoo.recipe.lock.Lock):
_path = '/zuul/cleanup/merge_requests'
def __init__(self, client):
super().__init__(client.client, self._path)
class ConnectionCleanupLock(kazoo.recipe.lock.Lock):
_path = '/zuul/cleanup/connection'
def __init__(self, client):
super().__init__(client.client, self._path)
class GeneralCleanupLock(kazoo.recipe.lock.Lock):
_path = '/zuul/cleanup/general'
def __init__(self, client):
super().__init__(client.client, self._path)
class NodeRequestCleanupLock(kazoo.recipe.lock.Lock):
_path = '/zuul/cleanup/node_request'
def __init__(self, client):
super().__init__(client.client, self._path)