Skip to content
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

feat: OpAMP Package Update functionality #616

Merged
merged 30 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
40de72d
feat: Add windows service definition to archive (#515)
BinaryFissionGames Jun 23, 2022
2638f9d
feat: Create Updater artifact (#529)
BinaryFissionGames Jun 28, 2022
06a8714
feat: Add tarball download + unarchiving to updater (#538)
BinaryFissionGames Jul 1, 2022
3bc34f4
feat: Added OpAMP PackageStatuses functionality & basic response to P…
StefanKurek Jul 12, 2022
be6df51
feat: Add ability to install unpacked artifacts in updater (#562)
BinaryFissionGames Jul 13, 2022
34d3207
Moved code to download, verify, and extract OpAMP package file from u…
StefanKurek Jul 14, 2022
562546e
OpAmp Package Update Glue (#567)
StefanKurek Jul 18, 2022
d2cfc03
Moved package install function to goroutine
StefanKurek Jul 18, 2022
b63bcdd
Add mutex for updatingClient flag in client (#570)
StefanKurek Jul 19, 2022
207f8d1
Created packagestate module (#579)
Jul 20, 2022
c974021
feat: Updater rollback (#584)
BinaryFissionGames Jul 26, 2022
6f04097
feat: Updater logging (#589)
BinaryFissionGames Jul 26, 2022
3902691
feat: Collector starts up Updater (#590)
StefanKurek Jul 27, 2022
1ab5a3b
Fixed go.sum
Jul 27, 2022
9f1d086
feat: Remove tmpdir from updater (#591)
BinaryFissionGames Jul 27, 2022
421ff8a
Fixed name of package updater looks at (#592)
Jul 28, 2022
ce4ab89
feat: Copy updater executable to CWD of collector before executing (#…
BinaryFissionGames Jul 28, 2022
9eb4ec3
fix: Windows updater log fix (#595)
BinaryFissionGames Jul 28, 2022
5cf413c
feat: Updater cleans up temporary directory (#596)
BinaryFissionGames Jul 28, 2022
47e08f4
fix: Pass install dir into service (#598)
BinaryFissionGames Jul 28, 2022
133ed52
Updater properly installs and rollbacks JMX Jar. (#600)
StefanKurek Jul 29, 2022
0aa145e
feat: Harden collector shutdown while updating (#597)
BinaryFissionGames Aug 1, 2022
f3340dd
fix: If the collector detects an error updating, clean temporary dire…
BinaryFissionGames Aug 1, 2022
b5ad5f2
Updated Makefile & GitHub Action workflow so Updater binary has licen…
StefanKurek Aug 1, 2022
da1b299
Fixes tmp dir for update to have 0700 permissions (#609)
StefanKurek Aug 3, 2022
76c0ef4
fix(updater): Do Update in place for windows service (#605)
BinaryFissionGames Aug 3, 2022
9fd9d40
feat: Refactor updater main (#608)
BinaryFissionGames Aug 3, 2022
f837886
fix(updater): Enable debug logs (#613)
BinaryFissionGames Aug 4, 2022
fb95c4d
feat: Refactor Updater's file package (#611)
BinaryFissionGames Aug 4, 2022
dffea4e
Added better logging/messaging around collector package updating (#614)
StefanKurek Aug 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,21 @@ updates:
commit-message:
prefix: "deps"
include: "scope"
- package-ecosystem: "gomod"
directory: "/updater"
schedule:
interval: "weekly"
ignore:
# Opentelemetry updates will be done manually
- dependency-name: "github.com/open-telemetry/opentelemetry-collector*"
- dependency-name: "go.opentelemetry.io/collector/*"
commit-message:
prefix: "deps"
include: "scope"
- package-ecosystem: "gomod"
directory: "/packagestate"
schedule:
interval: "weekly"
commit-message:
prefix: "deps"
include: "scope"
4 changes: 3 additions & 1 deletion .github/workflows/manual_msi_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ jobs:
args: build --single-target --skip-validate --rm-dist --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Copy Windows Binary
- name: Copy Windows Collector Binary
run: cp dist/collector_windows_amd64_v1/observiq-otel-collector.exe windows/observiq-otel-collector.exe
- name: Copy Windows Updater Binary
run: cp dist/updater_windows_amd64_v1/updater.exe windows/updater.exe
- name: Copy Plugins to MSI Build Directory
run: cp -r release_deps/plugins windows/
- name: Copy Example Config
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/multi_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Scan Third Party Dependency Licenses
run: |
go install github.com/uw-labs/lichen@v0.1.5
lichen --config=./license.yaml $(find dist/collector_*)
lichen --config=./license.yaml $(find dist/collector_* dist/updater_*)
build_darwin:
runs-on: macos-11
steps:
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Scan Third Party Dependency Licenses
run: |
go install github.com/uw-labs/lichen@v0.1.5
lichen --config=./license.yaml $(find dist/collector_*)
lichen --config=./license.yaml $(find dist/collector_* dist/updater_*)
build_windows:
runs-on: windows-2019
steps:
Expand All @@ -80,4 +80,4 @@ jobs:
- name: Scan Third Party Dependency Licenses
run: |
go install github.com/uw-labs/lichen@v0.1.5
lichen --config=./license.yaml dist/collector_windows_amd64.exe
lichen --config=./license.yaml dist/collector_windows_amd64.exe dist/updater_windows_amd64.exe
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ jobs:
args: build --single-target --skip-validate --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Copy Windows Binary
- name: Copy Windows Collector Binary
run: cp dist/collector_windows_amd64_v1/observiq-otel-collector.exe windows/observiq-otel-collector.exe
- name: Copy Windows Updater Binary
run: cp dist/updater_windows_amd64_v1/updater.exe windows/updater.exe
- name: Copy Plugins to MSI Build Directory
run: cp -r release_deps/plugins windows/
- name: Copy Example Config
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ jobs:
${{ runner.os }}-go-
- name: Run Tests
run: make test
- name: Run Updater Integration Tests (non-linux)
if: matrix.os != 'ubuntu-20.04'
run: make test-updater-integration
- name: Run Updater Integration Tests (linux)
if: matrix.os == 'ubuntu-20.04'
run: sudo make test-updater-integration
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cosign.*
gpg.*
*.msi
*.exe
*.zip
windows/*.zip
windows/**/wix.dynamic.json
windows/**/wix
windows/config.yaml
Expand All @@ -20,7 +20,7 @@ windows/plugins
opentelemetry-java-contrib-jmx-metrics.jar
VERSION.txt
release_deps
tmp
/tmp

# OpAmp Files
collector.yaml
Expand Down
33 changes: 32 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ builds:
- -X github.com/observiq/observiq-otel-collector/internal/version.gitHash={{ .FullCommit }}
- -X github.com/observiq/observiq-otel-collector/internal/version.date={{ .Date }}
no_unique_dist_dir: false
- id: updater
binary: updater
dir: ./updater/
main: ./cmd/updater
env:
- CGO_ENABLED=0
mod_timestamp: "{{ .CommitTimestamp }}"
goos:
- windows
- linux
- darwin
goarch:
- amd64
- arm64
- arm
ignore:
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
ldflags:
- -s -w
- -X github.com/observiq/observiq-otel-collector/updater/internal/version.version=v{{ .Version }}
- -X github.com/observiq/observiq-otel-collector/updater/internal/version.gitHash={{ .FullCommit }}
- -X github.com/observiq/observiq-otel-collector/updater/internal/version.date={{ .Date }}
no_unique_dist_dir: false

# https://goreleaser.com/customization/archive/
archives:
Expand All @@ -56,7 +82,12 @@ archives:
- src: release_deps/com.observiq.collector.plist
dst: "install"
strip_parent: true

- src: release_deps/windows_service.json
dst: install
strip_parent: true
- src: release_deps/observiq-otel-collector.service
dst: "install"
strip_parent: true
format_overrides:
- goos: windows
format: zip
Expand Down
40 changes: 31 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ OUTDIR=./dist
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)

INTEGRATION_TEST_ARGS?=-tags integration

ifeq ($(GOOS), windows)
EXT?=.exe
else
Expand All @@ -21,11 +23,23 @@ CURRENT_TAG := $(shell git tag --sort=v:refname --points-at HEAD | grep -E "v[0-
# Version will be the tag pointing to the current commit, or the previous version tag if there is no such tag
VERSION ?= $(if $(CURRENT_TAG),$(CURRENT_TAG),$(PREVIOUS_TAG))

# Default build target; making this should build for the current os/arch
# Build binaries for current GOOS/GOARCH by default
.DEFAULT_GOAL := build-binaries

# Builds just the collector for current GOOS/GOARCH pair
.PHONY: collector
collector:
go build -ldflags "-s -w -X github.com/observiq/observiq-otel-collector/internal/version.version=$(VERSION)" -o $(OUTDIR)/collector_$(GOOS)_$(GOARCH)$(EXT) ./cmd/collector

# Builds just the updater for current GOOS/GOARCH pair
.PHONY: updater
updater:
cd ./updater/; go build -ldflags "-s -w -X github.com/observiq/observiq-otel-collector/internal/version.version=$(VERSION)" -o ../$(OUTDIR)/updater_$(GOOS)_$(GOARCH)$(EXT) ./cmd/updater

# Builds the updater + collector for current GOOS/GOARCH pair
.PHONY: build-binaries
build-binaries: collector updater

.PHONY: build-all
build-all: build-linux build-darwin build-windows

Expand All @@ -40,27 +54,27 @@ build-windows: build-windows-amd64

.PHONY: build-linux-amd64
build-linux-amd64:
GOOS=linux GOARCH=amd64 $(MAKE) collector
GOOS=linux GOARCH=amd64 $(MAKE) build-binaries -j2

.PHONY: build-linux-arm64
build-linux-arm64:
GOOS=linux GOARCH=arm64 $(MAKE) collector
GOOS=linux GOARCH=arm64 $(MAKE) build-binaries -j2

.PHONY: build-linux-arm
build-linux-arm:
GOOS=linux GOARCH=arm $(MAKE) collector
GOOS=linux GOARCH=arm $(MAKE) build-binaries -j2

.PHONY: build-darwin-amd64
build-darwin-amd64:
GOOS=darwin GOARCH=amd64 $(MAKE) collector
GOOS=darwin GOARCH=amd64 $(MAKE) build-binaries -j2

.PHONY: build-darwin-arm64
build-darwin-arm64:
GOOS=darwin GOARCH=arm64 $(MAKE) collector
GOOS=darwin GOARCH=arm64 $(MAKE) build-binaries -j2

.PHONY: build-windows-amd64
build-windows-amd64:
GOOS=windows GOARCH=amd64 $(MAKE) collector
GOOS=windows GOARCH=amd64 $(MAKE) build-binaries -j2

# tool-related commands
.PHONY: install-tools
Expand Down Expand Up @@ -97,6 +111,10 @@ test-with-cover:
$(MAKE) for-all CMD="go test -coverprofile=cover.out ./..."
$(MAKE) for-all CMD="go tool cover -html=cover.out -o cover.html"

.PHONY: test-updater-integration
test-updater-integration:
cd updater; go test $(INTEGRATION_TEST_ARGS) -race ./...

.PHONY: bench
bench:
$(MAKE) for-all CMD="go test -benchmem -run=^$$ -bench ^* ./..."
Expand All @@ -115,7 +133,9 @@ tidy:

.PHONY: gosec
gosec:
gosec ./...
gosec -exclude-dir updater ./...
# exclude the testdata dir; it contains a go program for testing.
cd updater; gosec -exclude-dir internal/service/testdata ./...

# This target performs all checks that CI will do (excluding the build itself)
.PHONY: ci-checks
Expand Down Expand Up @@ -157,6 +177,8 @@ release-prep:
@cp config/example.yaml release_deps/config.yaml
@cp config/logging.yaml release_deps/logging.yaml
@cp service/com.observiq.collector.plist release_deps/com.observiq.collector.plist
@jq ".files[] | select(.service != null)" windows/wix.json >> release_deps/windows_service.json
@cp service/observiq-otel-collector.service release_deps/observiq-otel-collector.service

# Build, sign, and release
.PHONY: release
Expand Down Expand Up @@ -184,7 +206,7 @@ clean:

.PHONY: scan-licenses
scan-licenses:
lichen --config=./license.yaml $$(find dist/collector_* | grep -v 'sig\|json\|CHANGELOG.md\|yaml\|SHA256' | xargs)
lichen --config=./license.yaml $$(find dist/collector_* dist/updater_*)

.PHONY: generate
generate:
Expand Down
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/GoogleCloudPlatform/opentelemetry-operations-collector v0.0.3-0.20220711143229-08f2752ed367
github.com/google/uuid v1.3.0
github.com/observiq/observiq-otel-collector/exporter/googlecloudexporter v1.3.0
github.com/observiq/observiq-otel-collector/packagestate v0.0.0
github.com/observiq/observiq-otel-collector/processor/resourceattributetransposerprocessor v1.3.0
github.com/observiq/observiq-otel-collector/receiver/pluginreceiver v1.3.0
github.com/open-telemetry/opamp-go v0.2.0
Expand Down Expand Up @@ -162,6 +163,7 @@ require (
github.com/alecthomas/participle/v2 v2.0.0-alpha9 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/aliyun/aliyun-log-go-sdk v0.1.37 // indirect
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/antonmedv/expr v1.9.0 // indirect
github.com/apache/thrift v0.16.0 // indirect
github.com/armon/go-metrics v0.3.10 // indirect
Expand Down Expand Up @@ -190,6 +192,7 @@ require (
github.com/docker/docker v20.10.17+incompatible // indirect
github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/eapache/go-resiliency v1.3.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
Expand Down Expand Up @@ -276,6 +279,7 @@ require (
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/karrick/godirwalk v1.16.1 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/knadh/koanf v1.4.2 // indirect
github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b // indirect
github.com/leoluk/perflib_exporter v0.1.0 // indirect
Expand Down Expand Up @@ -306,6 +310,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/nginxinc/nginx-prometheus-exporter v0.8.1-0.20201110005315-f5a5f8086c19 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/observiq/ctimefmt v1.0.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlecloudexporter v0.57.2 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.57.2 // indirect
Expand Down Expand Up @@ -391,13 +396,15 @@ require (
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/ulikunitz/xz v0.5.9 // indirect
github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5 // indirect
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
github.com/vmware/govmomi v0.28.0 // indirect
github.com/vultr/govultr/v2 v2.17.2 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
Expand Down Expand Up @@ -454,6 +461,7 @@ require (
require (
github.com/containerd/containerd v1.6.6 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/mholt/archiver/v3 v3.5.1
github.com/shirou/gopsutil/v3 v3.22.7
github.com/spf13/cobra v1.5.0 // indirect
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e
Expand All @@ -465,4 +473,6 @@ replace github.com/observiq/observiq-otel-collector/receiver/pluginreceiver => .

replace github.com/observiq/observiq-otel-collector/exporter/googlecloudexporter => ./exporter/googlecloudexporter

replace github.com/observiq/observiq-otel-collector/packagestate => ./packagestate

replace github.com/GoogleCloudPlatform/opentelemetry-operations-collector v0.0.3-0.20220711143229-08f2752ed367 => github.com/observIQ/opentelemetry-operations-collector v0.0.3-0.20220804143341-7ae64090f52c
Loading