saltstack / saltstack/salt

Need to normalize salt-api responses

Open
#37,043 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

RIoT Salt-API severity-low
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Salt-api is very useful, but also in need of response normalization. This issue is partially tracked through a few different issues, and it would be helpful to keep progress in a single place. See: #20301 #18510 jenkinsci/saltstack-plugin#18 jenkinsci/saltstack-plugin#36

Here are some short examples demonstrating the problems:

Most state responses include a result key which contains the appropriate success status. So far so good

[{
  "outputter": "highstate",
  "data": {"pws-3.dev.mpl.ru":   {
    "file_|-/some/file":     {
      "comment": "No directory to create /some/file in",
      "name": "/other/file",
      "start_time": "16:21:10.068787",
      "result": false,
      "duration": "0.947 ms",
      "__run_num__": 6,
      "changes": {}
    }
  }}
}]

Other times the API does not include the necessary info at all:
CLI

# salt 'web1' cmd.run 'false 1'
web1:
ERROR: Minions returned with non-zero exit code

API

{
    "return": [
        {
            "web1": ""
        }
    ]
}

This same issue occurs with the service execution module. Here is an example of a service failing to restart:

{
    "info": [
        {
            "Arguments": [
                "klsdklsd"
            ],
            "Function": "service.restart",
            "Minions": [
                "web1"
            ],
            "Result": {
                "web1": {
                    "return": false
                }
            },
            "StartTime": "2016, May 27 14:08:28.970138",
            "Target": "web1",
            "Target-type": "glob",
            "User": "jenkins",
            "jid": "20160527140828970138"
        }
    ],
    "return": [
        {
            "web1": false
        }
    ]
}

And some errors are in different structures

[{
  "outputter": "highstate",
  "data": {"minion-name": ["Rendering SLS 'base:hostname' failed: mapping values are not allowed here; line 40..."]}
}]

Or

[{"infra01": "ERROR executing 'pillar.get': The following keyword arguments are not valid: output=raw"}]

The problem isn't just errors either. Commands like the manage.present runner respond with successful, but again completely different output, making parsing difficult.

[["minion1","minion2","salt"]]

Overall, the responses generated by salt-api are somewhat all over the board making for constant edge cases increasing complexity.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the response examples in this issue and review linked issues #20301, #18510, jenkinsci/saltstack-plugin#18, and jenkinsci/saltstack-plugin#36 to identify overlapping requirements. Trace the salt-api paths for highstate, cmd.run, service.restart, errors, and manage.present, then define and test a consistent response contract covering success, failure, and error cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.