From 8acc2f6fe0b1b8d068c9bc121a4f6f6a1475b4ee Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Mon, 18 Jun 2018 17:42:02 +0200 Subject: [PATCH] Modify upstream for the CD auto build Signed-off-by: Simon Pasquier --- .promu.yml | 1 + Dockerfile.rhel7 | 17 ++++ Makefile.common | 10 +- golang-github-prometheus-alertmanager.spec | 110 +++++++++++++++++++++ prometheus-alertmanager.service | 13 +++ prometheus-alertmanager.sysconfig | 16 +++ 6 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.rhel7 create mode 100644 golang-github-prometheus-alertmanager.spec create mode 100644 prometheus-alertmanager.service create mode 100644 prometheus-alertmanager.sysconfig diff --git a/.promu.yml b/.promu.yml index 905e6dd9b4..a23d8c4624 100644 --- a/.promu.yml +++ b/.promu.yml @@ -8,6 +8,7 @@ build: path: ./cmd/amtool flags: -a -tags netgo ldflags: | + -s -X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}} -X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}} -X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}} diff --git a/Dockerfile.rhel7 b/Dockerfile.rhel7 new file mode 100644 index 0000000000..720300aadf --- /dev/null +++ b/Dockerfile.rhel7 @@ -0,0 +1,17 @@ +FROM rhel7:7-released +LABEL maintainer="OpenShift Development " \ + com.redhat.component="golang-github-prometheus-alertmanager-docker" \ + name="openshift3/prometheus-alertmanager" \ + version="v0.15.0" \ + architecture=x86_64 + +RUN yum-config-manager --enable rhel-7-server-ose-3.9-rpms && \ + yum install -y prometheus-alertmanager && \ + yum clean all + +EXPOSE 9093 +WORKDIR /alertmanager +VOLUME [ "/alertmanager" ] +ENTRYPOINT [ "/bin/alertmanager" ] +CMD [ "--config.file=/etc/alertmanager/config.yml", \ + "--storage.path=/alertmanager" ] diff --git a/Makefile.common b/Makefile.common index eaee9f0b91..256cef60ec 100644 --- a/Makefile.common +++ b/Makefile.common @@ -28,7 +28,11 @@ unexport GOBIN GO ?= go GOFMT ?= $(GO)fmt FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) -PROMU := $(FIRST_GOPATH)/bin/promu +ifeq ($(BUILD_PROMU),false) + PROMU := promu +else + PROMU := $(FIRST_GOPATH)/bin/promu +endif STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck GOVENDOR := $(FIRST_GOPATH)/bin/govendor pkgs = ./... @@ -102,7 +106,11 @@ docker: .PHONY: promu promu: +ifeq ($(BUILD_PROMU),false) + @echo "using installed promu $(shell which promu)" +else GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu +endif .PHONY: $(STATICCHECK) $(STATICCHECK): diff --git a/golang-github-prometheus-alertmanager.spec b/golang-github-prometheus-alertmanager.spec new file mode 100644 index 0000000000..1ef7c41c6a --- /dev/null +++ b/golang-github-prometheus-alertmanager.spec @@ -0,0 +1,110 @@ + +%global debug_package %{nil} + +%global provider github +%global provider_tld com +%global project prometheus +%global repo alertmanager +# https://github.com/prometheus/alertmanager +%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} +%global import_path %{provider_prefix} +# %commit is intended to be set by tito. The values in this spec file will not be kept up to date. +%{!?commit: +%global commit 5e86f61bd73c6325d6049ab3dbcb468ede26dfe0 +} +%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%global gopathdir %{_sourcedir}/go +%global upstream_ver 0.15.0 +%global rpm_ver %(v=%{upstream_ver}; echo ${v//-/_}) +%global download_prefix %{provider}.%{provider_tld}/openshift/%{repo} + +Name: golang-%{provider}-%{project}-%{repo} +# Version and release information will be automatically managed by CD +# It will be kept in sync with OCP builds. +Version: %{rpm_ver} +Release: 1.git%{shortcommit}%{?dist} +Summary: The Prometheus Alertmanager handles alerts sent by client applications such as the Prometheus server. +License: ASL 2.0 +URL: https://prometheus.io/ +Source0: https://%{download_prefix}/archive/%{commit}/%{repo}-%{commit}.tar.gz + +# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required +# promu-based packages FTBFS on aarch64 (#1487462) +ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm} ppc64le s390x} +# If go_compiler is not set to 1, there is no virtual provide. Use golang instead. +BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} +BuildRequires: glibc-static +BuildRequires: prometheus-promu + +%description +%{summary} + +%package -n %{project}-alertmanager +Summary: %{summary} +Provides: prometheus-alertmanager = %{version}-%{release} +Obsoletes: prometheus-alertmanager < %{version}-%{release} + +%description -n %{project}-alertmanager +%{summary} + +%prep +%setup -q -n %{repo}-%{commit} + +%build +# Go expects a full path to the sources which is not included in the source +# tarball so create a link with the expected path +mkdir -p %{gopathdir}/src/%{provider}.%{provider_tld}/%{project} +GOSRCDIR=%{gopathdir}/src/%{import_path} +if [ ! -e "$GOSRCDIR" ]; then + ln -s `pwd` "$GOSRCDIR" +fi +export GOPATH=%{gopathdir} + +make build BUILD_PROMU=false + +%install +install -d %{buildroot}%{_bindir} +install -D -p -m 0755 alertmanager %{buildroot}%{_bindir}/alertmanager +install -D -p -m 0755 amtool %{buildroot}%{_bindir}/amtool +install -D -p -m 0644 doc/examples/simple.yml \ + %{buildroot}%{_sysconfdir}/prometheus/alertmanager.yml +install -D -p -m 0644 prometheus-alertmanager.service \ + %{buildroot}%{_unitdir}/prometheus-alertmanager.service +install -D -p -m 0644 prometheus-alertmanager.sysconfig \ + %{buildroot}%{_sysconfdir}/sysconfig/prometheus-alertmanager +install -d %{buildroot}%{_sharedstatedir}/prometheus-alertmanager + +%files -n %{project}-alertmanager +%license LICENSE NOTICE +%doc CHANGELOG.md CONTRIBUTING.md MAINTAINERS.md README.md +%{_bindir}/alertmanager +%{_bindir}/amtool +%{_sysconfdir}/prometheus/alertmanager.yml +%{_unitdir}/prometheus-alertmanager.service +%{_sysconfdir}/sysconfig/prometheus-alertmanager +%{_sharedstatedir}/prometheus-alertmanager + +%changelog +* Mon Jun 18 2018 Simon Pasquier - 0.15.0-1 +- Upgrade to 0.15.0 + +* Tue Feb 13 2018 Simon Pasquier - 0.14.0-1 +- Upgrade to 0.14.0 + +* Wed Jan 31 2018 Paul Gier - 0.13.0-1 +- Upgrade to 0.13.0 and include amtool + +* Thu Jan 18 2018 Simon Pasquier - 0.12.0-1 +- Upgrade to 0.12.0 + +* Wed Jan 10 2018 Yaakov Selkowitz - 0.9.1-3 +- Rebuilt for ppc64le, s390x enablement + +* Wed Nov 08 2017 Paul Gier - 0.9.1-2 +- upgrade to 0.9.1 + +* Fri Sep 01 2017 Paul Gier - 0.8.0-2 +- Strip debug and remove duplicate package + +* Fri Aug 25 2017 Paul Gier - 0.8.0-1 +- First package for Openshift diff --git a/prometheus-alertmanager.service b/prometheus-alertmanager.service new file mode 100644 index 0000000000..02605894d8 --- /dev/null +++ b/prometheus-alertmanager.service @@ -0,0 +1,13 @@ +[Unit] +Description=Prometheus Alertmanager handling alerts sent by client applications such as the Prometheus server. +Documentation=https://github.com/prometheus/alertmanager + +[Service] +Type=simple +EnvironmentFile=-/etc/sysconfig/prometheus-alertmanager +ExecStart=/usr/bin/alertmanager $CONFIG_FILE $STORAGE_PATH $CLUSTER_PEERS $OTHER_ARGS +ExecReload=/bin/kill -SIGHUP $MAINPID +ExecStop=/bin/kill -SIGKILL $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/prometheus-alertmanager.sysconfig b/prometheus-alertmanager.sysconfig new file mode 100644 index 0000000000..e8a83ccef1 --- /dev/null +++ b/prometheus-alertmanager.sysconfig @@ -0,0 +1,16 @@ +# This is a systemd environment file which provides arguments to the systemd +# prometheus alertmanager service. +# For more info see: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile= + +# The location of the configuration file. +CONFIG_FILE="--config.file=/etc/prometheus/alertmanager.yml" + +# The path for storing data. +STORAGE_PATH="--storage.path=/var/lib/prometheus-alertmanager" + +# The list of peers to connect to. +# CLUSTER_PEERS="--cluster.peer=peer1:9094 --cluster.peer=peer2:9094" +CLUSTER_PEERS="" + +# Other arguments. +OTHER_ARGS=""