fix(cloud-init): disable PyYAML line wrapping in scripts#13696
Open
soyacz wants to merge 1 commit intoscylladb:masterfrom
Open
fix(cloud-init): disable PyYAML line wrapping in scripts#13696soyacz wants to merge 1 commit intoscylladb:masterfrom
soyacz wants to merge 1 commit intoscylladb:masterfrom
Conversation
Long bash commands in write_files were being split by PyYAML's default 80-character limit, causing script execution failures on Azure VMs. Applied `width=10000` and `default_flow_style=False`. fixes: https://scylladb.atlassian.net/browse/SCT-62
Contributor
Author
|
@dimakr this one could also mess with Vector installation on Azure |
fruch
reviewed
Feb 19, 2026
| | self.yum_repos | ||
| | self.apt_configuration | ||
| | self.apt_configuration, | ||
| width=10000, # prevent YAML from breaking long lines with newlines |
Contributor
There was a problem hiding this comment.
seems like ruamel can convert to Literal Operator a bit better
from ruamel.yaml.scalarstring import walk_tree
data = { ... large nested dict ... }
# This utility finds all multi-line strings and wraps them for you
walk_tree(data)
yaml.dump(data, sys.stdout)while in pyyaml is global and ugly:
import yaml
def force_literal_dump(data):
# Define a representer that forces '|' for any string with a newline
yaml.SafeDumper.org_represent_str = yaml.SafeDumper.represent_str
def repr_str(dumper, data):
if '\n' in data:
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
return dumper.represent_scalar('tag:yaml.org,2002:str', data)
yaml.add_representer(str, repr_str)
output = yaml.dump(data)
# It's good practice to reset the representer back to default afterwards
yaml.add_representer(str, yaml.SafeDumper.org_represent_str)
return output
but that sound like a better way then width=10000
I think going forward we should consider ruamel for anything yaml...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Long bash commands in write_files were being split by PyYAML's default 80-character limit, causing script execution failures on Azure VMs. Applied
width=10000anddefault_flow_style=False.fixes: https://scylladb.atlassian.net/browse/SCT-62
Testing
PR pre-checks (self review)
backportlabelsReminders
sdcm/sct_config.py)unit-test/folder)