]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/orchestrator: stop passing "default_flow_style" flag to yaml dump
authorAdam King <adking@redhat.com>
Fri, 10 Oct 2025 14:48:35 +0000 (10:48 -0400)
committerAdam King <adking@redhat.com>
Fri, 10 Oct 2025 14:48:35 +0000 (10:48 -0400)
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 <adking@redhat.com>
src/pybind/mgr/orchestrator/module.py
src/python-common/ceph/deployment/service_spec.py

index ce8d2ec130d126f92976a0c511c9860339e10730..d6c21fd406c4c28653d9f1d0d9b5c871baed9422 100644 (file)
@@ -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')
index dd67aee4ff0a1bf87340baea2484275dd9f4407d..b2e5e08b6aa81b0fcafb778628688ac63548613c 100644 (file)
@@ -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: