Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/telegraf:1.17-21.04-update into ~ubuntu-docker-images/ubuntu-docker-images/+git/telegraf:edge

Proposed by Sergio Durigan Junior
Status: Merged
Merge reported by: Sergio Durigan Junior
Merged at revision: 04d201f49fa30842568d5718822c1d68c2e8c830
Proposed branch: ~ubuntu-docker-images/ubuntu-docker-images/+git/telegraf:1.17-21.04-update
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/telegraf:edge
Diff against target: 126 lines (+35/-70)
2 files modified
Dockerfile (+35/-27)
dev/null (+0/-43)
Reviewer Review Type Date Requested Status
Bryce Harrington Approve
Lucas Kanashiro Pending
Canonical Server Pending
Review via email: mp+398912@code.launchpad.net

Description of the change

Update the telegraf OCI image to hirsute, convert it to deb-based, and generate the manifest.

To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

Looks good.

There's a git checkout of the utils module that I'm curious if that's supposed to be there. But other than that the rest looks good.

review: Approve
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thansk Bryce. Yeah, the utils repository is where the golang-manifest-builder script lives, so we have to check it out first. Arguably I could use a wget directly instead, but I opted for the easier way.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Dockerfile b/Dockerfile
2index 97b39b7..2f858b1 100644
3--- a/Dockerfile
4+++ b/Dockerfile
5@@ -1,37 +1,45 @@
6-FROM ubuntu:focal AS builder
7-
8-COPY . .
9+FROM ubuntu:hirsute AS manifest-builder
10
11 WORKDIR /src/telegraf
12
13-RUN apt-get update \
14- && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
15- && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git dpkg-dev ca-certificates pristine-tar \
16- && git clone https://git.launchpad.net/~ubuntu-server/ubuntu/+source/telegraf \
17- && cd telegraf \
18- && git branch pristine-tar origin/pristine-tar \
19- && git checkout focal \
20- && cp -a /adjust-telegraf-conf.patch debian/patches \
21- && echo "adjust-telegraf-conf.patch" >> debian/patches/series \
22- && sed -i 's@^EXCLUDE_TESTS.*@EXCLUDE_TESTS = github.com/influxdata/telegraf/plugins/inputs/http_response \
23-github.com/influxdata/telegraf/plugins/inputs/zipkin \
24-github.com/influxdata/telegraf/plugins/outputs/prometheus_client \\@' debian/rules \
25- && pristine-tar checkout ../telegraf_$(dpkg-parsechangelog -SVersion | sed 's/\(.*\)-.ubuntu.*/\1/').orig.tar.xz \
26- && DEBIAN_FRONTEND=noninteractive apt-get build-dep . -y \
27- && dpkg-buildpackage -us -uc
28-
29-FROM ubuntu:focal
30+RUN set -eux; \
31+ grep '^deb ' /etc/apt/sources.list | sed 's/^deb/deb-src/' >> /etc/apt/sources.list; \
32+ DEBIAN_FRONTEND=noninteractive apt-get update; \
33+ DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y; \
34+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
35+ dpkg-dev golang-go git python3 python3-lxml python3-requests; \
36+ apt-get source telegraf; \
37+ git clone https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/utils; \
38+ cd telegraf*/vendor; \
39+# We have to use -mod=mod because "go list -m all" (from hirsute)
40+# doesn't work with vendorized deps.
41+#
42+# https://github.com/golang/go/issues/35224
43+# https://bugs.launchpad.net/docker.io/+bug/1916296
44+ go list -mod=mod -m all | tail -n +2 > /src/telegraf/telegraf-mods.txt; \
45+ /src/telegraf/utils/golang-manifest-builder.py /src/telegraf/telegraf-mods.txt | tee /src/telegraf/manifest-upstream.txt
46+
47+FROM ubuntu:hirsute
48
49 ENV TZ UTC
50
51-COPY --from=builder /src/telegraf/telegraf*.deb /pkg/
52-
53-RUN apt-get update \
54- && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
55- && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends /pkg/telegraf*.deb tzdata \
56+RUN set -eux; \
57+ apt-get update; \
58+ DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y; \
59+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
60+ telegraf tzdata; \
61 # We don't need to keep the .deb packages around
62- && rm -rf /pkg \
63- && rm -rf /var/lib/apt/lists/*
64+ rm -rf /pkg; \
65+ rm -rf /var/lib/apt/lists/*; \
66+# smoke test
67+ telegraf --version; \
68+# create manifest
69+ mkdir -p /usr/share/rocks; \
70+ (echo "# os-release" && cat /etc/os-release && echo "# dpkg-query" && dpkg-query -f '${db:Status-Abbrev},${binary:Package},${Version},${source:Package},${Source:Version}\n' -W) > /usr/share/rocks/dpkg.query
71+
72+# telegraf is "special" because we have a dpkg.query for it, but also
73+# the list of Golang modules needed to build the .deb.
74+COPY --from=manifest-builder /src/telegraf/manifest-upstream.txt /usr/share/rocks/upstream
75
76 EXPOSE 9273
77 ENTRYPOINT [ "/usr/bin/telegraf" ]
78diff --git a/adjust-telegraf-conf.patch b/adjust-telegraf-conf.patch
79deleted file mode 100644
80index d081fb2..0000000
81--- a/adjust-telegraf-conf.patch
82+++ /dev/null
83@@ -1,43 +0,0 @@
84-Author: Sergio Durigan Junior <sergio.durigan@canonical.com>
85-
86-A few adjustments needed to:
87-
88- - Disable outputs.influxdb, which, if enabled, will pollute the logs
89- if influxdb is not installed.
90- - Enable outputs.prometheus_client.
91-
92-diff --git a/etc/telegraf.conf b/etc/telegraf.conf
93-index 62bc616..6439457 100644
94---- a/etc/telegraf.conf
95-+++ b/etc/telegraf.conf
96-@@ -102,7 +102,7 @@
97-
98-
99- # Configuration for sending metrics to InfluxDB
100--[[outputs.influxdb]]
101-+#[[outputs.influxdb]]
102- ## The full HTTP or UDP URL for your InfluxDB instance.
103- ##
104- ## Multiple URLs can be specified for a single cluster, only ONE of the
105-@@ -1118,17 +1119,17 @@
106-
107-
108- # # Configuration for the Prometheus client to spawn
109--# [[outputs.prometheus_client]]
110-+[[outputs.prometheus_client]]
111- # ## Address to listen on
112--# listen = ":9273"
113--#
114-+ listen = "127.0.0.1:9273"
115-+
116- # ## Metric version controls the mapping from Telegraf metrics into
117- # ## Prometheus format. When using the prometheus input, use the same value in
118- # ## both plugins to ensure metrics are round-tripped without modification.
119- # ##
120- # ## example: metric_version = 1; deprecated in 1.13
121- # ## metric_version = 2; recommended version
122--# # metric_version = 1
123-+ metric_version = 2
124- #
125- # ## Use HTTP Basic Authentication.
126- # # basic_username = "Foo"

Subscribers

People subscribed via source and target branches

to all changes: