diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..480842551adb9a2d9d83de67fe346c710102bcf6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "deploy/asapo-client-template"] + path = deploy/asapo_client_template + url = ssh://yakubov@stash.desy.de:7999/asapo/asapo-client-template.git diff --git a/3d_party/ctest_junit_convert/convert.py b/3d_party/ctest_junit_convert/convert.py index c390c33eec2a0bba1a490400cf744ae92060ac32..7586aa4758404e4617dc2c1570d624d8214d5c57 100644 --- a/3d_party/ctest_junit_convert/convert.py +++ b/3d_party/ctest_junit_convert/convert.py @@ -1,74 +1,25 @@ #!/usr/bin/env python -# coding: utf-8 -# originally from: -# http://www.warp1337.com/content/how-use-ctest-jenkins-xunit-or-junit-plugin -# improved by: -# Jorge Araya Navarro <elcorreo@deshackra.com> - -# Veni, Sancte Spiritus. from lxml import etree import argparse -from os.path import expanduser from os.path import join -import logging - -# configure logging -logging.basicConfig(format="%(levelname)s: %(message)s", - level=logging.ERROR) -desc = ("Converts ctest XML file to xUnit/JUnit XML " - "compatible file to use with Jenkins-CI. " - "Did you found any bug? please report it on: " - "https://bitbucket.org/shackra/ctest-jenkins/issues") - -# configure argument parser. -parser = argparse.ArgumentParser(description=desc) -parser.add_argument("-x", "--xslt", help="the XSLT file to use", required=True) -parser.add_argument("-t", "--tag", help=("the directory where 'Testing/TAG'" - "file is. Remember to call ctest with" - " '-T test' option to generate it"), - required=True) +parser = argparse.ArgumentParser() +parser.add_argument("-x",dest='xsl', required=True) +parser.add_argument("-t", dest='tag',required=True) parsed = parser.parse_args() -# expanding user symbol "~" -parsed.xsl = expanduser(parsed.xslt) -parsed.tag = expanduser(parsed.tag) - -# opening the TAG file -directory = None -try: - with open(join(parsed.tag, "Testing", "TAG")) as tagfile: - directory = tagfile.readline().strip() -except NotADirectoryError: - logging.error( - "'Testing/TAG' wasn't found on directory '{}'.".format(parsed.tag)) - exit(1) -except FileNotFoundError: - logging.error( - "File '{}' not found.".format(join(parsed.tag, "Testing", "TAG"))) - exit(1) -xmldoc = None -transform = None -try: - with open(join(parsed.tag, "Testing", directory, "Test.xml"))\ - as testxmlfile: - xmldoc = etree.parse(testxmlfile) +with open(join(parsed.tag, "Testing", "TAG")) as tagfile: + directory = tagfile.readline().strip() -except FileNotFoundError: - logging.error("File {} not found. Was it deleted or moved?".format( - join(parsed.tag, "Testing", directory, "Test.xml"))) - exit(1) +with open(join(parsed.tag, "Testing", directory, "Test.xml")) as testxmlfile: + xmldoc = etree.parse(testxmlfile) -try: - with open(parsed.xslt) as xsltfile: - xslt_root = etree.XML(xsltfile.read()) - transform = etree.XSLT(xslt_root) -except FileNotFoundError: - logging.error("File {} not found.".format(parsed.xslt)) - exit(1) +with open(parsed.xsl) as xslfile: + xsl_root = etree.XML(xslfile.read()) + transform = etree.XSLT(xsl_root) result_tree = transform(xmldoc) print(result_tree) diff --git a/LICENSE-CREDITS-3RD-PARTY.txt b/LICENSE-CREDITS-3RD-PARTY.txt new file mode 100644 index 0000000000000000000000000000000000000000..bf9674937ff27b7e41dc5294fa235ccf3c798c21 --- /dev/null +++ b/LICENSE-CREDITS-3RD-PARTY.txt @@ -0,0 +1,42 @@ +There are following 3rd party libraries and tools used in various parts of the ASAP::O: + +======== +MIT - https://opensource.org/licenses/MIT +======== +ctest to junit converter - https://github.com/genome/build-common +rapidjson - https://github.com/Tencent/rapidjson +go testing packages - https://github.com/stretchr/testify +go unique id generator package https://github.com/rs/xid +go influxdb client - https://github.com/influxdata/influxdb1-client +using Visual Studio to compile for Windows - https://visualstudio.microsoft.com + +======== +Apache2 - https://www.apache.org/licenses/LICENSE-2.0 +======== +mongo-c-driver - https://github.com/mongodb/mongo-c-driver +go mongodb packages - https://github.com/mongodb/mongo-go-driver +go SQL parser package - https://github.com/knocknote/vitess-sqlparser/sqlparser +cython - https://github.com/cython/cython +Docker open source components - https://www.docker.com/ + +======== +BSD 3-Clause - https://opensource.org/licenses/BSD-3-Clause +======== +go request router package - https://github.com/gorilla/mux +using go to compile binaries - http://golang.org + +======== +Mozilla Public License, v. 2.0 - http://mozilla.org/MPL/2.0/ +======== +go consul client - github.com/hashicorp/consul/api + +======== +Custom licenses +======== +libcurl - https://curl.haxx.se/ - MIT-like license - https://curl.haxx.se/docs/copyright.html + +======== +Remarks +======== +gcc compiled binaries fall into the GCC Runtime Library Exception - https://www.gnu.org/licenses/gcc-exception.html + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..427c72f6ff93a6b33cb571e1bf95c32c79efe9f3 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (c) 2019 Deutsches Elektronen-Synchrotron (DESY) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 26e8f8c69417475f42c3bbdd073f6974bdf63f9b..79b2dd67bec042168af971988ed0edc91f61f01c 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,6 @@ Need googletest >= [1.8.0](https://github.com/google/googletest/releases/tag/rel - mkdir build - cd build - cmake -DBUILD_TESTS=ON .. + +The software is MIT licensed (see LICENSE.txt) and uses third party libraries that are distributed under their own terms +(see LICENSE-3RD-PARTY.txt) \ No newline at end of file diff --git a/broker/src/asapo_broker/database/mongodb_query.go b/broker/src/asapo_broker/database/mongodb_query.go index e85d0135efa518861bfd1ce1d2fc17214a041694..610631bf818117cdde642fd0226cc67a648ee90f 100644 --- a/broker/src/asapo_broker/database/mongodb_query.go +++ b/broker/src/asapo_broker/database/mongodb_query.go @@ -5,7 +5,7 @@ package database import ( "errors" "fmt" - "github.com/globalsign/mgo/bson" + "go.mongodb.org/mongo-driver/bson" "github.com/knocknote/vitess-sqlparser/sqlparser" "strconv" ) diff --git a/deploy/CMakeLists.txt b/deploy/CMakeLists.txt index 78859d8935f9ace14c30a7899fd8bd0d846f0f2d..ced90947d6d4278ef8bbe732cc232d6517041f2d 100644 --- a/deploy/CMakeLists.txt +++ b/deploy/CMakeLists.txt @@ -4,8 +4,8 @@ else() SET (NOMAD_INSTALL ${CMAKE_INSTALL_PREFIX}/nomad_jobs) endif() -configure_files(${CMAKE_CURRENT_SOURCE_DIR}/asapo ${CMAKE_CURRENT_BINARY_DIR}/asapo) -configure_files(${CMAKE_CURRENT_SOURCE_DIR}/asapo/scripts ${CMAKE_CURRENT_BINARY_DIR}/asapo/scripts) +configure_files(${CMAKE_CURRENT_SOURCE_DIR}/asapo_services ${CMAKE_CURRENT_BINARY_DIR}/asapo_services) +configure_files(${CMAKE_CURRENT_SOURCE_DIR}/asapo_services/scripts ${CMAKE_CURRENT_BINARY_DIR}/asapo_services/scripts) diff --git a/deploy/asapo_client_template b/deploy/asapo_client_template new file mode 160000 index 0000000000000000000000000000000000000000..e7f7552c8a8672577787db52fb32e2a009e14c98 --- /dev/null +++ b/deploy/asapo_client_template @@ -0,0 +1 @@ +Subproject commit e7f7552c8a8672577787db52fb32e2a009e14c98 diff --git a/deploy/asapo_orchestration_docker/Dockerfile b/deploy/asapo_orchestration_docker/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..87e56865ceaab1f03cedc23c06b4ef18a52b0e2b --- /dev/null +++ b/deploy/asapo_orchestration_docker/Dockerfile @@ -0,0 +1,7 @@ +FROM yakser/asapo-nomad-cluster + +MAINTAINER DESY IT + +COPY scripts/ /var/run/asapo/ + +RUN cd /var/run/asapo && terraform init diff --git a/deploy/asapo_orchestration_docker/build_image.sh b/deploy/asapo_orchestration_docker/build_image.sh new file mode 100755 index 0000000000000000000000000000000000000000..f375d647bd9799f5a229c9d45ebeefef4cca1398 --- /dev/null +++ b/deploy/asapo_orchestration_docker/build_image.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +docker build -t yakser/asapo-orc . +docker push yakser/asapo-orc + diff --git a/deploy/asapo_orchestration_docker/scripts/asapo.auto.tfvars b/deploy/asapo_orchestration_docker/scripts/asapo.auto.tfvars new file mode 100644 index 0000000000000000000000000000000000000000..3d6338cae7961b4476348207e46b2f75faa9ef2b --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/asapo.auto.tfvars @@ -0,0 +1,22 @@ +job_scripts_dir = "/var/run/asapo" + +consul_dns_port = 8600 + +grafana_total_memory_size = "256" +grafana_port = 3000 +grafana_version="latest" + +nginx_total_memory_size = 256 +nginx_port = 8401 +nginx_port_stream = 8402 +nginx_version = "1.14" + +influxdb_total_memory_size = "256" +influxdb_port = 8086 +influxdb_version = "latest" + +telegraf_total_memory_size = "256" +telegraf_port_stream = 8125 +telegraf_version = "latest" + +monitoring = true diff --git a/deploy/asapo_orchestration_docker/scripts/grafana/dashboards/grafana.json b/deploy/asapo_orchestration_docker/scripts/grafana/dashboards/grafana.json new file mode 100644 index 0000000000000000000000000000000000000000..2bf30cbb561b5c1c37ae7d8e4a8ebdcec6dfe86f --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/grafana/dashboards/grafana.json @@ -0,0 +1,929 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 1, + "iteration": 1575563736443, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 22, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "nomad_client_allocs", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "memory_rss" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "task", + "operator": "=~", + "value": "/^$task$/" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Total Memory Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorPostfix": false, + "colorPrefix": false, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "InfluxDB", + "description": "", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 5, + "w": 4, + "x": 1, + "y": 8 + }, + "id": 13, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "consul_health_checks", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "passing" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "service_name", + "operator": "=", + "value": "telegraf" + } + ] + } + ], + "thresholds": "1,1", + "timeFrom": "20s", + "timeShift": null, + "title": "Telegraf", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "Not running", + "value": "0" + }, + { + "op": "=", + "text": "Running", + "value": "1" + }, + { + "op": "=", + "text": "", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorPostfix": false, + "colorPrefix": false, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "InfluxDB", + "description": "", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 5, + "w": 4, + "x": 7, + "y": 8 + }, + "id": 15, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "consul_health_checks", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "passing" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "service_name", + "operator": "=", + "value": "influxdb" + } + ] + } + ], + "thresholds": "1,1", + "timeFrom": "20s", + "timeShift": null, + "title": "InfluxDB", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "Not running", + "value": "0" + }, + { + "op": "=", + "text": "Running", + "value": "1" + }, + { + "op": "=", + "text": "", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorPostfix": false, + "colorPrefix": false, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "InfluxDB", + "description": "", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 5, + "w": 4, + "x": 12, + "y": 8 + }, + "id": 17, + "interval": null, + "links": [], + "mappingType": 2, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + }, + { + "from": "0", + "text": "", + "to": "0" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "consul_health_checks", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "passing" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "service_name", + "operator": "=", + "value": "nginx" + } + ] + } + ], + "thresholds": "1,1", + "timeFrom": "20s", + "timeShift": null, + "title": "Nginx", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "Not running", + "value": "0" + }, + { + "op": "=", + "text": "Running", + "value": "1" + }, + { + "op": "=", + "text": "", + "value": "null" + } + ], + "valueName": "total" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorPostfix": false, + "colorPrefix": false, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "InfluxDB", + "description": "", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 5, + "w": 4, + "x": 1, + "y": 13 + }, + "id": 14, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "consul_health_checks", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "passing" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "service_name", + "operator": "=", + "value": "grafana" + } + ] + } + ], + "thresholds": "1,1", + "timeFrom": "20s", + "timeShift": null, + "title": "Grafana", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "Not running", + "value": "0" + }, + { + "op": "=", + "text": "Running", + "value": "1" + }, + { + "op": "=", + "text": "", + "value": "null" + } + ], + "valueName": "current" + }, + { + "datasource": "InfluxDB", + "gridPos": { + "h": 5, + "w": 4, + "x": 6, + "y": 13 + }, + "hideTimeOverride": true, + "id": 4, + "options": { + "fieldOptions": { + "calcs": [ + "mean" + ], + "defaults": { + "mappings": [], + "max": 100, + "min": 0, + "thresholds": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ], + "title": "", + "unit": "percent" + }, + "override": {}, + "values": false + }, + "orientation": "horizontal", + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "6.5.1", + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "nomad_client_allocs", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"memory_rss\") /mean([[memory_allocated]]) * 100 FROM \"nomad_client_allocs\" WHERE (\"task\" = 'grafana') AND $timeFilter GROUP BY time($__interval) fill(null)", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "memory_rss" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "/mean(\"memory_allocated\") * 100" + ], + "type": "math" + } + ] + ], + "tags": [ + { + "key": "task", + "operator": "=", + "value": "grafana" + } + ] + } + ], + "timeFrom": "20s", + "timeShift": null, + "title": "Memory Usage", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB", + "gridPos": { + "h": 5, + "w": 4, + "x": 11, + "y": 13 + }, + "hideTimeOverride": true, + "id": 9, + "options": { + "fieldOptions": { + "calcs": [ + "mean" + ], + "defaults": { + "mappings": [], + "max": 1600, + "min": 0, + "thresholds": [ + { + "color": "green", + "value": null + } + ], + "title": "", + "unit": "percent" + }, + "override": {}, + "values": false + }, + "orientation": "horizontal", + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "6.5.1", + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "nomad_client_allocs", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpu_total_percent" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [ + { + "key": "task", + "operator": "=", + "value": "grafana" + } + ] + } + ], + "timeFrom": "20s", + "timeShift": null, + "title": "CPU Usage", + "transparent": true, + "type": "gauge" + } + ], + "refresh": "10s", + "schemaVersion": 21, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "All", + "value": [ + "$__all" + ] + }, + "datasource": "InfluxDB", + "definition": "SHOW TAG VALUES WITH KEY = \"task\"", + "hide": 0, + "includeAll": true, + "label": null, + "multi": true, + "name": "task", + "options": [], + "query": "SHOW TAG VALUES WITH KEY = \"task\"", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 5, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Asapo Client Monitor", + "uid": "acm", + "version": 5 +} \ No newline at end of file diff --git a/deploy/asapo_orchestration_docker/scripts/grafana/grafana.ini.tpl b/deploy/asapo_orchestration_docker/scripts/grafana/grafana.ini.tpl new file mode 100644 index 0000000000000000000000000000000000000000..6dfd9cd1428f0f32b251f69354efbcc492415673 --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/grafana/grafana.ini.tpl @@ -0,0 +1,10 @@ +[server] +http_port = {{ env "NOMAD_PORT_grafana" }} + +[auth.anonymous] +enabled = true +org_name = Main Org. +org_role = Admin + +#[auth] +#disable_login_form = true diff --git a/deploy/asapo_orchestration_docker/scripts/grafana/provisioning/dashboards/dashboards.yaml b/deploy/asapo_orchestration_docker/scripts/grafana/provisioning/dashboards/dashboards.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e1a18c82d7e5ba671f502d30d47080a547959ae7 --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/grafana/provisioning/dashboards/dashboards.yaml @@ -0,0 +1,12 @@ +apiVersion: 1 + +providers: +- name: 'client monitoring' + folder: '' + type: file + disableDeletion: false + editable: true + updateIntervalSeconds: 10000 + allowUiUpdates: true + options: + path: /var/lib/grafana_config/dashboards \ No newline at end of file diff --git a/deploy/asapo_orchestration_docker/scripts/grafana/provisioning/datasources/datasources.yaml.tpl b/deploy/asapo_orchestration_docker/scripts/grafana/provisioning/datasources/datasources.yaml.tpl new file mode 100644 index 0000000000000000000000000000000000000000..f5bba7c336f48e86b95926bd21e4655c88c4428c --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/grafana/provisioning/datasources/datasources.yaml.tpl @@ -0,0 +1,10 @@ +apiVersion: 1 + +datasources: + - name: InfluxDB + type: influxdb + access: proxy + database: telegraf + url: http://localhost:{{ env "NOMAD_META_nginx_port" }}/influxdb + jsonData: + httpMode: GET diff --git a/deploy/asapo_orchestration_docker/scripts/monitoring.nmd.tpl b/deploy/asapo_orchestration_docker/scripts/monitoring.nmd.tpl new file mode 100644 index 0000000000000000000000000000000000000000..0a4e667a4be41d3396ddad053f9504c5badfdce9 --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/monitoring.nmd.tpl @@ -0,0 +1,191 @@ +job "monitoring" { + datacenters = ["dc1"] + affinity { + attribute = "$${meta.asapo_service}" + value = "true" + weight = 100 + } + +# update { +# max_parallel = 1 +# min_healthy_time = "10s" +# healthy_deadline = "3m" +# auto_revert = false +# } + + group "monitoring" { + count = "%{ if monitoring }1%{ else }0%{ endif }" + restart { + attempts = 2 + interval = "3m" + delay = "15s" + mode = "delay" + } + + meta { + nginx_port = "${nginx_port}" + } + + task "influxdb" { + driver = "docker" + user = "${asapo_user}" + config { + network_mode = "host" + security_opt = ["no-new-privileges"] + userns_mode = "host" + image = "influxdb:${influxdb_version}" + volumes = ["/${service_dir}/influxdb:/var/lib/influxdb"] + } + + env { + PRE_CREATE_DB="asapo_receivers;asapo_brokers" + } + + resources { + memory = "${influxdb_total_memory_size}" + network { + port "influxdb" { + static = "${influxdb_port}" + } + } + } + + service { + port = "influxdb" + name = "influxdb" + check { + name = "alive" + type = "http" + path = "/ping" + interval = "10s" + timeout = "1s" + } + check_restart { + limit = 2 + grace = "90s" + ignore_warnings = false + } + } + + } #influxdb + + + task "grafana" { + driver = "docker" + user = "${asapo_user}" + env { + GF_SERVER_DOMAIN = "$${attr.unique.hostname}" + GF_SERVER_ROOT_URL = "%(protocol)s://%(domain)s/monitoring/" + GF_PATHS_PROVISIONING = "/var/lib/grafana_config/provisioning" + } + + config { + network_mode = "host" + security_opt = ["no-new-privileges"] + userns_mode = "host" + image = "grafana/grafana:${grafana_version}" + volumes = ["/${service_dir}/grafana:/var/lib/grafana", + "local/grafana:/var/lib/grafana_config", + "local/grafana/grafana.ini:/etc/grafana/grafana.ini" + ] + } + + resources { + memory = "${grafana_total_memory_size}" + network { + port "grafana" { + static = "${grafana_port}" + } + } + } + + service { + port = "grafana" + name = "grafana" + check { + name = "alive" + type = "http" + path = "/api/health" + interval = "10s" + timeout = "1s" + } + check_restart { + limit = 2 + grace = "90s" + ignore_warnings = false + } + } + + template { + source = "${scripts_dir}/grafana/grafana.ini.tpl" + destination = "local/grafana/grafana.ini" + change_mode = "restart" + } + template { + source = "${scripts_dir}/grafana/provisioning/dashboards/dashboards.yaml" + destination = "local/grafana/provisioning/dashboards/dashboards.yaml" + change_mode = "restart" + } + template { + source = "${scripts_dir}/grafana/provisioning/datasources/datasources.yaml.tpl" + destination = "local/grafana/provisioning/datasources/datasources.yaml" + change_mode = "restart" + } + template { + source = "${scripts_dir}/grafana/dashboards/grafana.json" + destination = "local/grafana/dashboards/grafana.json" + change_mode = "restart" + } + + } #grafana + + task "telegraf" { + driver = "docker" + user = "${asapo_user}" + config { + network_mode = "host" + security_opt = ["no-new-privileges"] + userns_mode = "host" + image = "telegraf:${telegraf_version}" + volumes = [ + "local/telegraf.conf:/etc/telegraf/telegraf.conf" + ] + } + + resources { + memory = "${telegraf_total_memory_size}" + network { + port "telegraf_stream" { + static = "${telegraf_port_stream}" + } + } + } + + service { + name = "telegraf" + port = "telegraf_stream" + check { + name = "telegraf-alive" + type = "script" + command = "/bin/ps" + args = ["-fC","telegraf"] + interval = "10s" + timeout = "2s" + } + check_restart { + limit = 2 + grace = "15s" + ignore_warnings = false + } + } + + template { + source = "${scripts_dir}/telegraf.conf.tpl" + destination = "local/telegraf.conf" + change_mode = "restart" + } + + } #telegraf + + } +} diff --git a/deploy/asapo_orchestration_docker/scripts/nginx.conf.tpl b/deploy/asapo_orchestration_docker/scripts/nginx.conf.tpl new file mode 100644 index 0000000000000000000000000000000000000000..18eacfafd181b48ad7372c93508eb802a252e32e --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/nginx.conf.tpl @@ -0,0 +1,63 @@ +worker_processes 1; + +events { + worker_connections 100000; +} + +error_log "/dev/stdout"; +pid "/tmp/nginx.pid"; + +http { +# include mime.types; +# default_type application/octet-stream; + +# sendfile on; +# tcp_nopush on; + +# keepalive_timeout 0; +# keepalive_timeout 65; + + access_log off; + + + client_body_temp_path "/tmp/client_body" 1 2; + proxy_temp_path "/tmp/proxy" 1 2; + fastcgi_temp_path "/tmp/fastcgi" 1 2; + scgi_temp_path "/tmp/scgi" 1 2; + uwsgi_temp_path "/tmp/uwsgi" 1 2; + + + resolver 127.0.0.1:{{ env "NOMAD_META_consul_dns_port" }} valid=1s; + server { + listen {{ env "NOMAD_PORT_nginx" }} reuseport; + set $grafana_endpoint grafana.service.asapo; + set $influxdb_endpoint influxdb.service.asapo; + + location /influxdb/ { + rewrite ^/influxdb(/.*) $1 break; + proxy_pass http://$influxdb_endpoint:{{ env "NOMAD_META_influxdb_port" }}$uri$is_args$args; + } + + location /monitoring/ { + rewrite ^/monitoring(/.*) $1 break; + proxy_pass http://$grafana_endpoint:{{ env "NOMAD_META_grafana_port" }}$uri$is_args$args; + } + + location /nginx-health { + return 200 "healthy\n"; + } + } +} + +stream { + resolver 127.0.0.1:{{ env "NOMAD_META_consul_dns_port" }} valid=1s; + + map $remote_addr $upstream { + default telegraf.service.asapo; + } + + server { + listen {{ env "NOMAD_PORT_nginx_stream" }} udp; + proxy_pass $upstream:{{ env "NOMAD_META_telegraf_port_stream" }}; + } +} diff --git a/deploy/asapo_orchestration_docker/scripts/nginx.nmd.tpl b/deploy/asapo_orchestration_docker/scripts/nginx.nmd.tpl new file mode 100644 index 0000000000000000000000000000000000000000..994d99004b8c39bd604f5ffa024e9f41c35ad385 --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/nginx.nmd.tpl @@ -0,0 +1,77 @@ +job "asapo-nginx" { + datacenters = ["dc1"] + + type = "system" + + group "nginx" { + count = 1 + + restart { + attempts = 2 + interval = "3m" + delay = "16s" + mode = "delay" + } + + task "nginx" { + driver = "docker" + + user = "${asapo_user}" + + meta { + telegraf_port_stream = "${telegraf_port_stream}" + grafana_port = "${grafana_port}" + influxdb_port = "${influxdb_port}" + consul_dns_port = "${consul_dns_port}" + } + + config { + network_mode = "host" + security_opt = ["no-new-privileges"] + userns_mode = "host" + image = "nginx:${nginx_version}" + volumes = [ + "local/nginx.conf:/etc/nginx/nginx.conf" + ] + } + + resources { + cpu = 500 + memory = ${nginx_total_memory_size} + network { + mbits = 10 + port "nginx" { + static = ${nginx_port} + } + port "nginx_stream" { + static = ${nginx_port_stream} + } + } + } + + service { + port = "nginx" + name = "nginx" + check { + name = "alive" + type = "http" + path = "/nginx-health" + timeout = "2s" + interval = "10s" + } + + check_restart { + limit = 2 + grace = "15s" + ignore_warnings = false + } + } + + template { + source = "${scripts_dir}/nginx.conf.tpl" + destination = "local/nginx.conf" + change_mode = "restart" + } + } + } +} diff --git a/deploy/asapo_orchestration_docker/scripts/provider.tf b/deploy/asapo_orchestration_docker/scripts/provider.tf new file mode 100644 index 0000000000000000000000000000000000000000..2aea570ecbcf25d381c0d3ef2782e6bd4ba4ace7 --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/provider.tf @@ -0,0 +1,5 @@ +provider "nomad" { + address = "http://localhost:4646" +# secret_id = "${chomp(file("/var/nomad/token"))}" +} + diff --git a/deploy/asapo_orchestration_docker/scripts/resources.tf b/deploy/asapo_orchestration_docker/scripts/resources.tf new file mode 100644 index 0000000000000000000000000000000000000000..7bea5c4adcf6facd5e2f35679dd009f255e071f0 --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/resources.tf @@ -0,0 +1,7 @@ +resource "nomad_job" "monitoring" { + jobspec = "${data.template_file.monitoring_template.rendered}" +} + +resource "nomad_job" "nginx" { + jobspec = "${data.template_file.nginx_template.rendered}" +} diff --git a/deploy/asapo_orchestration_docker/scripts/telegraf.conf.tpl b/deploy/asapo_orchestration_docker/scripts/telegraf.conf.tpl new file mode 100644 index 0000000000000000000000000000000000000000..e962ebe74feb2340fb6317290c359753027b541a --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/telegraf.conf.tpl @@ -0,0 +1,18 @@ +[[inputs.statsd]] + protocol = "udp" + service_address = ":{{ env "NOMAD_PORT_telegraf_stream" }}" + namepass= ["nomad_client_allocs"] + templates = [ + "nomad.client.allocs.* measurement.measurement.measurement.field.field.job.group.alloc-id.task.hostname", + "nomad.nomad.job_summary.* measurement.measurement.measurement.field.job.group.hostname" + ] + +[[inputs.consul]] + +[[outputs.file]] + files=["stdout"] + + +[[outputs.influxdb]] + urls = ["http://localhost:{{ env "NOMAD_META_nginx_port" }}/influxdb"] + diff --git a/deploy/asapo_orchestration_docker/scripts/templates.tf b/deploy/asapo_orchestration_docker/scripts/templates.tf new file mode 100644 index 0000000000000000000000000000000000000000..cf1994d74510c76f099489c19d8e570adfaf0db7 --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/templates.tf @@ -0,0 +1,39 @@ +data "template_file" "monitoring_template" { + template = "${file("${var.job_scripts_dir}/monitoring.nmd.tpl")}" + vars = { + monitoring = "${var.monitoring}" + service_dir = "${var.service_dir}" + grafana_version = "${var.grafana_version}" + grafana_total_memory_size = "${var.grafana_total_memory_size}" + grafana_port = "${var.grafana_port}" + grafana_version = "${var.grafana_version}" + grafana_total_memory_size = "${var.grafana_total_memory_size}" + grafana_port = "${var.grafana_port}" + influxdb_version = "${var.influxdb_version}" + influxdb_total_memory_size = "${var.influxdb_total_memory_size}" + influxdb_port = "${var.influxdb_port}" + telegraf_version = "${var.telegraf_version}" + telegraf_total_memory_size = "${var.telegraf_total_memory_size}" + telegraf_port_stream = "${var.telegraf_port_stream}" + nginx_port = "${var.nginx_port}" + asapo_user = "${var.asapo_user}" + scripts_dir = "${var.job_scripts_dir}" + } +} + +data "template_file" "nginx_template" { + template = "${file("${var.job_scripts_dir}/nginx.nmd.tpl")}" + vars = { + scripts_dir = "${var.job_scripts_dir}" + nginx_total_memory_size = "${var.nginx_total_memory_size}" + nginx_version = "${var.nginx_version}" + nginx_port = "${var.nginx_port}" + nginx_port_stream = "${var.nginx_port_stream}" + telegraf_port_stream = "${var.telegraf_port_stream}" + grafana_port = "${var.grafana_port}" + influxdb_port = "${var.influxdb_port}" + asapo_user = "${var.asapo_user}" + consul_dns_port = "${var.consul_dns_port}" + } +} + diff --git a/deploy/asapo_orchestration_docker/scripts/vars.tf b/deploy/asapo_orchestration_docker/scripts/vars.tf new file mode 100644 index 0000000000000000000000000000000000000000..3944e8f7e5c57174efea06bf90df7854aa52edcc --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/vars.tf @@ -0,0 +1,28 @@ +variable "asapo_user" {} + +variable "monitoring" {} + +variable "grafana_version" {} +variable "telegraf_version" {} +variable "influxdb_version" {} +variable "nginx_version" {} + +variable "job_scripts_dir" {} +variable "service_dir" {} +variable "data_dir" {} + +variable "grafana_total_memory_size" {} +variable "grafana_port" {} + +variable "telegraf_port_stream" {} +variable "telegraf_total_memory_size" {} + +variable "influxdb_total_memory_size" {} +variable "influxdb_port" {} + +variable "nginx_total_memory_size" {} +variable "nginx_port" {} +variable "nginx_port_stream" {} + +variable "consul_dns_port" {} + diff --git a/deploy/asapo_services/Dockerfile b/deploy/asapo_services/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1ea67d704f343044c29e1c18d1dbf08ff9ac4792 --- /dev/null +++ b/deploy/asapo_services/Dockerfile @@ -0,0 +1,9 @@ +FROM yakser/asapo-nomad-cluster + +MAINTAINER DESY IT + +COPY scripts/ /var/run/asapo/ + +COPY asapo-wait-service /usr/bin/ + +RUN cd /var/run/asapo asapo && terraform init diff --git a/deploy/asapo/asap3.tfvars b/deploy/asapo_services/asap3.tfvars similarity index 100% rename from deploy/asapo/asap3.tfvars rename to deploy/asapo_services/asap3.tfvars diff --git a/deploy/asapo/asapo-wait-service b/deploy/asapo_services/asapo-wait-service similarity index 98% rename from deploy/asapo/asapo-wait-service rename to deploy/asapo_services/asapo-wait-service index 4b70a1630d4b6a5de0796098b0232ee97be96cb9..a8e40b965a0accafabe7e4a5060dbd45cc548fdc 100755 --- a/deploy/asapo/asapo-wait-service +++ b/deploy/asapo_services/asapo-wait-service @@ -4,8 +4,6 @@ if [ "$2" == "false" ]; then exit 0 fi - until dig +short @127.0.0.1 -p 8600 $1.service.asapo | grep . ; do sleep 1 done - diff --git a/deploy/asapo/asapo_overwrite_vars.tfvars b/deploy/asapo_services/asapo_overwrite_vars.tfvars similarity index 100% rename from deploy/asapo/asapo_overwrite_vars.tfvars rename to deploy/asapo_services/asapo_overwrite_vars.tfvars diff --git a/deploy/asapo/build_image.sh b/deploy/asapo_services/build_image.sh similarity index 100% rename from deploy/asapo/build_image.sh rename to deploy/asapo_services/build_image.sh diff --git a/deploy/asapo/copy_asap3.sh.in b/deploy/asapo_services/copy_asap3.sh.in similarity index 100% rename from deploy/asapo/copy_asap3.sh.in rename to deploy/asapo_services/copy_asap3.sh.in diff --git a/deploy/asapo/job.sh b/deploy/asapo_services/job.sh similarity index 100% rename from deploy/asapo/job.sh rename to deploy/asapo_services/job.sh diff --git a/deploy/asapo/run.sh b/deploy/asapo_services/run.sh similarity index 86% rename from deploy/asapo/run.sh rename to deploy/asapo_services/run.sh index 433a5deb5b9d9a522bed64a2b2718dbd5238e723..e33bed710657515f2d4696dca0f7b07df83b84c2 100755 --- a/deploy/asapo/run.sh +++ b/deploy/asapo_services/run.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -NOMAD_ALLOC_HOST_SHARED=/tmp/asapo/container_host_shared/nomad_alloc -SERVICE_DATA_CLUSTER_SHARED=/tmp/asapo/asapo_cluster_shared/service_data -DATA_GLOBAL_SHARED=/tmp/asapo/global_shared/data +NOMAD_ALLOC_HOST_SHARED=/var/tmp/asapo/container_host_shared/nomad_alloc +SERVICE_DATA_CLUSTER_SHARED=/var/tmp/asapo/asapo_cluster_shared/service_data +DATA_GLOBAL_SHARED=/var/tmp/asapo/global_shared/data MONGO_DIR=$SERVICE_DATA_CLUSTER_SHARED/mongodb ASAPO_USER=`id -u`:`id -g` @@ -14,7 +14,7 @@ ASAPO_USER=`id -u`:`id -g` #N_SERVERS= ASAPO_VAR_FILE=`pwd`/asapo_overwrite_vars.tfvars - +ACL_ENABLED=true mkdir -p $NOMAD_ALLOC_HOST_SHARED $SERVICE_DATA_CLUSTER_SHARED $DATA_GLOBAL_SHARED chmod 777 $NOMAD_ALLOC_HOST_SHARED $SERVICE_DATA_CLUSTER_SHARED $DATA_GLOBAL_SHARED @@ -52,6 +52,7 @@ docker run --privileged --rm -v /var/run/docker.sock:/var/run/docker.sock \ -e RECURSORS=$RECURSORS \ -e TF_VAR_asapo_user=$ASAPO_USER \ -e IB_ADDRESS=$IB_ADDRESS \ + -e ACL_ENABLED=$ACL_ENABLED \ -e SERVER_ADRESSES=$SERVER_ADRESSES \ -e N_SERVERS=$N_SERVERS \ --name asapo --net=host -d yakser/asapo-cluster diff --git a/deploy/asapo/run_maxwell.sh b/deploy/asapo_services/run_maxwell.sh similarity index 96% rename from deploy/asapo/run_maxwell.sh rename to deploy/asapo_services/run_maxwell.sh index a9bf9e7bf60b7e7c6f3093706314474ca591bf93..47d92d548b1c114f5c650651b8090dd01ba79eab 100755 --- a/deploy/asapo/run_maxwell.sh +++ b/deploy/asapo_services/run_maxwell.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash #folders -NOMAD_ALLOC_HOST_SHARED=/tmp/asapo/container_host_shared/nomad_alloc +NOMAD_ALLOC_HOST_SHARED=/var/tmp/asapo/container_host_shared/nomad_alloc SERVICE_DATA_CLUSTER_SHARED=/home/yakubov/asapo/asapo_cluster_shared/service_data DATA_GLOBAL_SHARED=/gpfs/petra3/scratch/yakubov/asapo_shared MONGO_DIR=/scratch/mongodb # due to performance reasons mongodb can benefit from writing to local filesystem (HA to be worked on) @@ -15,6 +15,7 @@ RECURSORS=["\"131.169.40.200\"",\""131.169.194.200\""] ASAPO_USER=`id -u`:`id -g` ASAPO_VAR_FILE=`pwd`/asapo_overwrite_vars.tfvars +ACL_ENABLED=true #docker stuff @@ -77,6 +78,7 @@ dockerrun --rm \ -e RECURSORS=$RECURSORS \ -e TF_VAR_asapo_user=$ASAPO_USER \ -e IB_ADDRESS=$IB_ADDRESS \ + -e ACL_ENABLED=$ACL_ENABLED \ -e SERVER_ADRESSES=$SERVER_ADRESSES \ -e ASAPO_LIGHTWEIGHT_SERVICE_NODES=$ASAPO_LIGHTWEIGHT_SERVICE_NODES \ -e DOCKER_ENDPOINT=$DOCKER_ENDPOINT \ diff --git a/deploy/asapo/scripts/asapo-brokers.nmd.tpl b/deploy/asapo_services/scripts/asapo-brokers.nmd.tpl similarity index 100% rename from deploy/asapo/scripts/asapo-brokers.nmd.tpl rename to deploy/asapo_services/scripts/asapo-brokers.nmd.tpl diff --git a/deploy/asapo/scripts/asapo-logging.nmd.tpl b/deploy/asapo_services/scripts/asapo-logging.nmd.tpl similarity index 100% rename from deploy/asapo/scripts/asapo-logging.nmd.tpl rename to deploy/asapo_services/scripts/asapo-logging.nmd.tpl diff --git a/deploy/asapo/scripts/asapo-mongo.nmd.tpl b/deploy/asapo_services/scripts/asapo-mongo.nmd.tpl similarity index 100% rename from deploy/asapo/scripts/asapo-mongo.nmd.tpl rename to deploy/asapo_services/scripts/asapo-mongo.nmd.tpl diff --git a/deploy/asapo/scripts/asapo-nginx.nmd.tpl b/deploy/asapo_services/scripts/asapo-nginx.nmd.tpl similarity index 100% rename from deploy/asapo/scripts/asapo-nginx.nmd.tpl rename to deploy/asapo_services/scripts/asapo-nginx.nmd.tpl diff --git a/deploy/asapo/scripts/asapo-perfmetrics.nmd.tpl b/deploy/asapo_services/scripts/asapo-perfmetrics.nmd.tpl similarity index 100% rename from deploy/asapo/scripts/asapo-perfmetrics.nmd.tpl rename to deploy/asapo_services/scripts/asapo-perfmetrics.nmd.tpl diff --git a/deploy/asapo/scripts/asapo-receivers.nmd.tpl b/deploy/asapo_services/scripts/asapo-receivers.nmd.tpl similarity index 100% rename from deploy/asapo/scripts/asapo-receivers.nmd.tpl rename to deploy/asapo_services/scripts/asapo-receivers.nmd.tpl diff --git a/deploy/asapo/scripts/asapo-services.nmd.tpl b/deploy/asapo_services/scripts/asapo-services.nmd.tpl similarity index 100% rename from deploy/asapo/scripts/asapo-services.nmd.tpl rename to deploy/asapo_services/scripts/asapo-services.nmd.tpl diff --git a/deploy/asapo/scripts/asapo.auto.tfvars.in b/deploy/asapo_services/scripts/asapo.auto.tfvars.in similarity index 100% rename from deploy/asapo/scripts/asapo.auto.tfvars.in rename to deploy/asapo_services/scripts/asapo.auto.tfvars.in diff --git a/deploy/asapo/scripts/auth_secret.key b/deploy/asapo_services/scripts/auth_secret.key similarity index 100% rename from deploy/asapo/scripts/auth_secret.key rename to deploy/asapo_services/scripts/auth_secret.key diff --git a/deploy/asapo/scripts/authorizer.json.tpl b/deploy/asapo_services/scripts/authorizer.json.tpl similarity index 100% rename from deploy/asapo/scripts/authorizer.json.tpl rename to deploy/asapo_services/scripts/authorizer.json.tpl diff --git a/deploy/asapo/scripts/broker.json.tpl b/deploy/asapo_services/scripts/broker.json.tpl similarity index 100% rename from deploy/asapo/scripts/broker.json.tpl rename to deploy/asapo_services/scripts/broker.json.tpl diff --git a/deploy/asapo/scripts/discovery.json.tpl b/deploy/asapo_services/scripts/discovery.json.tpl similarity index 100% rename from deploy/asapo/scripts/discovery.json.tpl rename to deploy/asapo_services/scripts/discovery.json.tpl diff --git a/deploy/asapo/scripts/fluentd.conf.tpl b/deploy/asapo_services/scripts/fluentd.conf.tpl similarity index 100% rename from deploy/asapo/scripts/fluentd.conf.tpl rename to deploy/asapo_services/scripts/fluentd.conf.tpl diff --git a/deploy/asapo/scripts/kibana.yml b/deploy/asapo_services/scripts/kibana.yml similarity index 100% rename from deploy/asapo/scripts/kibana.yml rename to deploy/asapo_services/scripts/kibana.yml diff --git a/deploy/asapo/scripts/nginx.conf.tpl b/deploy/asapo_services/scripts/nginx.conf.tpl similarity index 100% rename from deploy/asapo/scripts/nginx.conf.tpl rename to deploy/asapo_services/scripts/nginx.conf.tpl diff --git a/deploy/asapo/scripts/receiver.json.tpl b/deploy/asapo_services/scripts/receiver.json.tpl similarity index 100% rename from deploy/asapo/scripts/receiver.json.tpl rename to deploy/asapo_services/scripts/receiver.json.tpl diff --git a/deploy/asapo/scripts/resources.tf b/deploy/asapo_services/scripts/resources.tf similarity index 100% rename from deploy/asapo/scripts/resources.tf rename to deploy/asapo_services/scripts/resources.tf diff --git a/deploy/asapo/scripts/resources_services.tf b/deploy/asapo_services/scripts/resources_services.tf similarity index 100% rename from deploy/asapo/scripts/resources_services.tf rename to deploy/asapo_services/scripts/resources_services.tf diff --git a/deploy/asapo/scripts/templates.tf b/deploy/asapo_services/scripts/templates.tf similarity index 100% rename from deploy/asapo/scripts/templates.tf rename to deploy/asapo_services/scripts/templates.tf diff --git a/deploy/asapo/scripts/vars.tf b/deploy/asapo_services/scripts/vars.tf similarity index 100% rename from deploy/asapo/scripts/vars.tf rename to deploy/asapo_services/scripts/vars.tf diff --git a/deploy/docker/build_env/Ubuntu16.04/Dockerfile b/deploy/build_env/Ubuntu16.04/Dockerfile similarity index 100% rename from deploy/docker/build_env/Ubuntu16.04/Dockerfile rename to deploy/build_env/Ubuntu16.04/Dockerfile diff --git a/deploy/docker/build_env/Ubuntu16.04/build.sh b/deploy/build_env/Ubuntu16.04/build.sh similarity index 100% rename from deploy/docker/build_env/Ubuntu16.04/build.sh rename to deploy/build_env/Ubuntu16.04/build.sh diff --git a/deploy/docker/build_env/Ubuntu16.04/build_image.sh b/deploy/build_env/Ubuntu16.04/build_image.sh similarity index 100% rename from deploy/docker/build_env/Ubuntu16.04/build_image.sh rename to deploy/build_env/Ubuntu16.04/build_image.sh diff --git a/deploy/docker/build_env/Ubuntu16.04/install_curl.sh b/deploy/build_env/Ubuntu16.04/install_curl.sh similarity index 100% rename from deploy/docker/build_env/Ubuntu16.04/install_curl.sh rename to deploy/build_env/Ubuntu16.04/install_curl.sh diff --git a/deploy/asapo/Dockerfile b/deploy/nomad_consul_docker/Dockerfile similarity index 92% rename from deploy/asapo/Dockerfile rename to deploy/nomad_consul_docker/Dockerfile index 427524d878de46464d7953c947c3ef840be022ae..e5b1ae786d356341898e4c1c24eff61240881ed5 100644 --- a/deploy/asapo/Dockerfile +++ b/deploy/nomad_consul_docker/Dockerfile @@ -46,11 +46,9 @@ RUN mkdir -p /var/log/supervisord/ /etc/consul.d /etc/nomad.d COPY scripts/ /var/run/asapo/ -RUN cd /var/run/asapo asapo && terraform init +RUN cd /var/run/asapo && terraform init -COPY asapo-* /usr/bin/ - -COPY *.sh asapo_overwrite_vars.tfvars /tmp/asapo_runscripts/ +COPY jobs-* /usr/bin/ COPY *.py /etc/asapo/ COPY *.hcl.tpl /etc/asapo/ diff --git a/deploy/nomad_consul_docker/build_image.sh b/deploy/nomad_consul_docker/build_image.sh new file mode 100755 index 0000000000000000000000000000000000000000..227ac362f2d64b67ef80888f135065b2a16c3850 --- /dev/null +++ b/deploy/nomad_consul_docker/build_image.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +docker build -t yakser/asapo-nomad-cluster . +docker push yakser/asapo-nomad-cluster + diff --git a/deploy/asapo/consul.hcl.tpl b/deploy/nomad_consul_docker/consul.hcl.tpl similarity index 100% rename from deploy/asapo/consul.hcl.tpl rename to deploy/nomad_consul_docker/consul.hcl.tpl diff --git a/deploy/asapo/asapo-start b/deploy/nomad_consul_docker/jobs-start similarity index 50% rename from deploy/asapo/asapo-start rename to deploy/nomad_consul_docker/jobs-start index 8d0be8b80414b3c97375c02025467f3f7b4fd5ab..e25c56318748b648f7aecc1f3e5a44888136217c 100755 --- a/deploy/asapo/asapo-start +++ b/deploy/nomad_consul_docker/jobs-start @@ -1,13 +1,17 @@ #!/usr/bin/env bash -if [ ! -f /var/nomad/token ]; then - nomad acl bootstrap > /var/nomad/bootstrap - cat /var/nomad/bootstrap | grep Secret | awk '{print $4}' > /var/nomad/token - cp /var/nomad/token $TF_VAR_service_dir/nomad_token +if [ ! -f /var/nomad/token ] && [ "${ACL_ENABLED}" = "true" ]; then + nomad acl bootstrap > /var/nomad/bootstrap && \ + cat /var/nomad/bootstrap | grep Secret | awk '{print $4}' > /var/nomad/token && \ + cp /var/nomad/token $NOMAD_ALLOC_DIR/nomad_token fi if [ -f /var/run/asapo/user_vars.tfvars ]; then USER_VAR_FILE="-var-file=/var/run/asapo/user_vars.tfvars" fi -cd /var/run/asapo && terraform apply -auto-approve $USER_VAR_FILE "$@" \ No newline at end of file +cd /var/run/asapo && terraform apply -auto-approve $USER_VAR_FILE "$@" + +if [ "${ACL_ENABLED}" = "true" ]; then + cat /var/nomad/token +fi diff --git a/deploy/asapo/asapo-stop b/deploy/nomad_consul_docker/jobs-stop similarity index 100% rename from deploy/asapo/asapo-stop rename to deploy/nomad_consul_docker/jobs-stop diff --git a/deploy/asapo/nomad.hcl.tpl b/deploy/nomad_consul_docker/nomad.hcl.tpl similarity index 73% rename from deploy/asapo/nomad.hcl.tpl rename to deploy/nomad_consul_docker/nomad.hcl.tpl index fae4e73534cf1e34fa4718878133d021c4058a00..56cf2b426c46855258eff35cfc32a2acad9bb9aa 100644 --- a/deploy/asapo/nomad.hcl.tpl +++ b/deploy/nomad_consul_docker/nomad.hcl.tpl @@ -5,7 +5,7 @@ advertise { } acl { - enabled = true + enabled = $acl_enabled } server { @@ -39,3 +39,12 @@ plugin "docker" { } } +telemetry { + publish_allocation_metrics = $use_telemetry + publish_node_metrics = $use_telemetry + statsd_address = "$telegraf_address" + collection_interval = "10s" +} + + + diff --git a/deploy/asapo/orchestr_config.py b/deploy/nomad_consul_docker/orchestr_config.py similarity index 92% rename from deploy/asapo/orchestr_config.py rename to deploy/nomad_consul_docker/orchestr_config.py index f865f6dc65e385648ecb95c0aebf4514ce3b1f8e..5e91651d3bd413a2359790284df9da1b6023b904 100644 --- a/deploy/asapo/orchestr_config.py +++ b/deploy/nomad_consul_docker/orchestr_config.py @@ -44,10 +44,14 @@ def set_parameters(): else: d['bootstrap_expect_string'] = "" d['ib_address']=my_get_env('IB_ADDRESS',"none") + d['acl_enabled']=my_get_env('ACL_ENABLED',"false") d['nomad_alloc_dir']=my_get_env('NOMAD_ALLOC_DIR','') d['recursors']=my_get_env('RECURSORS','["8.8.8.8"]') lightweight_service_nodes=my_get_env('ASAPO_LIGHTWEIGHT_SERVICE_NODES','[]') d['is_asapo_lightweight_service_node']=in_server_list(d['advertise_ip'],lightweight_service_nodes, True) + d['use_telemetry'] = my_get_env('NOMAD_TELEMETRY','false') + d['telegraf_address'] = my_get_env('TELEGRAF_ADDRESS','localhost:8125') + return d def process_file(file_in,file_out): diff --git a/deploy/nomad_consul_docker/run.sh b/deploy/nomad_consul_docker/run.sh new file mode 100755 index 0000000000000000000000000000000000000000..0c5bedbb62907ea8f20f814c1794e233bd8cdd3f --- /dev/null +++ b/deploy/nomad_consul_docker/run.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +NOMAD_ALLOC_HOST_SHARED=/tmp/asapo/container_host_shared/nomad_alloc + +ASAPO_USER=`id -u`:`id -g` + +mkdir -p $NOMAD_ALLOC_HOST_SHARED +chmod 777 $NOMAD_ALLOC_HOST_SHARED + +docker run --privileged --rm -v /var/run/docker.sock:/var/run/docker.sock \ + -u $ASAPO_USER \ + --group-add `getent group docker | cut -d: -f3` \ + -v /var/lib/docker:/var/lib/docker \ + -v $NOMAD_ALLOC_HOST_SHARED:$NOMAD_ALLOC_HOST_SHARED \ + -e NOMAD_ALLOC_DIR=$NOMAD_ALLOC_HOST_SHARED \ + --name asapo --net=host -d yakser/asapo-nomad-cluster + diff --git a/deploy/asapo/scripts/provider.tf b/deploy/nomad_consul_docker/scripts/provider.tf similarity index 100% rename from deploy/asapo/scripts/provider.tf rename to deploy/nomad_consul_docker/scripts/provider.tf diff --git a/deploy/asapo/supervisord.conf b/deploy/nomad_consul_docker/supervisord.conf similarity index 100% rename from deploy/asapo/supervisord.conf rename to deploy/nomad_consul_docker/supervisord.conf diff --git a/deploy/nomad_consul/CMakeLists.txt b/deploy/nomad_consul_package/CMakeLists.txt similarity index 100% rename from deploy/nomad_consul/CMakeLists.txt rename to deploy/nomad_consul_package/CMakeLists.txt diff --git a/deploy/nomad_consul/Packages/CMakeLists.txt b/deploy/nomad_consul_package/Packages/CMakeLists.txt similarity index 100% rename from deploy/nomad_consul/Packages/CMakeLists.txt rename to deploy/nomad_consul_package/Packages/CMakeLists.txt diff --git a/deploy/nomad_consul/Packages/postinst b/deploy/nomad_consul_package/Packages/postinst similarity index 100% rename from deploy/nomad_consul/Packages/postinst rename to deploy/nomad_consul_package/Packages/postinst diff --git a/deploy/nomad_consul/usr/lib/systemd/system/consul.service b/deploy/nomad_consul_package/usr/lib/systemd/system/consul.service similarity index 100% rename from deploy/nomad_consul/usr/lib/systemd/system/consul.service rename to deploy/nomad_consul_package/usr/lib/systemd/system/consul.service diff --git a/deploy/nomad_consul/usr/lib/systemd/system/nomad.service b/deploy/nomad_consul_package/usr/lib/systemd/system/nomad.service similarity index 100% rename from deploy/nomad_consul/usr/lib/systemd/system/nomad.service rename to deploy/nomad_consul_package/usr/lib/systemd/system/nomad.service diff --git a/tests/automatic/consumer/consumer_api_python/consumer_api.py b/tests/automatic/consumer/consumer_api_python/consumer_api.py index a41756a876a87623e083cf823d2e3e75e052c038..f706f11ecd66f4fb353c6c1e52674d53dc923da4 100644 --- a/tests/automatic/consumer/consumer_api_python/consumer_api.py +++ b/tests/automatic/consumer/consumer_api_python/consumer_api.py @@ -187,7 +187,7 @@ def check_dataset(broker,group_id_new): source, path, beamtime, token, mode = sys.argv[1:] -broker = asapo_consumer.create_server_broker(source,path, beamtime,"",token,1000) +broker = asapo_consumer.create_server_broker(source,path, beamtime,"",token,5000) group_id_new = broker.generate_group_id() diff --git a/tests/automatic/settings/nginx.conf.tpl b/tests/automatic/settings/nginx.conf.tpl index 7d6c84e2c31bdf1294075dda2ad2c3d6245fba88..9fa1ba8ee13a3cb68ac54a09a4f7d1003531cfad 100644 --- a/tests/automatic/settings/nginx.conf.tpl +++ b/tests/automatic/settings/nginx.conf.tpl @@ -16,7 +16,7 @@ http { resolver 127.0.0.1:8600 valid=1s; server { - listen {{ env "NOMAD_PORT_nginx" }}; + listen {{ env "NOMAD_PORT_nginx" }} reuseport; set $discovery_endpoint discovery.service.asapo; set $authorizer_endpoint authorizer.service.asapo; set $fluentd_endpoint fluentd.service.asapo;