StackStorm / StackStorm/st2

Orquesta Error Message confusing when task name is missing

Open
#4,764 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement workflows: orquesta
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

SUMMARY

During the process of converting the backups pack from Mistral -> Orquesta i ran into a self-induced error that produced a confusing error message.

STACKSTORM VERSION
$ st2 --version
st2 3.1.0, on Python 2.7.5
OS, environment, install method
$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.6 (Maipo)

# Install = Puppet-st2

Steps to reproduce the problem

/opt/stackstorm/backups/actions/mongodb_backup.yaml

---
description: Performs a back of StackStorm MongoDB database
enabled: true
runner_type: orquesta
entry_point: workflows/mongodb_backup.yaml
name: mongodb_backup
pack: backups
parameters:
  path:
    default: /opt/stackstorm/backups
    type: string
  date:
    type: string
  mongodb_admin_username:
    default: "{{ st2kv.system.mongodb.admin_username }}"
    type: string
  mongodb_admin_password:
    default: "{% set pw = st2kv.system.mongodb.admin_password | string %}{{ pw | decrypt_kv if pw else '' }}"
    type: string
    secret: true
  retention_days:
    type: string
    description: "Passed into the find command. Deletes files based on this value. To find files older than n days it should be +n . If you specify just n it will find files that are exactly n days old."
    default: "{{ st2kv.system.backup.retention_days | string | default('+14', true) }}"

/opt/stackstorm/backups/actions/workflows/mongodb_backup.yaml

---
version: '1.0'
description: Workflow that backs up the StackStorm MongoDB database
input:
  - path
  - date
  - mongodb_admin_username
  - mongodb_admin_password: "{{ st2kv('system.mongodb.admin_password', decrypt=True) }}"
  - retention_days

output:
  - mongodb_dump_archive: '{{ ctx().mongodb_dump_archive }}'

tasks:
  main:
    action: core.noop
    next:
      - when: '{{ succeeded() and (ctx().date) }}'
        do:
          - init
      - when: '{{ succeeded() and (not ctx().date) }}'
        do:
          - date

  date:
    action: core.local
    input:
      cmd: "date +%Y%m%d_%H%M%S"
    next:
      - when: '{{ succeeded() }}'
        publish:
          - date: '{{ result().stdout }}'
        do:
          - init

  init:
    action: core.noop
    next:
      - when: '{{ succeeded() }}'
        publish:
          - mongodb_dump_archive: '{{ ctx().path }}/mongodb_dump_{{ ctx().date }}.gzip.archive'
        do:
          - mkdir_path

  mkdir_path:
    action: core.local_sudo
    input:
      cmd: "mkdir -p '{{ ctx().path }}'"
    next:
      - when: '{{ succeeded() and (not ctx().mongodb_admin_username or not ctx().mongodb_admin_password) }}'
        do:
          - mongodb_backup
      - when: '{{ succeeded() and (ctx().mongodb_admin_username and ctx().mongodb_admin_password) }}'
        do:
          - mongodb_backup_with_auth

  mongodb_backup:
    action: core.local_sudo
    input:
      cwd: '{{ ctx().path }}'
      cmd: "mongodump --gzip --archive='{{ ctx().mongodb_dump_archive }}'"
    next:
      - when: '{{ succeeded() }}'
        do:
          - mongodb_compress

  mongodb_backup_with_auth:
    action: core.local_sudo
    input:
      cwd: '{{ ctx().path }}'
      cmd: "mongodump -u '{{ ctx().mongodb_admin_username }}' -p '{{ ctx().mongodb_admin_password }}' --gzip --archive='{{ ctx().mongodb_dump_dirname }}'"
    next:
      - when: '{{ succeeded() }}'
        do:
          - mongodb_delete_old_files

  mongodb_delete_old_files:
    action: core.local_sudo
    input:
      cwd: '{{ ctx().path }}'
      cmd: "find . -name 'mongodb_dump_*' -mtime {{ ctx().retention_days }} | xargs --no-run-if-empty rm"

Notice in the mongodb_backup step i'm referencing mongodb_compress and that task doesn't exist.

st2 run backups.mongodb_backup

Expected Results

An error message about how the transition at point XXX is referencing a task that doesn't exist.

Actual Results

# st2 execution re-run 5d5158f0415b860708c26829
.
id: 5d51598e415b860c4bd5c338
action.ref: backups.mongodb_backup
parameters: 
  date: '20190812_081751'
  mongodb_admin_password: '********'
  mongodb_admin_username: admin
  path: /opt/stackstorm/backups
  retention_days: '+14'
status: failed
start_timestamp: Mon, 12 Aug 2019 12:20:30 UTC
end_timestamp: Mon, 12 Aug 2019 12:20:30 UTC
result: 
  errors:
  - message: '''mongodb_compress'''
  output: null

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

Reproduce the failure with the workflow in /opt/stackstorm/backups/actions/workflows/mongodb_backup.yaml and the st2 run backups.mongodb_backup command. Trace how the missing mongodb_compress transition is reported; done means the error identifies the invalid transition and referenced task clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.