While checking that the controller is up, we don't care about
[arvados-formula.git] / arvados / controller / service / running.sls
index 3fca8f3060797d848e38852a41aa26b539b4e675..edd0476e839e59241b393390357a451b137a08b8 100644 (file)
@@ -18,3 +18,21 @@ arvados-controller-service-running-service-running:
       - sls: {{ sls_config_file }}
     - require:
       - pkg: arvados-controller-package-install-pkg-installed
       - sls: {{ sls_config_file }}
     - require:
       - pkg: arvados-controller-package-install-pkg-installed
+
+# Before being able to create resources, we need API to be up. When running the formula for
+# the first time, it might be still being configured, so we add this workaround, as suggested at
+# https://github.com/saltstack/salt/issues/19084#issuecomment-70317884
+arvados-controller-service-running-service-ready-cmd-run:
+  cmd.run:
+    - name: |
+        while ! (curl -k -s {{  arvados.cluster.Services.Controller.ExternalURL }} | \
+                 grep -qE "req-[a-z0-9]{20}.{5}error_token") do
+          echo 'waiting for API to be ready...'
+          sleep 1
+        done
+    - timeout: 120
+    - unless: |
+        curl -s {{  arvados.cluster.Services.Controller.ExternalURL }} | \
+        grep -qE "req-[a-z0-9]{20}.{5}error_token"
+    - require:
+      - service: arvados-controller-service-running-service-running