asteris-llc/converge

Group / Switch Statement Interactions

Opened this issue · 0 comments

There are some subtle bugs in the interaction between groups and switch statements. This can possibly be addressed more cleanly now that the switch code has been refactored to store conditional information in the node metadata, but it's going to require some deep dives to deal with the interactions.

Example broken case:

param "p" {
  default = "1"
}

task.query "grp-a-a" {
  query = "echo a"
  group = "grp-a"
}

task.query "grp-b" {
  query = "echo b"
  group = "grp-b"
}

switch "foo" {
  case "{{eq `0` (param `p`)}}" "case-0" {
    task.query "case-0" {
      query = "echo 'case 0'"
    }

    task.query "case-0-group-a" {
      query = "echo 'case-0-group-a'"
      group = "grp-a"
    }

    task.query "case-0-group-b" {
      query = "echo 'case-0-group-b'"
      group = "grp-b"
    }

    task.query "case-0-group-a-dep-b" {
      query   = "echo 'case-0-group-a-dep-b'"
      group   = "grp-a"
      depends = ["task.query.case-0-group-b"]
    }

    task.query "case-0-deps-ab" {
      query   = "echo 'case-0-deps-ab'"
      depends = ["task.query.case-0-group-a", "task.query.case-0-group-b"]
    }
  }

  default {
    task.query "default" {
      query = "echo default"
    }

    task.query "default-group-a" {
      query = "echo 'default-group-a'"
      group = "grp-a"
    }

    task.query "default-group-b" {
      query = "echo 'default-group-b'"
      group = "grp-b"
    }

    task.query "default-group-a-dep-b" {
      query   = "echo 'default-group-a-dep-b'"
      group   = "grp-a"
      depends = ["task.query.default-group-b"]
    }

    task.query "case-0-deps-ab" {
      query   = "echo 'default-deps-ab'"
      depends = ["task.query.default-group-a", "task.query.default-group-b"]
    }
  }
}