Skip to content

Commit

Permalink
Run config check in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrik committed Nov 16, 2023
1 parent fe73d1c commit 3103b98
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,43 @@ jobs:
- name: Build example bpf probes
run: make -j $(nproc) -C examples build

- name: Save built examples into examples.x86_64.tar.gz
run: tar -cvzf examples.x86_64.tar.gz -T <(find examples | grep -E "\.(yaml|bpf.o)$")

- name: Upload examples.x86_64.tar.gz
uses: actions/upload-artifact@v3
with:
name: examples.x86_64.tar.gz
path: examples.x86_64.tar.gz

check-configs-x86_64:
name: Check examples
runs-on: ubuntu-22.04
needs:
- build-ebpf-exporter-docker-x86_64
- build-examples-x86_64-built-in-libbpf
steps:
- uses: actions/checkout@v3

- name: Download examples.x86_64.tar.gz
uses: actions/download-artifact@v3
with:
name: examples.x86_64.tar.gz

- name: Extract examples.x86_64.tar.gz
run: tar -xzvf examples.x86_64.tar.gz

- name: Download ebpf_exporter.x86_64
uses: actions/download-artifact@v3
with:
name: ebpf_exporter.x86_64

- name: Put ebpf_exporter.x86_64 into place
run: mv ebpf_exporter.x86_64 ebpf_exporter && chmod +x ebpf_exporter

- name: Run configuration check
run: make config-check

clang-format:
name: Run clang-format check
runs-on: ubuntu-22.04
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ GO_LDFLAGS_VARS := -X $(BUILD_VAR_PREFIX).Version=$(BUILD_VERSION) \

CLANG_FORMAT_FILES = ${wildcard examples/*.c examples/*.h benchmark/probes/*.c benchmark/probes/*.h}

# * unix-socket-backlog requires a newer kernel than we have in ci
CONFIGS_TO_IGNORE_IN_CHECK := unix-socket-backlog
CONFIGS_TO_CHECK := $(filter-out $(CONFIGS_TO_IGNORE_IN_CHECK), ${patsubst examples/%.yaml, %, ${wildcard examples/*.yaml}})

export CGO_LDFLAGS := -l bpf

include Makefile.libbpf
Expand Down Expand Up @@ -53,6 +57,10 @@ test: $(LIBBPF_DEPS)
test-privileged:
sudo go test $(GO_TEST_ARGS) ./cgroup

.PHONY: config-check
config-check:
sudo ./ebpf_exporter --config.check --config.dir=examples --config.names=$(shell echo $(CONFIGS_TO_CHECK) | tr ' ' ',')

.PHONY: build
build: build-static

Expand Down
6 changes: 6 additions & 0 deletions cmd/ebpf_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
func main() {
configDir := kingpin.Flag("config.dir", "Config dir path.").Required().ExistingDir()
configNames := kingpin.Flag("config.names", "Comma separated names of configs to load.").Required().String()
configCheck := kingpin.Flag("config.check", "Check whether configs attach and exit.").Bool()
debug := kingpin.Flag("debug", "Enable debug.").Bool()
noLogTime := kingpin.Flag("log.no-timestamps", "Disable timestamps in log.").Bool()
listenAddress := kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests (fd://0 for systemd activation).").Default(":9435").String()
Expand Down Expand Up @@ -72,6 +73,11 @@ func main() {

log.Printf("Started with %d programs found in the config in %dms", len(configs), time.Since(started).Milliseconds())

if *configCheck {
log.Printf("Config check successful, exiting")
return
}

err = prometheus.Register(version.NewCollector("ebpf_exporter"))
if err != nil {
log.Fatalf("Error registering version collector: %s", err)
Expand Down

0 comments on commit 3103b98

Please sign in to comment.