diff --git a/Dockerfile b/Dockerfile index 489a714f51..084523a802 100644 --- a/Dockerfile +++ b/Dockerfile @@ -795,7 +795,7 @@ COPY . /work # Run the build script once to build the ops agent engine to a cache RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang WORKDIR /tmp/cache_run/golang -RUN ./pkg/rpm/build.sh &> /dev/null || true +RUN SLE_VERSION=12 ./pkg/rpm/build.sh &> /dev/null || true WORKDIR /work COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml @@ -803,7 +803,7 @@ COPY --from=sles12-build-otel /work/cache /work/cache COPY --from=sles12-build-fluent-bit /work/cache /work/cache COPY --from=sles12-build-systemd /work/cache /work/cache COPY --from=sles12-build-wrapper /work/cache /work/cache -RUN ./pkg/rpm/build.sh +RUN SLE_VERSION=12 ./pkg/rpm/build.sh COPY cmd/ops_agent_uap_plugin cmd/ops_agent_uap_plugin COPY ./builds/ops_agent_plugin.sh . @@ -900,7 +900,7 @@ COPY . /work # Run the build script once to build the ops agent engine to a cache RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang WORKDIR /tmp/cache_run/golang -RUN ./pkg/rpm/build.sh &> /dev/null || true +RUN SLE_VERSION=15 ./pkg/rpm/build.sh &> /dev/null || true WORKDIR /work COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml @@ -908,7 +908,7 @@ COPY --from=sles15-build-otel /work/cache /work/cache COPY --from=sles15-build-fluent-bit /work/cache /work/cache COPY --from=sles15-build-systemd /work/cache /work/cache COPY --from=sles15-build-wrapper /work/cache /work/cache -RUN ./pkg/rpm/build.sh +RUN SLE_VERSION=15 ./pkg/rpm/build.sh COPY cmd/ops_agent_uap_plugin cmd/ops_agent_uap_plugin COPY ./builds/ops_agent_plugin.sh . @@ -921,6 +921,111 @@ COPY --from=sles15-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent COPY --from=sles15-build /google-cloud-ops-agent*.rpm / COPY --from=sles15-build /google-cloud-ops-agent-plugin*.tar.gz / +# ====================================== +# Build Ops Agent for sles-16 +# ====================================== + +FROM opensuse/leap:16.0 AS sles16-build-base +ARG OPENJDK_MAJOR_VERSION + +RUN set -x; zypper -n refresh && \ + zypper -n update && \ + zypper -n install git systemd autoconf automake flex libtool libcurl-devel libopenssl-devel libyajl-devel gcc gcc-c++ zlib-devel rpm-build expect cmake systemd-devel systemd-rpm-macros unzip zip 'bison>3' +# Allow fluent-bit to find systemd +RUN ln -fs /usr/lib/systemd /lib/systemd +COPY --from=openjdk-install /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/ /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk +ENV JAVA_HOME /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/ +COPY --from=cmake-install-recent /cmake.sh /cmake.sh +RUN set -x; bash /cmake.sh --skip-license --prefix=/usr/local + + +SHELL ["/bin/bash", "-c"] + +# Install golang +ARG TARGETARCH +ARG GO_VERSION +ADD https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz /tmp/go${GO_VERSION}.tar.gz +RUN set -xe; \ + tar -xf /tmp/go${GO_VERSION}.tar.gz -C /usr/local +ENV PATH="${PATH}:/usr/local/go/bin" + + +FROM sles16-build-base AS sles16-build-otel +WORKDIR /work +# Download golang deps +COPY ./submodules/opentelemetry-operations-collector/go.mod ./submodules/opentelemetry-operations-collector/go.sum submodules/opentelemetry-operations-collector/ +RUN cd submodules/opentelemetry-operations-collector && go mod download + +COPY ./submodules/opentelemetry-java-contrib submodules/opentelemetry-java-contrib +# Install gradle. The first invocation of gradlew does this +RUN cd submodules/opentelemetry-java-contrib && ./gradlew --no-daemon -Djdk.lang.Process.launchMechanism=vfork tasks +COPY ./submodules/opentelemetry-operations-collector submodules/opentelemetry-operations-collector +COPY ./builds/otel.sh . +RUN \ + unset OTEL_TRACES_EXPORTER && \ + unset OTEL_EXPORTER_OTLP_TRACES_ENDPOINT && \ + unset OTEL_EXPORTER_OTLP_TRACES_PROTOCOL && \ + ./otel.sh /work/cache/ + +FROM sles16-build-base AS sles16-build-fluent-bit +WORKDIR /work +COPY ./submodules/fluent-bit submodules/fluent-bit +COPY ./builds/fluent_bit.sh . +RUN ./fluent_bit.sh /work/cache/ + + +FROM sles16-build-base AS sles16-build-systemd +WORKDIR /work +COPY ./systemd systemd +COPY ./builds/systemd.sh . +RUN ./systemd.sh /work/cache/ + + +FROM sles16-build-base AS sles16-build-golang-base +WORKDIR /work +COPY go.mod go.sum ./ +# Fetch dependencies +RUN go mod download +COPY confgenerator confgenerator +COPY apps apps +COPY internal internal + + +FROM sles16-build-golang-base AS sles16-build-wrapper +WORKDIR /work +COPY cmd/agent_wrapper cmd/agent_wrapper +COPY ./builds/agent_wrapper.sh . +RUN ./agent_wrapper.sh /work/cache/ + + +FROM sles16-build-golang-base AS sles16-build +WORKDIR /work +COPY . /work + +# Run the build script once to build the ops agent engine to a cache +RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang +WORKDIR /tmp/cache_run/golang +RUN SLE_VERSION=16 ./pkg/rpm/build.sh &> /dev/null || true +WORKDIR /work + +COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY --from=sles16-build-otel /work/cache /work/cache +COPY --from=sles16-build-fluent-bit /work/cache /work/cache +COPY --from=sles16-build-systemd /work/cache /work/cache +COPY --from=sles16-build-wrapper /work/cache /work/cache +RUN SLE_VERSION=16 ./pkg/rpm/build.sh + +COPY cmd/ops_agent_uap_plugin cmd/ops_agent_uap_plugin +COPY ./builds/ops_agent_plugin.sh . +RUN ./ops_agent_plugin.sh /work/cache/ +RUN ./pkg/plugin/build.sh /work/cache sles16 + + +FROM scratch AS sles16 +COPY --from=sles16-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-sles-16.tgz +COPY --from=sles16-build /google-cloud-ops-agent*.rpm / +COPY --from=sles16-build /google-cloud-ops-agent-plugin*.tar.gz / + # ====================================== # Build Ops Agent for ubuntu-jammy # ====================================== @@ -1230,6 +1335,7 @@ COPY --from=bullseye /* / COPY --from=trixie /* / COPY --from=sles12 /* / COPY --from=sles15 /* / +COPY --from=sles16 /* / COPY --from=jammy /* / COPY --from=noble /* / COPY --from=questing /* / \ No newline at end of file diff --git a/dockerfiles/compile.go b/dockerfiles/compile.go index 47dd30e9f3..1115147f53 100644 --- a/dockerfiles/compile.go +++ b/dockerfiles/compile.go @@ -182,7 +182,7 @@ RUN set -x; \ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 1 \ --slave /usr/bin/g++ g++ /usr/bin/g++-8 && \ update-alternatives --set gcc /usr/bin/gcc-8` + installJava + installCMake, - package_build: "RUN ./pkg/rpm/build.sh", + package_build: "RUN SLE_VERSION=12 ./pkg/rpm/build.sh", tar_distro_name: "sles-12", package_extension: "rpm", }, @@ -194,10 +194,22 @@ RUN set -x; \ zypper -n install git systemd autoconf automake flex libtool libcurl-devel libopenssl-devel libyajl-devel gcc gcc-c++ zlib-devel rpm-build expect cmake systemd-devel systemd-rpm-macros unzip zip 'bison>3' # Allow fluent-bit to find systemd RUN ln -fs /usr/lib/systemd /lib/systemd` + installJava + installCMake, - package_build: "RUN ./pkg/rpm/build.sh", + package_build: "RUN SLE_VERSION=15 ./pkg/rpm/build.sh", tar_distro_name: "sles-15", package_extension: "rpm", }, + { + from_image: "opensuse/leap:16.0", + target_name: "sles16", + install_packages: `RUN set -x; zypper -n refresh && \ + zypper -n update && \ + zypper -n install git systemd autoconf automake flex libtool libcurl-devel libopenssl-devel libyajl-devel gcc gcc-c++ zlib-devel rpm-build expect cmake systemd-devel systemd-rpm-macros unzip zip 'bison>3' +# Allow fluent-bit to find systemd +RUN ln -fs /usr/lib/systemd /lib/systemd` + installJava + installCMake, + package_build: "RUN SLE_VERSION=16 ./pkg/rpm/build.sh", + tar_distro_name: "sles-16", + package_extension: "rpm", + }, { from_image: "ubuntu:jammy", target_name: "jammy", diff --git a/go.mod b/go.mod index 63723ccbae..69c6300321 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( buf.build/go/protoyaml v0.3.1 cloud.google.com/go/secretmanager v1.15.0 github.com/GoogleCloudPlatform/google-guest-agent v0.0.0-20250924181420-23412fbd6228 - github.com/GoogleCloudPlatform/opentelemetry-operations-collector/integration_test/gce-testing-internal v0.0.0-20260309230533-1603c95a7c02 + github.com/GoogleCloudPlatform/opentelemetry-operations-collector/integration_test/gce-testing-internal v0.0.0-20260316191654-9d7f77d828ab github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 go.opentelemetry.io/collector/pdata v1.48.0 golang.org/x/sync v0.19.0 diff --git a/go.sum b/go.sum index 166123958f..c7fef386f7 100644 --- a/go.sum +++ b/go.sum @@ -60,6 +60,8 @@ github.com/GoogleCloudPlatform/google-guest-agent v0.0.0-20250924181420-23412fbd github.com/GoogleCloudPlatform/google-guest-agent v0.0.0-20250924181420-23412fbd6228/go.mod h1:31SvkAl6ORtir1odRpTl92XpTtn52GnBAHPtCKDSePo= github.com/GoogleCloudPlatform/opentelemetry-operations-collector/integration_test/gce-testing-internal v0.0.0-20260309230533-1603c95a7c02 h1:x9hp68dyjsNd7b+2owUJH7s7OB+QBT4A0sqtkK/WgBo= github.com/GoogleCloudPlatform/opentelemetry-operations-collector/integration_test/gce-testing-internal v0.0.0-20260309230533-1603c95a7c02/go.mod h1:8hU3pEOeeje4IXMFFGZhcBL7r173zcnD4nC0EA6pf1Q= +github.com/GoogleCloudPlatform/opentelemetry-operations-collector/integration_test/gce-testing-internal v0.0.0-20260316191654-9d7f77d828ab h1:cX+4DUpVjnxwp91whwK3UH5edT+4++bJOHXmOIpIIPU= +github.com/GoogleCloudPlatform/opentelemetry-operations-collector/integration_test/gce-testing-internal v0.0.0-20260316191654-9d7f77d828ab/go.mod h1:8hU3pEOeeje4IXMFFGZhcBL7r173zcnD4nC0EA6pf1Q= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 h1:sBEjpZlNHzK1voKq9695PJSX2o5NEXl7/OL3coiIY0c= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0/go.mod h1:P4WPRUkOhJC13W//jWpyfJNDAIpvRbAUIYLX/4jtlE0= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0 h1:owcC2UnmsZycprQ5RfRgjydWhuoxg71LUfyiQdijZuM= diff --git a/integration_test/ops_agent_test/main_test.go b/integration_test/ops_agent_test/main_test.go index eeacf2e5fe..e6a585759a 100644 --- a/integration_test/ops_agent_test/main_test.go +++ b/integration_test/ops_agent_test/main_test.go @@ -2588,12 +2588,23 @@ func testDefaultMetrics(ctx context.Context, t *testing.T, logger *log.Logger, v if !gce.IsWindows(vm.ImageSpec) { // Enable swap file: https://linuxize.com/post/create-a-linux-swap-file/ // We do this so that swap file metrics will show up. - _, err := gce.RunRemotely(ctx, logger, vm, strings.Join([]string{ + swapCmds := []string{ "sudo dd if=/dev/zero of=/swapfile bs=1024 count=102400", "sudo chmod 600 /swapfile", "(sudo mkswap /swapfile || sudo /usr/sbin/mkswap /swapfile)", "(sudo swapon /swapfile || sudo /usr/sbin/swapon /swapfile)", - }, " && ")) + } + // TODO: moving isSLES16 to gce_testing.go + isSles16 := strings.Contains(vm.ImageSpec, "sles-16") + if isSles16 { + // SLES 16 uses btrfs by default, which does not support swapfiles created via dd without special handling. + // https://www.suse.com/support/kb/doc/?id=000019943 + swapCmds = []string{ + "sudo btrfs filesystem mkswapfile --size 100M --uuid clear /swapfile", + "(sudo swapon /swapfile || sudo /usr/sbin/swapon /swapfile)", + } + } + _, err := gce.RunRemotely(ctx, logger, vm, strings.Join(swapCmds, " && ")) if err != nil { t.Fatalf("Failed to enable swap file: %v", err) } diff --git a/kokoro/config/build/presubmit/sles15_aarch64.gcl b/kokoro/config/build/presubmit/sles15_aarch64.gcl index 1041e8e918..4a5a002f78 100644 --- a/kokoro/config/build/presubmit/sles15_aarch64.gcl +++ b/kokoro/config/build/presubmit/sles15_aarch64.gcl @@ -3,7 +3,7 @@ import '../common.gcl' as common config build = common.build { params { environment { - DISTRO = 'sles15' + DISTRO = 'sles16' PKGFORMAT = 'rpm' } } diff --git a/kokoro/config/build/presubmit/sles15_x86_64.gcl b/kokoro/config/build/presubmit/sles15_x86_64.gcl index 1041e8e918..4a5a002f78 100644 --- a/kokoro/config/build/presubmit/sles15_x86_64.gcl +++ b/kokoro/config/build/presubmit/sles15_x86_64.gcl @@ -3,7 +3,7 @@ import '../common.gcl' as common config build = common.build { params { environment { - DISTRO = 'sles15' + DISTRO = 'sles16' PKGFORMAT = 'rpm' } } diff --git a/kokoro/config/test/ops_agent/presubmit/sles15_aarch64.gcl b/kokoro/config/test/ops_agent/presubmit/sles15_aarch64.gcl index 1279b4897e..ecac3b9349 100644 --- a/kokoro/config/test/ops_agent/presubmit/sles15_aarch64.gcl +++ b/kokoro/config/test/ops_agent/presubmit/sles15_aarch64.gcl @@ -3,7 +3,7 @@ import 'common.gcl' as common config build = common.ops_agent_test { params { environment { - TARGET = 'sles15' + TARGET = 'sles16' ARCH = 'aarch64' } } diff --git a/kokoro/config/test/ops_agent/presubmit/sles15_x86_64.gcl b/kokoro/config/test/ops_agent/presubmit/sles15_x86_64.gcl index 0508fe0124..98b80a3b57 100644 --- a/kokoro/config/test/ops_agent/presubmit/sles15_x86_64.gcl +++ b/kokoro/config/test/ops_agent/presubmit/sles15_x86_64.gcl @@ -3,7 +3,7 @@ import 'common.gcl' as common config build = common.ops_agent_test { params { environment { - TARGET = 'sles15' + TARGET = 'sles16' ARCH = 'x86_64' } } diff --git a/kokoro/config/test/third_party_apps/presubmit/sles15_aarch64.gcl b/kokoro/config/test/third_party_apps/presubmit/sles15_aarch64.gcl index 65024bfea8..7789bf4aef 100644 --- a/kokoro/config/test/third_party_apps/presubmit/sles15_aarch64.gcl +++ b/kokoro/config/test/third_party_apps/presubmit/sles15_aarch64.gcl @@ -3,7 +3,7 @@ import 'common.gcl' as common config build = common.third_party_apps_test { params { environment { - TARGET = 'sles15' + TARGET = 'sles16' ARCH = 'aarch64' } } diff --git a/kokoro/config/test/third_party_apps/presubmit/sles15_x86_64.gcl b/kokoro/config/test/third_party_apps/presubmit/sles15_x86_64.gcl index 1d3afe1f56..da5ca29e1c 100644 --- a/kokoro/config/test/third_party_apps/presubmit/sles15_x86_64.gcl +++ b/kokoro/config/test/third_party_apps/presubmit/sles15_x86_64.gcl @@ -3,7 +3,7 @@ import 'common.gcl' as common config build = common.third_party_apps_test { params { environment { - TARGET = 'sles15' + TARGET = 'sles16' ARCH = 'x86_64' } } diff --git a/pkg/rpm/build.sh b/pkg/rpm/build.sh index 23b0f55270..5fe7275b26 100755 --- a/pkg/rpm/build.sh +++ b/pkg/rpm/build.sh @@ -19,9 +19,14 @@ set -ex . VERSION # Build .rpms +RPMBUILD_ARGS=() +if [[ -n "${SLE_VERSION}" ]]; then + RPMBUILD_ARGS+=(--define "sle_version ${SLE_VERSION}") +fi rpmbuild --define "_source_filedigest_algorithm md5" \ --define "package_version ${PKG_VERSION//[^a-zA-Z0-9.]/.}" \ --define "_sourcedir $(pwd)" \ --define "_rpmdir $(pwd)" \ + "${RPMBUILD_ARGS[@]}" \ -ba pkg/rpm/google-cloud-ops-agent.spec cp $(uname -m)/google-cloud-ops-agent*.rpm / diff --git a/project.yaml b/project.yaml index ba9c3ad171..4881c3ded3 100644 --- a/project.yaml +++ b/project.yaml @@ -205,6 +205,22 @@ targets: - suse-cloud:sles-15-arm64 exhaustive: - suse-cloud:sles-15-sp6-arm64 + sles16: + os_versions: [sles-16*, opensuse-leap-16*] + package_extension: + rpm + architectures: + x86_64: + test_distros: + representative: + - suse-cloud:sles-16-0-x86-64 + exhaustive: + - suse-sap-cloud:sles-sap-16-0-x86-64 + aarch64: + test_distros: + representative: + - suse-cloud:sles-16-0-arm64 + exhaustive: windows: package_extension: goo