fix(arvados-controller): add a loop to verify the service is ready
authorJavier Bértoli <javier@netmanagers.com.ar>
Fri, 14 May 2021 21:58:58 +0000 (18:58 -0300)
committerJavier Bértoli <javier@netmanagers.com.ar>
Fri, 14 May 2021 21:58:58 +0000 (18:58 -0300)
It's not enough to have the service up, but it needs to be responding correctly.

arvados/controller/service/running.sls

index 3fca8f3060797d848e38852a41aa26b539b4e675..6c95b3c9f1e17928242164d1412c1e5782332065 100644 (file)
@@ -18,3 +18,21 @@ arvados-controller-service-running-service-running:
       - 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 -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: 520
+    - 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