Skip to content

fix(cloud-init): disable PyYAML line wrapping in scripts#13696

Open
soyacz wants to merge 1 commit intoscylladb:masterfrom
soyacz:sct-62-fix-cloud-init-failure-azure
Open

fix(cloud-init): disable PyYAML line wrapping in scripts#13696
soyacz wants to merge 1 commit intoscylladb:masterfrom
soyacz:sct-62-fix-cloud-init-failure-azure

Conversation

@soyacz
Copy link
Contributor

@soyacz soyacz commented Feb 19, 2026

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

Testing

PR pre-checks (self review)

  • I added the relevant backport labels
  • I didn't leave commented-out/debugging code

Reminders

  • Add New configuration option and document them (in sdcm/sct_config.py)
  • Add unit tests to cover my changes (under unit-test/ folder)
  • Update the Readme/doc folder relevant to this change (if needed)

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
@soyacz soyacz requested review from a team and timtimb0t February 19, 2026 16:44
@soyacz
Copy link
Contributor Author

soyacz commented Feb 19, 2026

@dimakr this one could also mess with Vector installation on Azure

| self.yum_repos
| self.apt_configuration
| self.apt_configuration,
width=10000, # prevent YAML from breaking long lines with newlines
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments