18663: add keep-balance app management
authorJavier Bértoli <jbertoli@curii.com>
Wed, 9 Mar 2022 18:22:53 +0000 (15:22 -0300)
committerJavier Bértoli <jbertoli@curii.com>
Wed, 9 Mar 2022 18:22:53 +0000 (15:22 -0300)
Arvados-DCO-1.1-Signed-off-by: Javier Bértoli <jbertoli@curii.com>

16 files changed:
arvados/defaults.yaml
arvados/files/default/config.tmpl.jinja
arvados/keepbalance/clean.sls [new file with mode: 0644]
arvados/keepbalance/init.sls [new file with mode: 0644]
arvados/keepbalance/package/clean.sls [new file with mode: 0644]
arvados/keepbalance/package/init.sls [new file with mode: 0644]
arvados/keepbalance/package/install.sls [new file with mode: 0644]
arvados/keepbalance/service/clean.sls [new file with mode: 0644]
arvados/keepbalance/service/init.sls [new file with mode: 0644]
arvados/keepbalance/service/running.sls [new file with mode: 0644]
kitchen.yml
test/integration/keepbalance/README.md [new file with mode: 0644]
test/integration/keepbalance/controls/config_spec.rb [new file with mode: 0644]
test/integration/keepbalance/controls/packages_spec.rb [new file with mode: 0644]
test/integration/keepbalance/controls/services_spec.rb [new file with mode: 0644]
test/integration/keepbalance/inspec.yml [new file with mode: 0644]

index 6f44cbb0a346358486a94c8c233b1e7b67b5d7e2..4ac246852a6da3779e5dda5db084570879ea5414 100644 (file)
@@ -101,6 +101,13 @@ arvados:
     service:
       name: keepproxy
       port: 25100
+  ##### KEEPBALANCE
+  keepbalance:
+    pkg:
+      name: keep-balance
+    service:
+      name: keep-balance
+      port: 9005
   ##### KEEPWEB
   keepweb:
     pkg:
index 017c6722a6fb61ad7a95a039d5034b17ba7f1c6a..668fe1c7d2783a3d03b5a975ab74c479ea1c2399 100644 (file)
@@ -29,6 +29,9 @@ Clusters:
     {%- if 'Collections' in arvados.cluster %}
       {{ arvados.cluster.Collections | yaml(False) | indent(6) }}
     {%- endif %}
+    {%- if 'Keepbalance' in arvados.cluster.Services %}
+      BlobTrash: true
+    {%- endif %}
 
     TLS:
       Certificate: {{ arvados.cluster.tls.certificate | yaml_encode }}
diff --git a/arvados/keepbalance/clean.sls b/arvados/keepbalance/clean.sls
new file mode 100644 (file)
index 0000000..c176be2
--- /dev/null
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# vim: ft=sls
+
+include:
+  - .service.clean
+  - .package.clean
diff --git a/arvados/keepbalance/init.sls b/arvados/keepbalance/init.sls
new file mode 100644 (file)
index 0000000..02a98b8
--- /dev/null
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# vim: ft=sls
+
+include:
+  - .package
+  - ..config
+  - .service
diff --git a/arvados/keepbalance/package/clean.sls b/arvados/keepbalance/package/clean.sls
new file mode 100644 (file)
index 0000000..18f86d0
--- /dev/null
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# vim: ft=sls
+
+{#- Get the `tplroot` from `tpldir` #}
+{%- set tplroot = tpldir.split('/')[0] %}
+{%- from tplroot ~ "/map.jinja" import arvados with context %}
+
+arvados-keepbalance-package-clean-pkg-removed:
+  pkg.removed:
+    - name: {{ arvados.keepbalance.pkg.name }}
diff --git a/arvados/keepbalance/package/init.sls b/arvados/keepbalance/package/init.sls
new file mode 100644 (file)
index 0000000..d3e5518
--- /dev/null
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# vim: ft=sls
+
+include:
+  - .install
diff --git a/arvados/keepbalance/package/install.sls b/arvados/keepbalance/package/install.sls
new file mode 100644 (file)
index 0000000..545d0dc
--- /dev/null
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+# vim: ft=sls
+
+{#- Get the `tplroot` from `tpldir` #}
+{%- set tplroot = tpldir.split('/')[0] %}
+{%- from tplroot ~ "/map.jinja" import arvados with context %}
+
+arvados-keepbalance-package-install-pkg-installed:
+  pkg.installed:
+    - name: {{ arvados.keepbalance.pkg.name }}
+    - version: {{ arvados.version }}
+    - refresh: true
diff --git a/arvados/keepbalance/service/clean.sls b/arvados/keepbalance/service/clean.sls
new file mode 100644 (file)
index 0000000..4b05135
--- /dev/null
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+# vim: ft=sls
+
+{#- Get the `tplroot` from `tpldir` #}
+{%- set tplroot = tpldir.split('/')[0] %}
+{%- from tplroot ~ "/map.jinja" import arvados with context %}
+
+arvados-keepbalance-service-clean-service-dead:
+  service.dead:
+    - name: {{ arvados.service.name }}
+    - enable: False
+    - require_in:
+      - pkg: arvados-keepbalance-package-clean-pkg-removed
diff --git a/arvados/keepbalance/service/init.sls b/arvados/keepbalance/service/init.sls
new file mode 100644 (file)
index 0000000..6fe4d1a
--- /dev/null
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# vim: ft=sls
+
+include:
+  - .running
diff --git a/arvados/keepbalance/service/running.sls b/arvados/keepbalance/service/running.sls
new file mode 100644 (file)
index 0000000..70c9fba
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# vim: ft=sls
+
+{#- Get the `tplroot` from `tpldir` #}
+{%- set tplroot = tpldir.split('/')[0] %}
+{%- set sls_config_file = tplroot ~ '.config.file' %}
+{%- from tplroot ~ "/map.jinja" import arvados with context %}
+
+include:
+  - ..package
+  - {{ sls_config_file }}
+
+arvados-keepbalance-service-running-service-running:
+  service.running:
+    - name: {{ arvados.keepbalance.service.name }}
+    - enable: True
+    - watch:
+      - sls: {{ sls_config_file }}
+    - require:
+      - pkg: arvados-keepbalance-package-install-pkg-installed
index 443e2199ab2637ce6b26461f8a5650d237070800..e7f200bb2b5f85281f233682bc1728a3dd420c66 100644 (file)
@@ -147,6 +147,7 @@ suites:
             - arvados.keepweb
             - arvados.controller
             - arvados.dispatcher
+            - arvados.keepbalance
       pillars:
         top.sls:
           base:
@@ -181,6 +182,7 @@ suites:
         - path: test/integration/keepproxy
         - path: test/integration/keepweb
         - path: test/integration/controller
+        - path: test/integration/keepbalance
   #### workbench,workbench2,webshell
   - name: workbench
     driver:
diff --git a/test/integration/keepbalance/README.md b/test/integration/keepbalance/README.md
new file mode 100644 (file)
index 0000000..15b911d
--- /dev/null
@@ -0,0 +1,50 @@
+# InSpec Profile: `keepbalance`
+
+This shows the implementation of the `keepbalance` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
+
+## Verify a profile
+
+InSpec ships with built-in features to verify a profile structure.
+
+```bash
+$ inspec check keepbalance
+Summary
+-------
+Location: keepbalance
+Profile: profile
+Controls: 4
+Timestamp: 2019-06-24T23:09:01+00:00
+Valid: true
+
+Errors
+------
+
+Warnings
+--------
+```
+
+## Execute a profile
+
+To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.
+
+```bash
+$ inspec exec keepbalance
+..
+
+Finished in 0.0025 seconds (files took 0.12449 seconds to load)
+8 examples, 0 failures
+```
+
+## Execute a specific control from a profile
+
+To run one control from the profile use `inspec exec /path/to/profile --controls name`.
+
+```bash
+$ inspec exec keepbalance --controls package
+.
+
+Finished in 0.0025 seconds (files took 0.12449 seconds to load)
+1 examples, 0 failures
+```
+
+See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).
diff --git a/test/integration/keepbalance/controls/config_spec.rb b/test/integration/keepbalance/controls/config_spec.rb
new file mode 100644 (file)
index 0000000..73b6da9
--- /dev/null
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+keepbalance_stanza = <<-KEEPBALANCE_STANZA
+      Keepbalance:
+        InternalURLs:
+          http://fixme.example.net:9005: {}
+KEEPBALANCE_STANZA
+
+collections_stanza = <<-COLLECTIONS_STANZA
+    Collections:
+      BlobSigningKey: "blobsigningkeymushaveatleast32characters"
+      BlobTrash: true
+COLLECTIONS_STANZA
+
+group = case os[:name]
+        when 'centos'
+          'nginx'
+        when 'debian', 'ubuntu'
+          'www-data'
+        end
+
+control 'arvados configuration' do
+  title 'should match desired keepbalance lines'
+
+  describe file('/etc/arvados/config.yml') do
+    it { should be_file }
+    it { should be_owned_by 'root' }
+    # We're testing it in the API instance, so group will be nginx's
+    it { should be_grouped_into group }
+    its('mode') { should cmp '0640' }
+    its('content') do
+      should include(
+        'File managed by Salt at <salt://arvados/files/default/config.tmpl.jinja>.'
+      )
+    end
+    its('content') { should include(keepbalance_stanza) }
+    its('content') { should include(collections_stanza) }
+  end
+end
diff --git a/test/integration/keepbalance/controls/packages_spec.rb b/test/integration/keepbalance/controls/packages_spec.rb
new file mode 100644 (file)
index 0000000..0ce9a0f
--- /dev/null
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+control 'arvados keepbalance package' do
+  title 'should be installed'
+
+  describe package('keep-balance') do
+    it { should be_installed }
+  end
+end
diff --git a/test/integration/keepbalance/controls/services_spec.rb b/test/integration/keepbalance/controls/services_spec.rb
new file mode 100644 (file)
index 0000000..fe157e2
--- /dev/null
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+control 'arvados keepbalance service' do
+  impact 0.5
+  title 'should be running and enabled'
+
+  describe service('keep-balance') do
+    it { should be_enabled }
+    it { should be_running }
+  end
+  describe port(9_005) do
+    it { should be_listening }
+    its('processes') { should cmp 'keep-balance' }
+  end
+end
diff --git a/test/integration/keepbalance/inspec.yml b/test/integration/keepbalance/inspec.yml
new file mode 100644 (file)
index 0000000..a431079
--- /dev/null
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+# vim: ft=yaml
+---
+name: keepbalance
+title: arvados formula keepbalance submodule
+maintainer: SaltStack Formulas
+license: Apache-2.0
+summary: Verify that the arvados formula keepbalance is setup and configured correctly
+supports:
+  - platform-name: debian
+  - platform-name: ubuntu
+  - platform-name: centos