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

Don't duplicate agent builds for OTEL collector #34304

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
1 change: 1 addition & 0 deletions .gitlab/JOBOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ agent_suse* @DataDog/agent-delivery
windows-installer* @DataDog/windows-agent
windows_* @DataDog/windows-agent
powershell_script_signing @DataDog/windows-agent
datadog-otel-agent-* @DataDog/agent-delivery

# Packaging
agent_deb* @DataDog/agent-delivery
Expand Down
25 changes: 14 additions & 11 deletions .gitlab/container_build/docker_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# context
.docker_build_artifact:
before_script:
- mv $OMNIBUS_PACKAGE_DIR/*.xz $BUILD_CONTEXT
- ls $OMNIBUS_PACKAGE_DIR/*.xz | grep -v -- -dbg- | xargs -I '{}' mv '{}' $BUILD_CONTEXT/

.docker_build_job_definition_amd64:
extends: .docker_build_job_definition
Expand Down Expand Up @@ -169,59 +169,62 @@ docker_build_fips_agent7_arm64_jmx:
TAG_SUFFIX: -7-fips-jmx
BUILD_ARG: --target test --build-arg WITH_JMX=true --build-arg WITH_JMX_FIPS=true --build-arg DD_AGENT_ARTIFACT=datadog-fips-agent-7*-arm64.tar.xz

# build agent7 UA image
# Build agent7 OTel image
docker_build_ot_agent7:
extends: [.docker_build_job_definition_amd64, .docker_build_artifact]
rules:
- !reference [.except_mergequeue]
- when: on_success
needs:
- job: datadog-ot-agent-7-x64
- job: datadog-agent-7-x64
- job: datadog-otel-agent-x64
variables:
IMAGE: registry.ddbuild.io/ci/datadog-agent/agent
BUILD_CONTEXT: Dockerfiles/agent
TAG_SUFFIX: -7-ot-beta
BUILD_ARG: --target test --build-arg DD_AGENT_ARTIFACT=datadog-ot-agent-7*-amd64.tar.xz
BUILD_ARG: --target test --build-arg DD_AGENT_ARTIFACT=datadog-*-7*-amd64.tar.xz

docker_build_ot_agent7_arm64:
extends: [.docker_build_job_definition_arm64, .docker_build_artifact]
rules:
- !reference [.except_mergequeue]
- when: on_success
needs:
- job: datadog-ot-agent-7-arm64
- job: datadog-agent-7-arm64
- job: datadog-otel-agent-arm64
variables:
IMAGE: registry.ddbuild.io/ci/datadog-agent/agent
BUILD_CONTEXT: Dockerfiles/agent
TAG_SUFFIX: -7-ot-beta
BUILD_ARG: --target test --build-arg DD_AGENT_ARTIFACT=datadog-ot-agent-7*-arm64.tar.xz
BUILD_ARG: --target test --build-arg DD_AGENT_ARTIFACT=datadog-*-7*-arm64.tar.xz

# build agent7 jmx image
docker_build_ot_agent7_jmx:
extends: [.docker_build_job_definition_amd64, .docker_build_artifact]
rules:
- !reference [.except_mergequeue]
- when: on_success
needs:
- job: datadog-ot-agent-7-x64
- job: datadog-agent-7-x64
- job: datadog-otel-agent-x64
variables:
IMAGE: registry.ddbuild.io/ci/datadog-agent/agent
BUILD_CONTEXT: Dockerfiles/agent
TAG_SUFFIX: -7-ot-beta-jmx
BUILD_ARG: --target test --build-arg WITH_JMX=true --build-arg DD_AGENT_ARTIFACT=datadog-ot-agent-7*-amd64.tar.xz
BUILD_ARG: --target test --build-arg WITH_JMX=true --build-arg DD_AGENT_ARTIFACT=datadog-*-7*-amd64.tar.xz

docker_build_ot_agent7_jmx_arm64:
extends: [.docker_build_job_definition_arm64, .docker_build_artifact]
rules:
- !reference [.except_mergequeue]
- when: on_success
needs:
- job: datadog-ot-agent-7-arm64
- job: datadog-agent-7-arm64
- job: datadog-otel-agent-arm64
variables:
IMAGE: registry.ddbuild.io/ci/datadog-agent/agent
BUILD_CONTEXT: Dockerfiles/agent
TAG_SUFFIX: -7-ot-beta-jmx
BUILD_ARG: --target test --build-arg WITH_JMX=true --build-arg DD_AGENT_ARTIFACT=datadog-ot-agent-7*-arm64.tar.xz
BUILD_ARG: --target test --build-arg WITH_JMX=true --build-arg DD_AGENT_ARTIFACT=datadog-*-7*-arm64.tar.xz

# build the cluster-agent image
docker_build_cluster_agent_amd64:
Expand Down
56 changes: 42 additions & 14 deletions .gitlab/package_build/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@
before_script:
- export RELEASE_VERSION=$RELEASE_VERSION_7

.ot_agent_7_build:
variables:
FLAVOR: ot
before_script:
- export RELEASE_VERSION=$RELEASE_VERSION_7

.agent_fips_build:
variables:
FLAVOR: fips
Expand All @@ -81,14 +75,6 @@ datadog-agent-7-x64:
datadog-agent-7-arm64:
extends: [.agent_build_common, .agent_build_arm64, .agent_7_build]

# build Agent 7 binaries for x86_64
datadog-ot-agent-7-x64:
extends: [.agent_build_common, .agent_build_x86, .ot_agent_7_build]

# build Agent 7 binaries for arm64
datadog-ot-agent-7-arm64:
extends: [.agent_build_common, .agent_build_arm64, .ot_agent_7_build]

# build Agent 7 binaries for x86_64 with FIPS
datadog-agent-7-x64-fips:
extends: [.agent_build_common, .agent_build_x86, .agent_fips_build]
Expand Down Expand Up @@ -180,3 +166,45 @@ dogstatsd-arm64:
variables:
DD_CC: "aarch64-unknown-linux-gnu-gcc"
DD_CXX: "aarch64-unknown-linux-gnu-g++"

.otel_build_common:
needs: ["go_mod_tidy_check", "go_deps"]
rules:
- !reference [.except_mergequeue]
- when: on_success
stage: package_build
script:
- echo "About to build for $RELEASE_VERSION"
- !reference [.retrieve_linux_go_deps]
- !reference [.cache_omnibus_ruby_deps, setup]
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR/*
- inv -e omnibus.build --release-version $RELEASE_VERSION_7 --base-dir $OMNIBUS_BASE_DIR ${USE_S3_CACHING} --skip-deps --go-mod-cache="$GOPATH/pkg/mod" --target-project otel-agent
- ls -la $OMNIBUS_PACKAGE_DIR
- !reference [.upload_sbom_artifacts]
variables:
KUBERNETES_CPU_REQUEST: 16
KUBERNETES_MEMORY_REQUEST: "32Gi"
KUBERNETES_MEMORY_LIMIT: "32Gi"
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR
cache:
- !reference [.cache_omnibus_ruby_deps, cache]

datadog-otel-agent-x64:
extends: .otel_build_common
image: registry.ddbuild.io/ci/datadog-agent-buildimages/linux-glibc-2-17-x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
tags: ["arch:amd64"]
variables:
DD_CC: "x86_64-unknown-linux-gnu-gcc"
DD_CXX: "x86_64-unknown-linux-gnu-g++"

datadog-otel-agent-arm64:
extends: .otel_build_common
image: registry.ddbuild.io/ci/datadog-agent-buildimages/linux-glibc-2-23-arm64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
tags: ["arch:arm64"]
variables:
DD_CC: "aarch64-unknown-linux-gnu-gcc"
DD_CXX: "aarch64-unknown-linux-gnu-g++"
Comment on lines +196 to +210
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - we could have a matrix to avoid some cpy/paste

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we have 3 values to modify (the image name, the tag, a the compiler prefix) for a 7 lines job, I'm not sure a matrix would improve the readability/maintainability here

4 changes: 2 additions & 2 deletions .gitlab/packaging/deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ot_agent_deb-x64-a7:
rules:
- !reference [.except_mergequeue]
- when: on_success
needs: ["datadog-ot-agent-7-x64"]
needs: ["datadog-agent-7-x64", "datadog-otel-agent-x64"]
variables:
DD_PROJECT: "agent"

Expand All @@ -99,7 +99,7 @@ ot_agent_deb-arm64-a7:
rules:
- !reference [.except_mergequeue]
- when: on_success
needs: ["datadog-ot-agent-7-arm64"]
needs: ["datadog-agent-7-arm64", "datadog-otel-agent-arm64"]
variables:
DD_PROJECT: "agent"

Expand Down
81 changes: 81 additions & 0 deletions omnibus/config/projects/otel-agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https:#www.datadoghq.com/).
# Copyright 2016-present Datadog, Inc.
require "./lib/ostools.rb"
require "./lib/project_helpers.rb"
output_config_dir = ENV["OUTPUT_CONFIG_DIR"]

name 'otel-agent'
package_name 'datadog-otel-agent'

license "Apache-2.0"
license_file "../LICENSE"

third_party_licenses "../LICENSE-3rdparty.csv"

homepage 'http://www.datadoghq.com'

if ENV.has_key?("OMNIBUS_WORKERS_OVERRIDE")
COMPRESSION_THREADS = ENV["OMNIBUS_WORKERS_OVERRIDE"].to_i
else
COMPRESSION_THREADS = 1
end
if ENV.has_key?("DEPLOY_AGENT") && ENV["DEPLOY_AGENT"] == "true"
COMPRESSION_LEVEL = 9
else
COMPRESSION_LEVEL = 5
end

if ENV.has_key?("OMNIBUS_GIT_CACHE_DIR")
Omnibus::Config.use_git_caching true
Omnibus::Config.git_cache_dir ENV["OMNIBUS_GIT_CACHE_DIR"]
end

unless linux_target?
raise UnknownPlatform
end

INSTALL_DIR = ENV["INSTALL_DIR"] || '/opt/datadog-agent'

install_dir INSTALL_DIR

json_manifest_path File.join(install_dir, "version-manifest.otel-agent.json")
text_manifest_path File.join(install_dir, "version-manifest.otel-agent.txt")

# build_version is computed by an invoke command/function.
# We can't call it directly from there, we pass it through the environment instead.
build_version ENV['PACKAGE_VERSION']

build_iteration 1

description ''

# ------------------------------------
# Generic package information
# ------------------------------------

package :deb do
skip_packager true
end

package :xz do
compression_threads COMPRESSION_THREADS
compression_level COMPRESSION_LEVEL
end

# ------------------------------------
# Dependencies
# ------------------------------------
dependency 'datadog-otel-agent'

extra_package_file "#{output_config_dir}/etc/datadog-agent/"

exclude '\.git*'
exclude 'bundler\/git'

# the stripper will drop the symbols in a `.debug` folder in the installdir
# we want to make sure that directory is not in the main build, while present
# in the debug package.
strip_build true
debug_path ".debug" # the strip symbols will be in here
49 changes: 49 additions & 0 deletions omnibus/config/software/datadog-otel-agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https:#www.datadoghq.com/).
# Copyright 2016-present Datadog, Inc.

require './lib/ostools.rb'
require './lib/project_helpers.rb'
require 'pathname'

name 'datadog-otel-agent'

source path: '..'
relative_path 'src/github.com/DataDog/datadog-agent'

always_build true

build do
license :project_license

# set GOPATH on the omnibus source dir for this software
gopath = Pathname.new(project_dir) + '../../../..'

env = {
'GOPATH' => gopath.to_path,
'PATH' => "#{gopath.to_path}/bin:#{ENV['PATH']}",
"LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib",
"CGO_CFLAGS" => "-I. -I#{install_dir}/embedded/include",
"CGO_LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib"
}

unless ENV["OMNIBUS_GOMODCACHE"].nil? || ENV["OMNIBUS_GOMODCACHE"].empty?
gomodcache = Pathname.new(ENV["OMNIBUS_GOMODCACHE"])
env["GOMODCACHE"] = gomodcache.to_path
end

# include embedded path (mostly for `pkg-config` binary)
env = with_standard_compiler_flags(with_embedded_path(env))

conf_dir = "/etc/datadog-agent"
embedded_bin_dir = "#{install_dir}/embedded/bin"

mkdir conf_dir
mkdir embedded_bin_dir

command "invoke -e otel-agent.build", :env => env
copy 'bin/otel-agent/otel-agent', embedded_bin_dir

move 'bin/otel-agent/dist/otel-config.yaml', "#{conf_dir}/otel-config.yaml.example"
end
31 changes: 29 additions & 2 deletions omnibus/config/software/package-artifact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,35 @@
# that have been stripped out during the build
Dir.glob("*.tar.xz", base: input_dir).each do |input|
path = File.join(input_dir, input)
command "tar xf #{path} -C /"
delete path
shellout! "tar xf #{path} -C /"
FileUtils.rm path
end

# Merge version manifests together
# The agent file is the main one, with no .$product suffix.
# We will merge suffixed files into the main one
block "Merge version-manifest.json" do
main_json_manifest = "#{install_dir}/version-manifest.json"
versions = FFI_Yajl::Parser.parse(File.read(main_json_manifest))
Dir.glob("#{install_dir}/version-manifest.*.json").each do |version_manifest_json_path|
additional_versions = FFI_Yajl::Parser.parse(File.read(version_manifest_json_path))

versions["software"].merge!(additional_versions["software"])
FileUtils.rm version_manifest_json_path
end
File.open(main_json_manifest, "w") do |f|
f.write(FFI_Yajl::Encoder.encode(versions.to_hash, pretty: true))
end
end

block "Merge version-manifest.txt" do
main_txt_manifest = "#{install_dir}/version-manifest.txt"
Dir.glob("#{install_dir}/version-manifest.*.txt").each do |version_manifest_txt_path|
# Simply append the listing part. The first 4 lines are the package name, blank lines
# listing headers and a separator.
shellout! "tail -n +5 #{version_manifest_txt_path} >> #{main_txt_manifest}"
FileUtils.rm version_manifest_txt_path
end
end

if project.name == "installer"
Expand Down
2 changes: 1 addition & 1 deletion release.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"nightly-a7": {
"OMNIBUS_SOFTWARE_VERSION": "43365c0198e2e8bfd62287db53e96512792f9666",
"OMNIBUS_RUBY_VERSION": "f614b2ccc11250b836f346007da49226e198b28e",
"OMNIBUS_RUBY_VERSION": "7ff6fe13aa37efbe5bb929837643c9ef2b3109db",
"JMXFETCH_VERSION": "0.49.6",
"JMXFETCH_HASH": "f06bdac1f8ec41daf9b9839ac883f1865a068b04810ea82197b8a6afb9369cb9",
"MACOS_BUILD_VERSION": "master",
Expand Down