While checking that the controller is up, we don't care about
[arvados-formula.git] / arvados / controller / service / running.sls
1 # -*- coding: utf-8 -*-
2 # vim: ft=sls
3
4 {#- Get the `tplroot` from `tpldir` #}
5 {%- set tplroot = tpldir.split('/')[0] %}
6 {%- set sls_config_file = tplroot ~ '.config.file' %}
7 {%- from tplroot ~ "/map.jinja" import arvados with context %}
8
9 include:
10   - ..package
11   - {{ sls_config_file }}
12
13 arvados-controller-service-running-service-running:
14   service.running:
15     - name: {{ arvados.controller.service.name }}
16     - enable: True
17     - watch:
18       - sls: {{ sls_config_file }}
19     - require:
20       - pkg: arvados-controller-package-install-pkg-installed
21
22 # Before being able to create resources, we need API to be up. When running the formula for
23 # the first time, it might be still being configured, so we add this workaround, as suggested at
24 # https://github.com/saltstack/salt/issues/19084#issuecomment-70317884
25 arvados-controller-service-running-service-ready-cmd-run:
26   cmd.run:
27     - name: |
28         while ! (curl -k -s {{  arvados.cluster.Services.Controller.ExternalURL }} | \
29                  grep -qE "req-[a-z0-9]{20}.{5}error_token") do
30           echo 'waiting for API to be ready...'
31           sleep 1
32         done
33     - timeout: 120
34     - unless: |
35         curl -s {{  arvados.cluster.Services.Controller.ExternalURL }} | \
36         grep -qE "req-[a-z0-9]{20}.{5}error_token"
37     - require:
38       - service: arvados-controller-service-running-service-running