Skip to content

Commit f37efa4

Browse files
[opampsupervisor] Add deb/rpm packages for the OpAMP supervisor (#1209)
* Add deb/rpm packages for the OpAMP supervisor Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Add changelog entry Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Fix nfpms contents paths The binaries are built with a different workdir when compared to the normal distributions. This seems like the simplest solution at the moment for me. Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Fix scripts paths in opampsupervisor CI Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Add package tests for the opamp supervisor Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Attempt to fix package tests CI for opampsupervisor Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Run opampsupervisor package tests only after ci Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Fix goreleaser artifact paths for opampsupervisor Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Fix artifacts and metadata path for opampsupervisor Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Upload opampsupervisor deb and rpm packages as artifacts Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Parameterize base package test binary name Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * More fixes to binary names for package tests Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Try to make the package test script work with the opampsupervisor Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Fix default package test binary name Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Bump rockylinux to 9.6 Trying to fix some issues in CI where all of the mirrors are returning 404s for the Rocky Linux packages. Example: ``` - Status code: 404 for http://mirrors.egr.msu.edu/rockylinux/9.6/AppStream/x86_64/os/repodata/160a783f-886f-4645-86b6-5c04d94522c9-MODULES.yaml.gz (IP: 35.9.37.146) ``` Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Use container manifest sha instead of index sha Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Get rockylinux from their official docker hub org Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Use short-form license header Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Use default kill mode for supervisor service Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Remove debug statements Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Remove package tests from opampsupervisor ci Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Add explanation for different path for supervisor nfpms Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Put bangs first because linter says so Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Retrigger build * Rename collector config file to avoid conflict It had the same name as the supervisor's Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> * Apply suggestion from @jackgopack4 Co-authored-by: John L. Peterson (Jack) <john.peterson@datadoghq.com> * Remove binary name arg for base package tests Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --------- Signed-off-by: Douglas Camata Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> Co-authored-by: John L. Peterson (Jack) <john.peterson@datadoghq.com>
1 parent 963fa0e commit f37efa4

File tree

12 files changed

+183
-1
lines changed

12 files changed

+183
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
5+
component: opampsupervisor
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Add .deb and .rpm packages release artifacts for the OpAMP supervisor
9+
10+
# One or more tracking issues or pull requests related to the change
11+
issues: [1209]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:
17+
18+
# Optional: The change log or logs in which this entry should be included.
19+
# e.g. '[user]' or '[user, api]'
20+
# Include 'user' if the change is relevant to end users.
21+
# Include 'api' if there is a change to a library API.
22+
# Default: '[user]'
23+
change_logs: [user]

.github/workflows/base-ci-binary.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ on:
1717
type: string
1818
default: ""
1919
description: "The collector dependency will be put into this folder"
20+
linux-packages:
21+
required: false
22+
type: boolean
23+
default: false
24+
description: "Set to true if linux packages should be uploaded as an artifact"
2025

2126
permissions:
2227
contents: read
@@ -79,3 +84,13 @@ jobs:
7984
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
8085
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8186
COSIGN_YES: false
87+
88+
- name: Upload linux service packages
89+
if: ${{ inputs.linux-packages == true }}
90+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
91+
with:
92+
name: linux-packages
93+
path: |
94+
dist/*amd64*.deb
95+
dist/*amd64*.rpm
96+
if-no-files-found: error

.github/workflows/ci-opampsupervisor.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ jobs:
3737
binary: opampsupervisor
3838
collector-dependency: 'open-telemetry/opentelemetry-collector-contrib'
3939
dependency-target-folder: '.contrib'
40+
linux-packages: true
4041
secrets: inherit
4142
permissions: write-all

cmd/goreleaser/internal/configure.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,23 @@ var (
222222
}).WithBinaryPackagingDefaults().
223223
WithBinaryMonorepo(".contrib/cmd/opampsupervisor").
224224
WithDefaultBinaryRelease(opampReleaseHeader).
225+
WithDefaultNfpms().
226+
// This is required because of same non-obvious path/workdir handling in
227+
// Github Actions specific to the binaries CI.
228+
WithConfigFunc(func(d *distribution) {
229+
d.nfpms[0].Contents = append(d.nfpms[0].Contents, config.NFPMContent{
230+
Source: "config.example.yaml",
231+
Destination: path.Join("/etc", d.name, "config.example.yaml"),
232+
Type: "config|noreplace",
233+
})
234+
for i, content := range d.nfpms[0].Contents {
235+
content.Source = path.Join("cmd", d.name, content.Source)
236+
d.nfpms[0].Contents[i] = content
237+
}
238+
d.nfpms[0].Scripts.PreInstall = path.Join("cmd", d.name, d.nfpms[0].Scripts.PreInstall)
239+
d.nfpms[0].Scripts.PostInstall = path.Join("cmd", d.name, d.nfpms[0].Scripts.PostInstall)
240+
d.nfpms[0].Scripts.PreRemove = path.Join("cmd", d.name, d.nfpms[0].Scripts.PreRemove)
241+
}).
225242
WithNightlyConfig().
226243
Build()
227244
)

cmd/opampsupervisor/.goreleaser.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,34 @@ builds:
5050
archives:
5151
- formats:
5252
- binary
53+
nfpms:
54+
- package_name: opampsupervisor
55+
contents:
56+
- src: cmd/opampsupervisor/opampsupervisor.service
57+
dst: /lib/systemd/system/opampsupervisor.service
58+
- src: cmd/opampsupervisor/opampsupervisor.conf
59+
dst: /etc/opampsupervisor/opampsupervisor.conf
60+
type: config|noreplace
61+
- src: cmd/opampsupervisor/config.example.yaml
62+
dst: /etc/opampsupervisor/config.example.yaml
63+
type: config|noreplace
64+
scripts:
65+
preinstall: cmd/opampsupervisor/preinstall.sh
66+
postinstall: cmd/opampsupervisor/postinstall.sh
67+
preremove: cmd/opampsupervisor/preremove.sh
68+
overrides:
69+
rpm:
70+
dependencies:
71+
- /bin/sh
72+
id: opampsupervisor
73+
ids:
74+
- opampsupervisor-linux
75+
formats:
76+
- deb
77+
- rpm
78+
maintainer: The OpenTelemetry Collector maintainers <cncf-opentelemetry-maintainers@lists.cncf.io>
79+
description: OpenTelemetry Collector - opampsupervisor
80+
license: Apache 2.0
5381
snapshot:
5482
version_template: '{{ .Tag }}-next'
5583
checksum:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
server:
2+
endpoint: "http://:4320/v1/opamp"
3+
headers:
4+
X-Auth: "some_token"
5+
tls:
6+
insecure_skip_verify: false
7+
8+
capabilities:
9+
reports_effective_config: true
10+
reports_own_metrics: true
11+
reports_own_logs: true
12+
reports_own_traces: true
13+
reports_health: true
14+
accepts_remote_config: true
15+
reports_remote_config: true
16+
17+
agent:
18+
executable: /etc/opampsupervisor/otelcol-contrib
19+
passthrough_logs: true
20+
21+
# This passes config files to the Collector.
22+
config_files:
23+
- /etc/opampsupervisor/collector.yaml
24+
25+
# This adds CLI arguments to the Collector.
26+
args: []
27+
28+
# This adds env vars to the Collector process.
29+
env: {}
30+
31+
# The storage can be used for many things:
32+
# - It stores configuration sent by the OpAMP server so that new collector
33+
# processes can start with the most known desired config.
34+
storage:
35+
directory: /var/lib/opampsupervisor/
36+
37+
telemetry:
38+
logs:
39+
level: debug
40+
output_paths:
41+
- /var/log/opampsupervisor/opampsupervisor.log
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Systemd environment file for the opampsupervisor service
2+
3+
# Command-line options for the opampsupervisor service.
4+
# Run `/usr/bin/opampsupervisor --help` to see all available options.
5+
OPAMP_OPTIONS="--config=/etc/opampsupervisor/config.yaml"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[Unit]
2+
Description=OpenTelemetry Collector OpAMP Supervisor
3+
After=network.target
4+
AssertPathExists=/etc/opampsupervisor/config.yaml
5+
6+
[Service]
7+
EnvironmentFile=/etc/opampsupervisor/opampsupervisor.conf
8+
ExecStart=/usr/bin/opampsupervisor $OPAMP_OPTIONS
9+
ExecReload=/bin/kill -HUP $MAINPID
10+
Restart=on-failure
11+
Type=simple
12+
User=opampsupervisor
13+
Group=opampsupervisor
14+
ConfigurationDirectory=opampsupervisor
15+
StateDirectory=opampsupervisor
16+
LogsDirectory=opampsupervisor
17+
18+
[Install]
19+
WantedBy=multi-user.target

cmd/opampsupervisor/postinstall.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
# Copyright The OpenTelemetry Authors
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
if command -v systemctl >/dev/null 2>&1; then
7+
if [ -d /run/systemd/system ]; then
8+
systemctl daemon-reload
9+
fi
10+
systemctl enable opampsupervisor.service
11+
if [ -f /etc/opampsupervisor/config.yaml ]; then
12+
if [ -d /run/systemd/system ]; then
13+
systemctl restart opampsupervisor.service
14+
fi
15+
fi
16+
fi

cmd/opampsupervisor/preinstall.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
# Copyright The OpenTelemetry Authors
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
getent passwd opampsupervisor >/dev/null || useradd --system --user-group --no-create-home --shell /sbin/nologin opampsupervisor

0 commit comments

Comments
 (0)