diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 2e90d3fb41..30e3049c89 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -444,10 +444,14 @@ class TestOnlineZKOperations(ZuulTestCase): # Delete the pipeline state out, _ = p.communicate() self.log.debug(out.decode('utf8')) + self.assertEqual(p.returncode, 0, 'The command must exit 0') # Make sure it's deleted with testtools.ExpectedException(NoNodeError): self.getZKTree( f'/zuul/tenant/{tenant.name}/pipeline/{pipeline}/item') + # Make sure the change list is re-created + self.getZKTree( + f'/zuul/tenant/{tenant.name}/pipeline/{pipeline}/change_list') finally: sched.run_handler_lock.release() diff --git a/zuul/cmd/client.py b/zuul/cmd/client.py index 6fa20c7c4a..bb35cfb35c 100755 --- a/zuul/cmd/client.py +++ b/zuul/cmd/client.py @@ -33,7 +33,9 @@ import urllib.parse import zuul.cmd from zuul.lib.config import get_default -from zuul.model import SystemAttributes, PipelineState, PipelineChangeList +from zuul.model import ( + SystemAttributes, Pipeline, PipelineState, PipelineChangeList +) from zuul.zk import ZooKeeperClient from zuul.lib.keystorage import KeyStorage from zuul.zk.locks import tenant_read_lock, pipeline_lock @@ -1035,14 +1037,16 @@ class Client(zuul.cmd.ZuulApp): with tenant_read_lock(zk_client, args.tenant): path = f'/zuul/tenant/{safe_tenant}/pipeline/{safe_pipeline}' self.log.info('get pipe') + pipeline = Pipeline(args.tenant, args.pipeline) 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) + pipeline.state = PipelineState.new( + context, _path=path, layout_uuid=None) + PipelineChangeList.new(context, pipeline=pipeline) sys.exit(0)