Ming Hsieh
Ming Hsieh

Reputation: 803

How to do any or two successful minion return in Saltstack orch state?

I tried to write some orchestration state for converting HBase to high available mode. To do so, there are couple requirements for checking:

  1. Datanode process has to be up and running on ALL nodes.
  2. HRegion process has to be up and running on ALL nodes.
  3. After converting, namenode process has to be up and running on two nodes only.

So I got ALL implicitly for free, e.g.

{# If all minions passed, then this will pass #}
2_1_example_pod_is_dn_running:
  salt.function:
    - name: cmd.run
    - tgt: 'G@stype:hbase and G@pod_name:example_pod'
    - tgt_type: compound
    - arg:
      - ps aux | grep datanode
    - failhard: True

But how to check any or two?

{# Pseduo code. This won't work. #}
2_3_example_pod_is_nn_running:
    - name: cmd.run
    - tgt: 'G@stype:hbase and G@pod_name:example_pod'
    - tgt_type: compound
    - arg:
      - ps aux | grep namenode
    - successful_count: 2   {# <== namenode process has to be running on two minions #}
    - failhard: True

Upvotes: 0

Views: 93

Answers (1)

whytewolf
whytewolf

Reputation: 704

So, what you want for this is to know which minions should "fail" the check. if you know you can use fail_minions to mark the minions that will not have namenode.

For things like this it is almost always to either be specific. when setting it up so you know how which minions will have namenode. or, to skip the check an use subset to only start namenode on 2 servers. subset will pick the number of servers of a subset of the targeted minions randomly and run the command on only the subset.

Upvotes: 1

Related Questions