Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Regression] yaml output broken in 3006.8 #66594

Open
2 tasks done
SaherH opened this issue May 26, 2024 · 3 comments
Open
2 tasks done

[BUG] [Regression] yaml output broken in 3006.8 #66594

SaherH opened this issue May 26, 2024 · 3 comments
Labels
Argon v3008.0 Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt Regression The issue is a bug that breaks functionality known to work in previous releases.

Comments

@SaherH
Copy link

SaherH commented May 26, 2024

Description
Yaml output is not working (e.g. when using show_sls --out=yaml), and it's returning NULL.

Setup

  • container (Docker)
  • onedir packaging

Steps to Reproduce the behavior
Create any SLS file, and run show_sls with --out=yaml

[root@0b379b6cb0ba /]# cat /srv/salt/test.sls
test:
  cmd.run:
    - name: echo hello
[root@0b379b6cb0ba /]# salt-call --local state.show_sls --out=yaml test
local: NULL

Expected behavior
Working output from 3006.7

[root@0b379b6cb0ba /]# salt-call --local state.show_sls --out=yaml test
local:
  test:
    cmd:
    - name: echo hello
    - run
    - order: 10000
    __sls__: test
    __env__: base

Versions Report

salt --versions-report
Salt Version:
          Salt: 3006.8
 
Python Version:
        Python: 3.10.14 (main, Apr  3 2024, 21:30:09) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.14.6
      cherrypy: 18.6.1
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.3
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.16.0
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: rocky 8.9 Green Obsidian
        locale: utf-8
       machine: x86_64
       release: 4.18.0-513.24.1.el8_9.x86_64
        system: Linux
       version: Rocky Linux 8.9 Green Obsidian

Additional context
Root cause is missing yaml dumper logic.
In b9be2de, OrderedDict was replaced with HashableOrderedDict. The former had custom yaml dumper logic defined that hasn't been applied to the latter.

OrderedDumper.add_representer(OrderedDict, represent_ordereddict)
SafeOrderedDumper.add_representer(OrderedDict, represent_ordereddict)

@SaherH SaherH added Bug broken, incorrect, or confusing behavior needs-triage labels May 26, 2024
@twangboy twangboy added Argon v3008.0 Core relates to code central or existential to Salt and removed needs-triage labels May 29, 2024
@twangboy twangboy added this to the Argon v3008.0 milestone May 29, 2024
@twangboy twangboy added the Regression The issue is a bug that breaks functionality known to work in previous releases. label May 29, 2024
@achalupa-ptc
Copy link

I'm also facing this problem and it's a killer because we can't render runnable code w/ this broken. makes it very difficult to resume an orchestration.

@doesitblend
Copy link
Contributor

@achalupa-ptc @SaherH As a quick workaround for this issue you can pipe the output from JSON to a simple Python script to convert the data to YAML.

# salt-run state.orch_show_sls testing.orch --output=json | ./converter.py 

https://gist.github.com/doesitblend/6e63caf909235c4875bbf38b172b382f

@achalupa-ptc
Copy link

@doesitblend : thanks for the workaround it works but unfortunately it's not enough to reduce the pain for my use case. I'm typically rendering an orchestration or state using --out=yaml to resume an orchestration from where it failed. With the workaround it accurately renders the code as yaml but it does so in a random order. It's very time consuming to pick through the randomly ordered code to pick out the steps that haven't run yet.

First salt broke the ability to pass test=true -l debug as a way of rendering code. using --out=yaml was the workaround for this breakage and now this is broken :(.

@dwoz dwoz modified the milestones: Argon v3008.0, Sulfur v3006.9 Jun 11, 2024
gediminasz added a commit to gediminasz/slskit that referenced this issue Jun 29, 2024
Workaround for broken yaml output (saltstack/salt#66594)

from salt.state import HashableOrderedDict
from salt.utils.yamldumper import SafeOrderedDumper, represent_ordereddict

SafeOrderedDumper.add_representer(HashableOrderedDict, represent_ordereddict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Argon v3008.0 Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt Regression The issue is a bug that breaks functionality known to work in previous releases.
Projects
None yet
Development

No branches or pull requests

5 participants