Skip to content

[FEATURE REQUEST] Orchestration job metadata #62683

@max-arnold

Description

@max-arnold

Is your feature request related to a problem? Please describe.

For reporting/observability purposes it would be very useful to add custom metadata (key/value pairs) to Salt jobs. This metadata should be propagated back to job returns (be visible on the event bus) and could be used to track and filter particular job types using this metadata.

Turns out, this feature already exists in Salt:

Unfortunately, salt-run doesn't have an ability to add metadata and it is not possible to pass metadata from an orchestration job to any child jobs that generate new JIDs and produce separate returns

Describe the solution you'd like

My suggestion is to add the job metadata to runner jobs to achieve feature parity with other job types (salt, salt-call, scheduled):

  1. Add a new CLI arg to salt-run: either named --metadata (used by salt) or --set-metadata (used by salt-call, because --metadata does another thing, see Add --set-metadata option to salt-call #37362
  2. Automatically inherit this metadata by orchestration sub-jobs that generate new JIDs and produce separate return events (salt.function, salt.state, salt.runner, salt.parallel_runners, salt.wheel, including nested orchestrations).
  3. Optionally, allow adding/extending job metadata for orchestration sub-jobs explicitly (in addition to inherited metadata), e.g.:
# orch/myorch.sls
Sleep:
  salt.function:
    - name: test.sleep
    - metadata:
        baz: qux
    - tgt: "*"
    - arg:
      - 1
salt-run state.orch orch.myorch --metadata '{foo: bar}'

The return event from the Sleep sub-job should have {foo: bar, baz: qux} metadata, the return from the orch itself just {foo: bar}

I believe this ability to add cross-cutting job metadata will significantly improve job traceability for complex orchestrations that spawn new sub-jobs.

Describe alternatives you've considered
An alternative is to add a parent job ID to every sub-job spawned by the orchestration. It is less flexible though because it is a single field and doesn't allow adding arbitrary attributes.

P.S. check whether it is possible to supply metadata via salt-api.
P.P.S. maybe also worth passing it down to jinja context for a complete pass-through observability

Metadata

Metadata

Assignees

No one assigned

    Labels

    Featurenew functionality including changes to functionality and code refactors, etc.Runnersneeds-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions