Skip to content

Commit

Permalink
Remove static mode and static mode operator (#15)
Browse files Browse the repository at this point in the history
* Remove cmd/grafana-agentctl and its presence from release assets
* Remove cmd/grafana-agent-operator and its Docker image
* Remove cmd/grafana-agent-flow and its presence from release assets
* Remove all static mode code from cmd/grafana-agent
* Replace packages with the ones used for grafana-agent-flow (but renamed)
* Temporarily remove example/docker-compose, which was extremely static-mode tailored.
  • Loading branch information
rfratto authored Feb 29, 2024
1 parent dfb917a commit 813d60b
Show file tree
Hide file tree
Showing 192 changed files with 277 additions and 32,302 deletions.
516 changes: 3 additions & 513 deletions .drone/drone.yml

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions .drone/pipelines/check_containers.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ local pipelines = import '../util/pipelines.jsonnet';

local linux_containers = [
{ name: 'grafana/agent', make: 'make agent-image', path: 'cmd/grafana-agent/Dockerfile' },
{ name: 'grafana/agentctl', make: 'make agentctl-image', path: 'cmd/grafana-agentctl/Dockerfile' },
{ name: 'grafana/agent-operator', make: 'make operator-image', path: 'cmd/grafana-agent-operator/Dockerfile' },
];

local windows_containers = [
{ name: 'grafana/agent', argument: 'agent', path: 'cmd/grafana-agent/Dockerfile.windows' },
{ name: 'grafana/agentctl', argument: 'agentctl', path: 'cmd/grafana-agentctl/Dockerfile.windows' },
];

(
Expand Down
11 changes: 4 additions & 7 deletions .drone/pipelines/crosscompile.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ local os_arch_tuples = [

local targets = [
'agent',
'agent-flow',
'agentctl',
'operator',
];

local targets_boringcrypto = [
'agent-boringcrypto',
];
local targets_boringcrypto_windows = [
'agent-flow-windows-boringcrypto',
'agent-windows-boringcrypto',
];


Expand All @@ -64,7 +61,7 @@ local build_environments(targets, tuples, image) = std.flatMap(function(target)
target: target,

tags: go_tags[platform.os],
} + (if 'experiment' in platform then { GOEXPERIMENT: platform.experiment } else { }),
} + (if 'experiment' in platform then { GOEXPERIMENT: platform.experiment } else {}),

trigger: {
event: ['pull_request'],
Expand All @@ -75,7 +72,7 @@ local build_environments(targets, tuples, image) = std.flatMap(function(target)
image: image,
commands: [
'make generate-ui',
(if 'GOEXPERIMENT' in env
(if 'GOEXPERIMENT' in env
then 'GO_TAGS="%(tags)s" GOOS=%(GOOS)s GOARCH=%(GOARCH)s GOARM=%(GOARM)s GOEXPERIMENT=%(GOEXPERIMENT)s make %(target)s' % env
else 'GO_TAGS="%(tags)s" GOOS=%(GOOS)s GOARCH=%(GOARCH)s GOARM=%(GOARM)s make %(target)s') % env,
],
Expand All @@ -86,4 +83,4 @@ local build_environments(targets, tuples, image) = std.flatMap(function(target)

build_environments(targets, os_arch_tuples, build_image.linux) +
build_environments(targets_boringcrypto, os_arch_types_boringcrypto, build_image.linux) +
build_environments(targets_boringcrypto_windows, windows_os_arch_types_boringcrypto, build_image.boringcrypto)
build_environments(targets_boringcrypto_windows, windows_os_arch_types_boringcrypto, build_image.boringcrypto)
4 changes: 2 additions & 2 deletions .drone/pipelines/publish.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local ghTokenFilename = '/drone/src/gh-token.txt';
// job_names gets the list of job names for use in depends_on.
local job_names = function(jobs) std.map(function(job) job.name, jobs);

local linux_containers = ['agent', 'agent-boringcrypto', 'agentctl', 'agent-operator'];
local linux_containers = ['agent', 'agent-boringcrypto'];
local linux_containers_jobs = std.map(function(container) (
pipelines.linux('Publish Linux %s container' % container) {
trigger: {
Expand Down Expand Up @@ -60,7 +60,7 @@ local linux_containers_jobs = std.map(function(container) (
}
), linux_containers);

local windows_containers = ['agent', 'agentctl'];
local windows_containers = ['agent'];
local windows_containers_jobs = std.map(function(container) (
pipelines.windows('Publish Windows %s container' % container) {
trigger: {
Expand Down
34 changes: 0 additions & 34 deletions .drone/pipelines/test.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,6 @@ local pipelines = import '../util/pipelines.jsonnet';
}],
},

pipelines.linux('Test dashboards') {
trigger: {
event: ['pull_request'],
},
steps: [{
name: 'Regenerate dashboards',
image: build_image.linux,

commands: [
'make generate-dashboards',
'ERR_MSG="Dashboard definitions are out of date. Please run \'make generate-dashboards\' and commit changes!"',
// "git status --porcelain" reports if there's any new, modified, or deleted files.
'if [ ! -z "$(git status --porcelain)" ]; then echo $ERR_MSG >&2; exit 1; fi',
],
}],
},

pipelines.linux('Test crds') {
trigger: {
event: ['pull_request'],
},
steps: [{
name: 'Regenerate crds',
image: build_image.linux,

commands: [
'make generate-crds',
'ERR_MSG="Custom Resource Definitions are out of date. Please run \'make generate-crds\' and commit changes!"',
// "git status --porcelain" reports if there's any new, modified, or deleted files.
'if [ ! -z "$(git status --porcelain)" ]; then echo $ERR_MSG >&2; exit 1; fi',
],
}],
},

pipelines.linux('Test') {
trigger: {
event: ['pull_request'],
Expand Down
2 changes: 0 additions & 2 deletions .drone/pipelines/test_packages.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ local pipelines = import '../util/pipelines.jsonnet';
}],
commands: [
'DOCKER_OPTS="" make dist/grafana-agent-linux-amd64',
'DOCKER_OPTS="" make dist/grafana-agentctl-linux-amd64',
'DOCKER_OPTS="" make dist.temp/grafana-agent-flow-linux-amd64',
'DOCKER_OPTS="" make test-packages',
],
}],
Expand Down
125 changes: 30 additions & 95 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,28 @@
## binaries Compiles all binaries.
## agent Compiles cmd/grafana-agent to $(AGENT_BINARY)
## agent-boringcrypto Compiles cmd/grafana-agent with GOEXPERIMENT=boringcrypto to $(AGENT_BORINGCRYPTO_BINARY)
## agent-flow Compiles cmd/grafana-agent-flow to $(FLOW_BINARY)
## agent-flow-windows-boringcrypto Compiles cmd/grafana-agent-flow to $(FLOW_BINARY)-windows-boringcrypto
## agent-windows-boringcrypto Compiles cmd/grafana-agent to $(AGENT_BORINGCRYPTO_BINARY)
## agent-service Compiles cmd/grafana-agent-service to $(SERVICE_BINARY)
## agentctl Compiles cmd/grafana-agentctl to $(AGENTCTL_BINARY)
## operator Compiles cmd/grafana-agent-operator to $(OPERATOR_BINARY)
##
## Targets for building Docker images:
##
## images Builds all Docker images.
## agent-image Builds agent Docker image.
## agent-boringcrypto-image Builds agent Docker image with boringcrypto.
## agentctl-image Builds agentctl Docker image.
## operator-image Builds operator Docker image.
##
## Targets for packaging:
##
## dist Produce release assets for everything.
## dist-agent-binaries Produce release-ready agent binaries.
## dist-agentctl-binaries Produce release-ready agentctl binaries.
## dist-packages Produce release-ready DEB and RPM packages.
## dist-agent-installer Produce a Windows installer for Grafana Agent.
##
## Targets for generating assets:
##
## generate Generate everything.
## generate-crds Generate Grafana Agent Operator CRDs ands its documentation.
## generate-drone Generate the Drone YAML from Jsonnet.
## generate-helm-docs Generate Helm chart documentation.
## generate-helm-tests Generate Helm chart tests.
## generate-dashboards Generate dashboards in example/docker-compose after
## changing Jsonnet.
## generate-protos Generate protobuf files.
## generate-ui Generate the UI assets.
## generate-versioned-files Generate versioned files.
Expand All @@ -70,40 +61,31 @@
##
## Environment variables:
##
## USE_CONTAINER Set to 1 to enable proxying commands to build container
## AGENT_IMAGE Image name:tag built by `make agent-image`
## AGENTCTL_IMAGE Image name:tag built by `make agentctl-image`
## OPERATOR_IMAGE Image name:tag built by `make operator-image`
## BUILD_IMAGE Image name:tag used by USE_CONTAINER=1
## AGENT_BINARY Output path of `make agent` (default build/grafana-agent)
## AGENT_BORINGCRYPTO_BINARY Output path of `make agent-boringcrypto` (default build/grafana-agent-boringcrypto)
## FLOW_BINARY Output path of `make agent-flow` (default build/grafana-agent-flow)
## SERVICE_BINARY Output path of `make agent-service` (default build/grafana-agent-service)
## AGENTCTL_BINARY Output path of `make agentctl` (default build/grafana-agentctl)
## OPERATOR_BINARY Output path of `make operator` (default build/grafana-agent-operator)
## GOOS Override OS to build binaries for
## GOARCH Override target architecture to build binaries for
## GOARM Override ARM version (6 or 7) when GOARCH=arm
## CGO_ENABLED Set to 0 to disable Cgo for binaries.
## RELEASE_BUILD Set to 1 to build release binaries.
## VERSION Version to inject into built binaries.
## GO_TAGS Extra tags to use when building.
## DOCKER_PLATFORM Overrides platform to build Docker images for (defaults to host platform).
## GOEXPERIMENT Used to enable features, most likely boringcrypto via GOEXPERIMENT=boringcrypto.
## USE_CONTAINER Set to 1 to enable proxying commands to build container
## AGENT_IMAGE Image name:tag built by `make agent-image`
## BUILD_IMAGE Image name:tag used by USE_CONTAINER=1
## AGENT_BINARY Output path of `make agent` (default build/grafana-agent)
## AGENT_BORINGCRYPTO_BINARY Output path of `make agent-boringcrypto` (default build/grafana-agent-boringcrypto)
## AGENT_BORINGCRYPTO_WINDOWS_BINARY Output path of `make agent-windows-boringcrypto` (default build/grafana-agent-windows-boringcrypto.exe)
## SERVICE_BINARY Output path of `make agent-service` (default build/grafana-agent-service)
## GOOS Override OS to build binaries for
## GOARCH Override target architecture to build binaries for
## GOARM Override ARM version (6 or 7) when GOARCH=arm
## CGO_ENABLED Set to 0 to disable Cgo for binaries.
## RELEASE_BUILD Set to 1 to build release binaries.
## VERSION Version to inject into built binaries.
## GO_TAGS Extra tags to use when building.
## DOCKER_PLATFORM Overrides platform to build Docker images for (defaults to host platform).
## GOEXPERIMENT Used to enable features, most likely boringcrypto via GOEXPERIMENT=boringcrypto.

include tools/make/*.mk

AGENT_IMAGE ?= grafana/agent:latest
AGENT_BORINGCRYPTO_IMAGE ?= grafana/agent-boringcrypto:latest
AGENTCTL_IMAGE ?= grafana/agentctl:latest
OPERATOR_IMAGE ?= grafana/agent-operator:latest
AGENT_BINARY ?= build/grafana-agent
AGENT_BORINGCRYPTO_BINARY ?= build/grafana-agent-boringcrypto
AGENT_BORINGCRYPTO_WINDOWS_BINARY ?= build/agent-flow-windows-boringcrypto.exe
FLOW_BINARY ?= build/grafana-agent-flow
AGENT_BORINGCRYPTO_WINDOWS_BINARY ?= build/grafana-agent-windows-boringcrypto.exe
SERVICE_BINARY ?= build/grafana-agent-service
AGENTCTL_BINARY ?= build/grafana-agentctl
OPERATOR_BINARY ?= build/grafana-agent-operator
AGENTLINT_BINARY ?= build/agentlint
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
Expand All @@ -115,9 +97,9 @@ GOEXPERIMENT ?= $(shell go env GOEXPERIMENT)
# List of all environment variables which will propagate to the build
# container. USE_CONTAINER must _not_ be included to avoid infinite recursion.
PROPAGATE_VARS := \
AGENT_IMAGE AGENTCTL_IMAGE OPERATOR_IMAGE \
AGENT_IMAGE \
BUILD_IMAGE GOOS GOARCH GOARM CGO_ENABLED RELEASE_BUILD \
AGENT_BINARY AGENT_BORINGCRYPTO_BINARY FLOW_BINARY AGENTCTL_BINARY OPERATOR_BINARY \
AGENT_BINARY AGENT_BORINGCRYPTO_BINARY \
VERSION GO_TAGS GOEXPERIMENT

#
Expand Down Expand Up @@ -149,8 +131,7 @@ endif
#
# Targets for running tests
#
# These targets currently don't support proxying to a build container due to
# difficulties with testing ./internal/util/k8s and testing packages.
# These targets currently don't support proxying to a build container.
#

.PHONY: lint
Expand All @@ -163,7 +144,7 @@ lint: agentlint
# more without -race for packages that have known race detection issues.
test:
$(GO_ENV) go test $(GO_FLAGS) -race $(shell go list ./... | grep -v /integration-tests/)
$(GO_ENV) go test $(GO_FLAGS) ./internal/static/integrations/node_exporter ./internal/static/logs ./internal/static/operator ./internal/util/k8s ./internal/component/otelcol/processor/tail_sampling ./internal/component/loki/source/file ./internal/component/loki/source/docker
$(GO_ENV) go test $(GO_FLAGS) ./internal/static/integrations/node_exporter ./internal/static/logs ./internal/component/otelcol/processor/tail_sampling ./internal/component/loki/source/file ./internal/component/loki/source/docker

test-packages:
docker pull $(BUILD_IMAGE)
Expand All @@ -177,8 +158,8 @@ integration-test:
# Targets for building binaries
#

.PHONY: binaries agent agent-boringcrypto agent-flow agentctl operator
binaries: agent agent-boringcrypto agent-flow agentctl operator
.PHONY: binaries agent agent-boringcrypto
binaries: agent agent-boringcrypto

agent:
ifeq ($(USE_CONTAINER),1)
Expand All @@ -194,19 +175,11 @@ else
GOEXPERIMENT=boringcrypto $(GO_ENV) go build $(GO_FLAGS) -o $(AGENT_BORINGCRYPTO_BINARY) ./cmd/grafana-agent
endif

agent-flow-windows-boringcrypto:
agent-windows-boringcrypto:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
GOEXPERIMENT=cngcrypto $(GO_ENV) go build $(GO_FLAGS) -tags cngcrypto -o $(AGENT_BORINGCRYPTO_WINDOWS_BINARY) ./cmd/grafana-agent-flow
endif


agent-flow:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
$(GO_ENV) go build $(GO_FLAGS) -o $(FLOW_BINARY) ./cmd/grafana-agent-flow
GOEXPERIMENT=cngcrypto $(GO_ENV) go build $(GO_FLAGS) -tags cngcrypto -o $(AGENT_BORINGCRYPTO_WINDOWS_BINARY) ./cmd/grafana-agent
endif

# agent-service is not included in binaries since it's Windows-only.
Expand All @@ -217,20 +190,6 @@ else
$(GO_ENV) go build $(GO_FLAGS) -o $(SERVICE_BINARY) ./cmd/grafana-agent-service
endif

agentctl:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
$(GO_ENV) go build $(GO_FLAGS) -o $(AGENTCTL_BINARY) ./cmd/grafana-agentctl
endif

operator:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
$(GO_ENV) go build $(GO_FLAGS) -o $(OPERATOR_BINARY) ./cmd/grafana-agent-operator
endif

agentlint:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
Expand All @@ -248,32 +207,20 @@ ifneq ($(DOCKER_PLATFORM),)
DOCKER_FLAGS += --platform=$(DOCKER_PLATFORM)
endif

.PHONY: images agent-image agentctl-image operator-image
images: agent-image agentctl-image operator-image
.PHONY: images agent-image
images: agent-image

agent-image:
DOCKER_BUILDKIT=1 docker build $(DOCKER_FLAGS) -t $(AGENT_IMAGE) -f cmd/grafana-agent/Dockerfile .
agentctl-image:
DOCKER_BUILDKIT=1 docker build $(DOCKER_FLAGS) -t $(AGENTCTL_IMAGE) -f cmd/grafana-agentctl/Dockerfile .
agent-boringcrypto-image:
DOCKER_BUILDKIT=1 docker build $(DOCKER_FLAGS) --build-arg GOEXPERIMENT=boringcrypto -t $(AGENT_BORINGCRYPTO_IMAGE) -f cmd/grafana-agent/Dockerfile .
operator-image:
DOCKER_BUILDKIT=1 docker build $(DOCKER_FLAGS) -t $(OPERATOR_IMAGE) -f cmd/grafana-agent-operator/Dockerfile .

#
# Targets for generating assets
#

.PHONY: generate generate-crds generate-drone generate-helm-docs generate-helm-tests generate-dashboards generate-protos generate-ui generate-versioned-files
generate: generate-crds generate-drone generate-helm-docs generate-helm-tests generate-dashboards generate-protos generate-ui generate-versioned-files generate-docs

generate-crds:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
bash ./tools/generate-crds.bash
gen-crd-api-reference-docs -config tools/gen-crd-docs/config.json -api-dir "github.com/grafana/agent/internal/static/operator/apis/monitoring/" -out-file docs/sources/operator/api.md -template-dir tools/gen-crd-docs/template
endif
.PHONY: generate generate-drone generate-helm-docs generate-helm-tests generate-protos generate-ui generate-versioned-files
generate: generate-drone generate-helm-docs generate-helm-tests generate-protos generate-ui generate-versioned-files generate-docs

generate-drone:
drone jsonnet -V BUILD_IMAGE_VERSION=$(BUILD_IMAGE_VERSION) --stream --format --source .drone/drone.jsonnet --target .drone/drone.yml
Expand All @@ -292,14 +239,6 @@ else
bash ./operations/helm/scripts/rebuild-tests.sh
endif

generate-dashboards:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
cd example/docker-compose && jb install && \
cd grafana/dashboards && jsonnet template.jsonnet -J ../../vendor -m .
endif

generate-protos:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
Expand Down Expand Up @@ -350,12 +289,8 @@ clean: clean-dist clean-build-container-cache
info:
@printf "USE_CONTAINER = $(USE_CONTAINER)\n"
@printf "AGENT_IMAGE = $(AGENT_IMAGE)\n"
@printf "AGENTCTL_IMAGE = $(AGENTCTL_IMAGE)\n"
@printf "OPERATOR_IMAGE = $(OPERATOR_IMAGE)\n"
@printf "BUILD_IMAGE = $(BUILD_IMAGE)\n"
@printf "AGENT_BINARY = $(AGENT_BINARY)\n"
@printf "AGENTCTL_BINARY = $(AGENTCTL_BINARY)\n"
@printf "OPERATOR_BINARY = $(OPERATOR_BINARY)\n"
@printf "GOOS = $(GOOS)\n"
@printf "GOARCH = $(GOARCH)\n"
@printf "GOARM = $(GOARM)\n"
Expand Down
Loading

0 comments on commit 813d60b

Please sign in to comment.