diff options
author | Zuul <zuul@review.opendev.org> | 2023-03-02 12:14:50 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-03-02 12:14:50 +0000 |
commit | 36e81916f0b3b560ad672f2100daec25c56e3f94 (patch) | |
tree | fc0ed57f67965d644e0e7cfe518ad5f7b8e6cd8b /zuul | |
parent | 55c158c447d73e7dcc084d141e465dfb88515124 (diff) | |
parent | b1490b1d8e55ebca90533ccc55d8a6bef999197a (diff) | |
download | zuul-36e81916f0b3b560ad672f2100daec25c56e3f94.tar.gz |
Merge "Avoid layout updates after delete-pipeline-state"
Diffstat (limited to 'zuul')
-rwxr-xr-x | zuul/cmd/client.py | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/zuul/cmd/client.py b/zuul/cmd/client.py index 1a3738b85..62e51ac3f 100755 --- a/zuul/cmd/client.py +++ b/zuul/cmd/client.py @@ -30,16 +30,14 @@ import time import textwrap import requests import urllib.parse -from uuid import uuid4 import zuul.cmd from zuul.lib.config import get_default -from zuul.model import SystemAttributes, PipelineState +from zuul.model import SystemAttributes, PipelineState, PipelineChangeList from zuul.zk import ZooKeeperClient from zuul.lib.keystorage import KeyStorage -from zuul.zk.locks import tenant_write_lock +from zuul.zk.locks import tenant_read_lock, pipeline_lock from zuul.zk.zkobject import ZKContext -from zuul.zk.layout import LayoutState, LayoutStateStore from zuul.zk.components import COMPONENT_REGISTRY @@ -1029,27 +1027,18 @@ class Client(zuul.cmd.ZuulApp): safe_tenant = urllib.parse.quote_plus(args.tenant) safe_pipeline = urllib.parse.quote_plus(args.pipeline) COMPONENT_REGISTRY.create(zk_client) - with tenant_write_lock(zk_client, args.tenant) as lock: + self.log.info('get tenant') + with tenant_read_lock(zk_client, args.tenant): path = f'/zuul/tenant/{safe_tenant}/pipeline/{safe_pipeline}' - layout_uuid = None - zk_client.client.delete(path, recursive=True) - with ZKContext(zk_client, lock, None, self.log) as context: - ps = PipelineState.new(context, _path=path, - layout_uuid=layout_uuid) - ltime = ps._zstat.last_modified_transaction_id - # Force everyone to make a new layout for this tenant in - # order to rebuild the shared change queues. - layout_state = LayoutState( - tenant_name=args.tenant, - hostname='admin command', - last_reconfigured=int(time.time()), - last_reconfigure_event_ltime=ltime, - uuid=uuid4().hex, - branch_cache_min_ltimes={}, - ltime=ltime, - ) - tenant_layout_state = LayoutStateStore(zk_client, lambda: None) - tenant_layout_state[args.tenant] = layout_state + self.log.info('get pipe') + with pipeline_lock( + zk_client, args.tenant, args.pipeline + ) as plock: + self.log.info('got locks') + zk_client.client.delete(path, recursive=True) + with ZKContext(zk_client, plock, None, self.log) as context: + PipelineState.new(context, _path=path, layout_uuid=None) + PipelineChangeList.new(context) sys.exit(0) |