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

Playbook: Conditional action fails when special function success() tested with parameter value #1267

Open
junaid-ebrahim opened this issue Aug 14, 2024 · 0 comments
Labels
bug Something isn't working playbook
Milestone

Comments

@junaid-ebrahim
Copy link

When trying to conditionally run an action that depends on the success of previous actions plus a parameter value we get an error. See example below on second action in playbook , note the "success()" function that causes the failure.

apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
  name: grant-mssql-user-db-access
spec:
  description: Grant an MSSQL user read or readwrite access to a database
  parameters:
    - name: delay
      label: Expires after
      type: list
      properties:
        options:
          - label: "1 minute"
            value: '1m'
          - label: "Indefinitely"
            value: "0"
  actions:
    - name: Assign Database User Roles
      if: "always()"
      sql:
        connection: connection://default/mssql-db
        driver: mssql
        query: |
          <sql here>

    - name: Clear Rolebinding Broken
      if: success() && params.delay != "0"
      delay: '.params.delay'
      sql:
        connection: connection://default/mssql-db
        driver: mssql
        query: |
          <sql here>

The workaround is to use the "getAction()" function instead of "success()"

    - name: Clear Rolebinding Fixed
      if: getAction('Assign Database User Roles').status != 'failed' && params.delay != "0"
      delay: '.params.delay'
      sql:
        connection: connection://default/mssql-db
        driver: mssql
        query: |
          <sql here>
@moshloop moshloop added the bug Something isn't working label Aug 15, 2024
@moshloop moshloop added this to the v1.0.0 milestone Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working playbook
Projects
None yet
Development

No branches or pull requests

2 participants