diff --git a/.zuul.yaml b/.zuul.yaml index d60a8f4375..6176e9d7cd 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -131,6 +131,33 @@ vars: *gitea_vars files: *gitea_files +# Haproxy-statsd jobs +- job: + name: system-config-build-image-haproxy-statsd + description: Build a haproxy-statsd image. + parent: system-config-build-image + vars: &haproxy-statsd_vars + docker_images: + - context: docker/haproxy-statsd + repository: opendevorg/haproxy-statsd + # Duplicate in the run-gitea job + files: &haproxy-statsd_files + - docker/haproxy-statsd/.* + +- job: + name: system-config-upload-image-haproxy-statsd + description: Build and upload a haproxy-statsd image. + parent: system-config-upload-image + vars: *haproxy-statsd_vars + files: *haproxy-statsd_files + +- job: + name: system-config-promote-image-haproxy-statsd + description: Promote a previously published haproxy-statsd image to latest. + parent: system-config-promote-image + vars: *haproxy-statsd_vars + files: *haproxy-statsd_files + # Gerrit jobs - job: name: system-config-build-image-gerrit @@ -580,6 +607,9 @@ # From gitea_files -- If we rebuild the image, we want to run # this job as well. - docker/gitea/.* + # From haproxy-statsd_files -- If we rebuild the image, we want + # to run this job as well. + - docker/haproxy-statsd/.* - job: name: system-config-run-zuul-preview @@ -651,12 +681,15 @@ dependencies: - name: system-config-build-image-gitea soft: true + - name: system-config-build-image-haproxy-statsd + soft: true - system-config-run-zuul-preview - system-config-run-letsencrypt - system-config-build-image-jinja-init - system-config-build-image-gitea-init - system-config-build-image-gitea - system-config-build-image-gerrit + - system-config-build-image-haproxy-statsd - system-config-build-image-python-base - system-config-build-image-python-builder gate: @@ -674,12 +707,15 @@ dependencies: - name: system-config-upload-image-gitea soft: true + - name: system-config-upload-image-haproxy-statsd + soft: true - system-config-run-zuul-preview - system-config-run-letsencrypt - system-config-upload-image-jinja-init - system-config-upload-image-gitea-init - system-config-upload-image-gitea - system-config-upload-image-gerrit + - system-config-upload-image-haproxy-statsd - system-config-upload-image-python-base - system-config-upload-image-python-builder promote: @@ -688,5 +724,6 @@ - system-config-promote-image-gitea-init - system-config-promote-image-gitea - system-config-promote-image-gerrit + - system-config-promote-image-haproxy-statsd - system-config-promote-image-python-base - system-config-promote-image-python-builder diff --git a/docker/haproxy-statsd/Dockerfile b/docker/haproxy-statsd/Dockerfile new file mode 100644 index 0000000000..e65152af26 --- /dev/null +++ b/docker/haproxy-statsd/Dockerfile @@ -0,0 +1,20 @@ +# Copyright (c) 2019 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM opendevorg/python-base + +COPY haproxy-statsd.py /usr/local/bin +RUN pip install statsd +CMD ["/usr/local/bin/haproxy-statsd.py"] diff --git a/modules/openstack_project/files/git/haproxy-statsd.py b/docker/haproxy-statsd/haproxy-statsd.py old mode 100644 new mode 100755 similarity index 99% rename from modules/openstack_project/files/git/haproxy-statsd.py rename to docker/haproxy-statsd/haproxy-statsd.py index 73b8cabb58..169b304211 --- a/modules/openstack_project/files/git/haproxy-statsd.py +++ b/docker/haproxy-statsd/haproxy-statsd.py @@ -179,5 +179,5 @@ class HAProxy(object): logging.basicConfig(level=logging.DEBUG) -p = HAProxy('/var/lib/haproxy/stats') +p = HAProxy('/var/haproxy/run/stats') p.run() diff --git a/modules/openstack_project/files/git/haproxy-statsd.default b/modules/openstack_project/files/git/haproxy-statsd.default deleted file mode 100644 index 8ab3f71202..0000000000 --- a/modules/openstack_project/files/git/haproxy-statsd.default +++ /dev/null @@ -1,2 +0,0 @@ -STATSD_HOST=graphite.opendev.org -STATSD_PORT=8125 diff --git a/modules/openstack_project/files/git/haproxy-statsd.service b/modules/openstack_project/files/git/haproxy-statsd.service deleted file mode 100644 index 270a5a7135..0000000000 --- a/modules/openstack_project/files/git/haproxy-statsd.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=haproxy-statsd -After=haproxy.service - -[Service] -ExecStart=/usr/local/bin/haproxy-statsd.py -EnvironmentFile=/etc/default/haproxy-statsd - -[Install] -WantedBy=multi-user.target diff --git a/playbooks/group_vars/graphite.yaml b/playbooks/group_vars/graphite.yaml index 9535f1f750..005a6ea59b 100644 --- a/playbooks/group_vars/graphite.yaml +++ b/playbooks/group_vars/graphite.yaml @@ -2,7 +2,7 @@ iptables_extra_allowed_hosts: - hostname: bridge.openstack.org port: 8125 protocol: udp - - hostname: git.openstack.org + - hostname: opendev.org port: 8125 protocol: udp - hostname: firehose01.openstack.org diff --git a/playbooks/roles/haproxy/files/docker/docker-compose.yaml b/playbooks/roles/haproxy/files/docker/docker-compose.yaml index eff4cd2e1c..efa7166132 100644 --- a/playbooks/roles/haproxy/files/docker/docker-compose.yaml +++ b/playbooks/roles/haproxy/files/docker/docker-compose.yaml @@ -10,3 +10,12 @@ services: volumes: - /var/haproxy/etc:/usr/local/etc/haproxy - /var/haproxy/run:/var/haproxy/run + haproxy-statsd: + restart: always + image: opendevorg/haproxy-statsd:latest + network_mode: host + volumes: + - /var/haproxy/run:/var/haproxy/run + environment: + STATSD_HOST: graphite.opendev.org + STATSD_PORT: 8125 diff --git a/testinfra/test_gitea_lb.py b/testinfra/test_gitea_lb.py index e330a8e7f6..c7cce56a87 100644 --- a/testinfra/test_gitea_lb.py +++ b/testinfra/test_gitea_lb.py @@ -12,6 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +import json + testinfra_hosts = ['gitea-lb01.opendev.org'] @@ -21,3 +23,9 @@ def test_gitea_listening(host): assert gitea_https.is_listening gitea_http = host.socket("tcp://0.0.0.0:80") assert gitea_http.is_listening + +def test_haproxy_statsd_running(host): + cmd = host.run("docker inspect haproxydocker_haproxy-statsd_1") + out = json.loads(cmd.stdout) + assert out[0]["State"]["Status"] == "running" + assert out[0]["RestartCount"] == 0