-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build a Snap package from source #17328
Draft
ralphm
wants to merge
7
commits into
master
Choose a base branch
from
snap-build
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
351864c
Build Netdata Agent Snap from source
ralphm a1fc979
Switch to using cmake directly.
ralphm 55b2e24
Bundle eBPF
ralphm 2b9b95d
Add initial GitHub action to build snap
ralphm 9c83833
Run this new workflow
ralphm 96c798b
Check out submodules in GitHub action
ralphm 072fc16
Fix indentation, set default retention to 7 days
ralphm File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Snap | ||
on: | ||
push: | ||
branches: | ||
- "snap-build" | ||
workflow_dispatch: | ||
inputs: | ||
retention: | ||
description: Retention Days | ||
default: 1 | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- uses: snapcore/action-build@v1 | ||
id: snapcraft | ||
with: | ||
snapcraft-args: --verbosity debug | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: snap | ||
path: ${{ steps.snapcraft.outputs.snap }} | ||
retention-days: ${{ github.event.inputs.retention || 7 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Initialize configuration and var directory skeleton | ||
mkdir -p "$SNAP_COMMON/etc" | ||
mkdir -p "$SNAP_DATA/var/cache" | ||
mkdir -p "$SNAP_DATA/var/lib" | ||
mkdir -p "$SNAP_DATA/var/log/netdata" | ||
cp -rp "$SNAP/etc/netdata" "$SNAP_COMMON/etc/netdata" | ||
cp -rp "$SNAP/var/cache/netdata" "$SNAP_DATA/var/cache/netdata" | ||
cp -rp "$SNAP/var/lib/netdata" "$SNAP_DATA/var/lib/netdata" | ||
mkdir -p "$SNAP_DATA/var/lib/netdata/www" | ||
mkdir -p "$SNAP_DATA/var/run/netdata" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[directories] | ||
config = /var/snap/netdata/common/etc/netdata | ||
log = /var/snap/netdata/current/var/log/netdata | ||
cache = /var/snap/netdata/current/var/cache/netdata | ||
lib = /var/snap/netdata/current/var/lib/netdata | ||
home = /var/snap/netdata/current/var/lib/netdata | ||
|
||
[plugin:proc] | ||
# Disable btrfs, as this cannot be accessed from within a snap | ||
/sys/fs/btrfs = no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
name: netdata # you probably want to 'snapcraft register <name>' | ||
base: core24 # the base snap is the execution environment for this snap | ||
build-base: devel | ||
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' | ||
summary: Netdata Agent | ||
description: | | ||
Netdata is distributed, real-time, performance and health monitoring for | ||
systems and applications. It provides insights of everything happening on the | ||
systems it runs using interactive web dashboards. | ||
|
||
grade: devel # must be 'stable' to release into candidate/stable channels | ||
confinement: strict # use 'strict' once you have the right plugs and slots | ||
|
||
layout: | ||
# /etc/netdata: | ||
# symlink: $SNAP_COMMON/etc/netdata | ||
# /usr/lib/netdata: | ||
# symlink: $SNAP/usr/lib/netdata | ||
# /usr/libexec/netdata: | ||
# symlink: $SNAP/usr/libexec/netdata | ||
# /usr/share/netdata: | ||
# symlink: $SNAP/usr/share/netdata | ||
# /var/cache/netdata: | ||
# symlink: $SNAP_DATA/var/cache/netdata | ||
# /var/lib/netdata: | ||
# symlink: $SNAP_DATA/var/lib/netdata | ||
# /var/log/netdata: | ||
# symlink: $SNAP_DATA/var/log/netdata | ||
/etc/sensors3.conf: | ||
symlink: $SNAP/etc/sensors3.conf | ||
/usr/bin/lsns: | ||
bind-file: $SNAP/usr/bin/lsns | ||
|
||
parts: | ||
deps: | ||
plugin: nil | ||
source: . | ||
source-type: local | ||
override-build: | | ||
packaging/installer/install-required-packages.sh --dont-wait --non-interactive -i netdata-all | ||
|
||
|
||
netdata: | ||
plugin: cmake | ||
source: . | ||
source-type: local | ||
build-environment: | ||
- CFLAGS: ${CFLAGS:-"-O2 pipe"} | ||
- DESTDIR: $CRAFT_PART_INSTALL | ||
build-packages: | ||
- golang-1.21-go | ||
- libbrotli-dev | ||
- libcap-dev | ||
- libcups2-dev | ||
- libipmimonitoring-dev | ||
- libmongoc-dev | ||
- libnetfilter-acct-dev | ||
- libpcre2-dev | ||
- libprotobuf-dev | ||
- libsnappy-dev | ||
- libxen-dev | ||
- protobuf-compiler | ||
cmake-generator: Ninja | ||
cmake-parameters: | ||
- -DCMAKE_INSTALL_PREFIX=/snap/netdata/current | ||
- -DENABLE_ACLK=On | ||
- -DENABLE_CLOUD=On | ||
- -DENABLE_DBENGINE=On | ||
- -DENABLE_H2O=On | ||
- -DENABLE_ML=On | ||
- -DENABLE_PLUGIN_APPS=On | ||
- -DENABLE_PLUGIN_CGROUP_NETWORK=On | ||
- -DENABLE_PLUGIN_DEBUGFS=On | ||
- -DENABLE_PLUGIN_EBPF=On | ||
- -DENABLE_PLUGIN_FREEIPMI=On | ||
- -DENABLE_PLUGIN_GO=On | ||
- -DENABLE_PLUGIN_LOCAL_LISTENERS=On | ||
- -DENABLE_PLUGIN_LOGS_MANAGEMENT=On | ||
- -DENABLE_PLUGIN_NFACCT=On | ||
- -DENABLE_PLUGIN_PERF=On | ||
- -DENABLE_PLUGIN_SLABINFO=On | ||
- -DENABLE_PLUGIN_SYSTEMD_JOURNAL=On | ||
- -DENABLE_PLUGIN_XENSTAT=On | ||
- -DENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE=On | ||
- -DENABLE_EXPORTER_MONGODB=On | ||
- -DENABLE_BUNDLED_PROTOBUF=Off | ||
- -DENABLE_BUNDLED_JSONC=Off | ||
# - ${SENTRY_CONFIG} | ||
- -DENABLE_BUNDLED_YAML=Off | ||
override-build: | | ||
"${CRAFT_PART_SRC}/packaging/bundle-libbpf.sh" "${CRAFT_PART_SRC}" "${CRAFT_PART_INSTALL}/usr/libexec/netdata/plugins.d" | ||
"${CRAFT_PART_SRC}/packaging/bundle-ebpf-co-re.sh" "${CRAFT_PART_SRC}" "${CRAFT_PART_INSTALL}/usr/libexec/netdata/plugins.d" | ||
update-alternatives --install /usr/bin/go go /usr/lib/go-1.21/bin/go 3 | ||
update-alternatives --install /usr/bin/gofmt gofmt /usr/lib/go-1.21/bin/gofmt 3 | ||
craftctl default | ||
mkdir -p "$CRAFT_PART_INSTALL/etc/netdata" | ||
cp -p "$CRAFT_PART_SRC/snap/local/netdata.conf" "$CRAFT_PART_INSTALL/etc/netdata/netdata.conf" | ||
organize: | ||
"snap/netdata/current": "/" | ||
stage-packages: | ||
- apcupsd | ||
- curl | ||
- iproute2 | ||
- iw | ||
- libatm1 | ||
- libavahi-client3 | ||
- libavahi-common3 | ||
- libbson-1.0-0 | ||
- libcups2 | ||
- libfreeipmi17 | ||
- libipmimonitoring6 | ||
- libmongoc-1.0-0 | ||
- libmongocrypt0 | ||
- libnetfilter-acct1 | ||
- libsnappy1v5 | ||
- libutf8proc3 | ||
- libuv1 | ||
- libxencall1 | ||
- libxendevicemodel1 | ||
- libxenevtchn1 | ||
- libxenforeignmemory1 | ||
- libxengnttab1 | ||
- libxenhypfs1 | ||
- libxenmisc4.17 | ||
- libxenstore4 | ||
- libxentoolcore1 | ||
- libxentoollog1 | ||
- libyajl2 | ||
- lm-sensors | ||
- nvme-cli | ||
- util-linux | ||
prime: | ||
- -snap/netdata | ||
|
||
ebpf-kernel-collector: | ||
plugin: nil | ||
source: . | ||
source-type: local | ||
override-pull: | | ||
craftctl default | ||
NETDATA_PLUGINDIR=$CRAFT_PART_INSTALL/usr/libexec/netdata/plugins.d | ||
mkdir -p "${NETDATA_PLUGINDIR}" | ||
sh -x "${CRAFT_PART_SRC}/packaging/bundle-ebpf.sh" "${CRAFT_PART_SRC}" "${NETDATA_PLUGINDIR}" force | ||
|
||
apps: | ||
agent: | ||
command: usr/sbin/netdata -u root -D -P $SNAP_DATA/var/run/netdata/netdata.pid -c $SNAP_COMMON/etc/netdata/netdata.conf | ||
daemon: simple | ||
plugs: | ||
- docker-support # Allows access to /prod/[0-9]*/limits | ||
- hardware-observe | ||
- kubernetes-support # cgroups (incl. systemd services) | ||
- log-observe | ||
- login-session-observe | ||
- mount-observe | ||
- network | ||
- network-bind | ||
- network-observe # network connections function | ||
- network-setup-observe # ip{,4,6}.*, wireless.*, netfilter.conntrack_sockets | ||
- system-observe # many disk.*, cpu and memory pressure, system.io | ||
- time-control # needed for timex to call clock_adjtime to measure jitter | ||
claim: | ||
command: usr/sbin/netdata-claim.sh | ||
plugs: | ||
- network | ||
cli: | ||
command: usr/sbin/netdatacli | ||
log2journal: | ||
command: usr/sbin/log2journal | ||
systemd-cat-native: | ||
command: usr/sbin/systemd-cat-native |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think it’s possible for a Snap package to access the required interfaces for this plugin to work, no matter what connections are made, so we should probably just disable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean Xen specifically? Yeah, I haven't gotten to testing that and will indeed disable it if that is indeed the case.
Fortunately, many things do work. I'm currently trying to get eBPF working properly, but here too, some interfaces don't appear to be exposed and may require putting in a ticket with snapd.