From: Adam King Date: Fri, 10 Oct 2025 14:48:35 +0000 (-0400) Subject: mgr/orchestrator: stop passing "default_flow_style" flag to yaml dump X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ea16f50da9d30b97d5b5228f903667c34862d488;p=ceph-ci.git mgr/orchestrator: stop passing "default_flow_style" flag to yaml dump This seems to not be compatible with pyyaml 6.0 ``` File "/lib/python3.12/site-packages/ceph/deployment/service_spec.py", line 1350, in __repr__ y = yaml.dump(cast(dict, self), default_flow_style=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib64/python3.12/site-packages/yaml/__init__.py", line 253, in dump return dump_all([data], stream, Dumper=Dumper, **kwds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib64/python3.12/site-packages/yaml/__init__.py", line 241, in dump_all dumper.represent(data) File "/lib64/python3.12/site-packages/yaml/representer.py", line 28, in represent self.serialize(node) File "/lib64/python3.12/site-packages/yaml/serializer.py", line 54, in serialize self.serialize_node(node, None, None) File "/lib64/python3.12/site-packages/yaml/serializer.py", line 104, in serialize_node self.emit(MappingStartEvent(alias, node.tag, implicit, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Prepared.__init__() got an unexpected keyword argument 'flow_style' ``` and didn't seem to cause any issues with making our specs look readable in the logs or being able to round-trip specs when using `ceph orch ls --export` (minus the known bug around doing so with multi-line certs) Resolves: rhbz#2402684 Signed-off-by: Adam King --- diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index ce8d2ec130d..d6c21fd406c 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -259,8 +259,8 @@ def to_format(what: Any, format: Format, many: bool, cls: Any) -> Any: to_yaml = to_yaml_n if many else to_yaml_1 if many: - return yaml.dump_all(to_yaml(copy), default_flow_style=False) - return yaml.dump(to_yaml(copy), default_flow_style=False) + return yaml.dump_all(to_yaml(copy)) + return yaml.dump(to_yaml(copy)) elif format == Format.xml or format == Format.xml_pretty: raise OrchestratorError(f"format '{format.name}' is not implemented.") else: @@ -1195,7 +1195,7 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule, if format != Format.plain: return HandleCommandResult(stdout=to_format(bindings_ls, format, many=False, cls=None)) else: - result_str = yaml.dump(bindings_ls, default_flow_style=False, sort_keys=False) + result_str = yaml.dump(bindings_ls, sort_keys=False) return HandleCommandResult(stdout=result_str) @_cli_read_command('orch certmgr cert check') diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index dd67aee4ff0..b2e5e08b6aa 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -1347,7 +1347,7 @@ class ServiceSpec(object): ) def __repr__(self) -> str: - y = yaml.dump(cast(dict, self), default_flow_style=False) + y = yaml.dump(cast(dict, self)) return f"{self.__class__.__name__}.from_json(yaml.safe_load('''{y}'''))" def __eq__(self, other: Any) -> bool: