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

[autoinstrumentation] remove dependency on busybox, use native cp #3682

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions .chloggen/native_cp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: autoinstrumentation

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Implement native cp, remove dependency on busybox for all autoinstrumentation images

# One or more tracking issues related to the change
issues: [1600]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ on:
- 'autoinstrumentation/apache-httpd/**'
- '.github/workflows/publish-autoinstrumentation-apache-httpd.yaml'
workflow_dispatch:
workflow_run:
workflows: [ "Publish cp Auto-Instrumentation" ]
branches: [ main ]
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
publish:
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04

steps:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/publish-autoinstrumentation-cp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Publish cp Auto-Instrumentation"

on:
push:
paths:
- 'autoinstrumentation/cp/**'
- '.github/workflows/publish-autoinstrumentation-cp.yaml'
branches:
- main
pull_request:
paths:
- 'autoinstrumentation/cp/**'
- '.github/workflows/publish-autoinstrumentation-cp.yaml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
publish:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Read version
run: echo "VERSION=$(cat autoinstrumentation/cp/version.txt)" >> $GITHUB_ENV

- name: Login to GitHub Package Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create docker image
run: |
cd autoinstrumentation/cp
VERSION=${{ env.VERSION }} make docker

6 changes: 6 additions & 0 deletions .github/workflows/publish-autoinstrumentation-dotnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ on:
- 'autoinstrumentation/dotnet/**'
- '.github/workflows/publish-autoinstrumentation-dotnet.yaml'
workflow_dispatch:
workflow_run:
workflows: [ "Publish cp Auto-Instrumentation" ]
branches: [ main ]
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
publish:
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04

steps:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/publish-autoinstrumentation-java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
- 'autoinstrumentation/java/**'
- '.github/workflows/publish-autoinstrumentation-java.yaml'
workflow_dispatch:
workflow_run:
workflows: [ "Publish cp Auto-Instrumentation" ]
branches: [ main ]
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -20,6 +25,7 @@ concurrency:

jobs:
publish:
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04

steps:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/publish-autoinstrumentation-nodejs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
- 'autoinstrumentation/nodejs/**'
- '.github/workflows/publish-autoinstrumentation-nodejs.yaml'
workflow_dispatch:
workflow_run:
workflows: [ "Publish cp Auto-Instrumentation" ]
branches: [ main ]
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -20,6 +25,7 @@ concurrency:

jobs:
publish:
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04

steps:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/publish-autoinstrumentation-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
- 'autoinstrumentation/python/**'
- '.github/workflows/publish-autoinstrumentation-python.yaml'
workflow_dispatch:
workflow_run:
workflows: [ "Publish cp Auto-Instrumentation" ]
branches: [ main ]
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -20,6 +25,7 @@ concurrency:

jobs:
publish:
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ config/rbac/certmanager-permissions/
build
node_modules
package-lock.json
autoinstrumentation/cp/bin/
19 changes: 7 additions & 12 deletions autoinstrumentation/apache-httpd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

############################
# STEP 1 download the webserver agent
############################
FROM alpine:latest as agent

ARG version
Expand All @@ -13,14 +9,13 @@ RUN mkdir agent
RUN wget -c https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/download/webserver%2Fv$version/opentelemetry-webserver-sdk-x64-linux.tgz
RUN unzip -p opentelemetry-webserver-sdk-x64-linux.tgz | tar -zx -C agent

############################
# STEP 2 download the webserver agent
############################
FROM alpine:latest

COPY --from=agent /opt/opentelemetry/agent/opentelemetry-webserver-sdk /opt/opentelemetry

RUN chmod 775 -R /opt/opentelemetry/
RUN chmod a+w /opt/opentelemetry/logs

CMD ["cat", "Just delivering the Opentelemetry Apache/Nginx agent"]
FROM ghcr.io/open-telemetry/opentelemetry-operator/cp:1.0.0 AS cp

FROM scratch

COPY --from=cp /cp /usr/bin/cp

COPY --from=agent /opt/opentelemetry/agent/opentelemetry-webserver-sdk /opt/opentelemetry
7 changes: 7 additions & 0 deletions autoinstrumentation/cp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM scratch

ARG cp

ADD $cp /cp

ENTRYPOINT ["/cp"]
9 changes: 9 additions & 0 deletions autoinstrumentation/cp/Dockerfile.fips
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM scratch

LABEL fips=true

ARG cp

ADD $cp /cp

ENTRYPOINT ["/cp"]
7 changes: 7 additions & 0 deletions autoinstrumentation/cp/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM scratch

ARG cp

ADD $cp /cp.exe

ENTRYPOINT ["/cp.exe"]
97 changes: 97 additions & 0 deletions autoinstrumentation/cp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
VERSION?=latest
REPOSITORY?=ghcr.io/open-telemetry/opentelemetry-operator
GO_BUILD_LDFLAGS ?= '-w -s -extldflags "-static"'

.PHONY := build
build:
mkdir -p bin
CGO_ENABLED=0 go build -trimpath -o ./bin/cp_$(GOOS)_$(GOARCH)$(EXTRA)$(EXTENSION) -ldflags $(GO_BUILD_LDFLAGS)

bin/cp_linux_amd64: main.go go.mod
GOOS=linux GOARCH=amd64 EXTENSION="" EXTRA="" make build

bin/cp_linux_arm64: main.go go.mod
GOOS=linux GOARCH=arm64 EXTENSION="" EXTRA="" make build

bin/cp_linux_ppc64le: main.go go.mod
GOOS=linux GOARCH=ppc64le EXTENSION="" EXTRA="" make build

bin/cp_linux_s390x: main.go go.mod
GOOS=linux GOARCH=s390x EXTENSION="" EXTRA="" make build

bin/cp_windows_arm64.exe: main.go go.mod
GOOS=windows GOARCH=arm64 EXTENSION=".exe" EXTRA="" make build

bin/cp_windows_amd64.exe: main.go go.mod
GOOS=windows GOARCH=amd64 EXTENSION=".exe" EXTRA="" make build

bin/cp_linux_amd64_fips: main.go go.mod
GOEXPERIMENT=boringcrypto GOOS=linux GOARCH=amd64 EXTENSION="" EXTRA="_fips" make build

bin/cp_linux_arm64_fips: main.go go.mod
GOEXPERIMENT=boringcrypto GOOS=linux GOARCH=arm64 EXTENSION="" EXTRA="_fips" make build

bin/cp_windows_arm64_fips.exe: main.go go.mod
GOEXPERIMENT=boringcrypto GOOS=windows GOARCH=arm64 EXTENSION=".exe" EXTRA="_fips" make build

bin/cp_windows_amd64_fips.exe: main.go go.mod
GOEXPERIMENT=boringcrypto GOOS=windows GOARCH=amd64 EXTENSION=".exe" EXTRA="_fips" make build

## Docker build

.PHONY := docker_linux_amd64
docker_linux_amd64: bin/cp_linux_amd64
docker buildx build --platform="linux/amd64" --push -t $(REPOSITORY)/cp_linux_amd64:$(VERSION) --build-arg cp=bin/cp_linux_amd64 .

.PHONY := docker_linux_arm64
docker_linux_arm64: bin/cp_linux_arm64
docker buildx build --platform="linux/arm64" --push -t $(REPOSITORY)/cp_linux_arm64:$(VERSION) --build-arg cp=bin/cp_linux_arm64 .

.PHONY := docker_linux_ppc64le
docker_linux_ppc64le: bin/cp_linux_ppc64le
docker buildx build --platform="linux/ppc64le" --push -t $(REPOSITORY)/cp_linux_ppc64le:$(VERSION) --build-arg cp=bin/cp_linux_ppc64le .

.PHONY := docker_linux_s390x
docker_linux_s390x: bin/cp_linux_s390x
docker buildx build --platform="linux/s390x" --push -t $(REPOSITORY)/cp_linux_s390x:$(VERSION) --build-arg cp=bin/cp_linux_s390x .

.PHONY := docker_windows_arm64
docker_windows_arm64: bin/cp_windows_arm64.exe
docker buildx build --platform="windows/arm64" --push -f Dockerfile.windows -t $(REPOSITORY)/cp_windows_arm64:$(VERSION) --build-arg cp=bin/cp_windows_arm64.exe .

.PHONY := docker_windows_amd64
docker_windows_amd64: bin/cp_windows_amd64.exe
docker buildx build --platform="windows/amd64" --push -f Dockerfile.windows -t $(REPOSITORY)/cp_windows_amd64:$(VERSION) --build-arg cp=bin/cp_windows_amd64.exe .

.PHONY := docker_linux_amd64_fips
docker_linux_amd64_fips: bin/cp_linux_amd64_fips
docker buildx build --platform="linux/amd64" --push -t $(REPOSITORY)/cp_linux_amd64_fips:$(VERSION) --build-arg cp=bin/cp_linux_amd64_fips .

.PHONY := docker_linux_arm64_fips
docker_linux_arm64_fips: bin/cp_linux_arm64_fips
docker buildx build --platform="linux/arm64" --push -t $(REPOSITORY)/cp_linux_arm64_fips:$(VERSION) --build-arg cp=bin/cp_linux_arm64_fips .

.PHONY := docker_windows_amd64_fips
docker_windows_amd64_fips: bin/cp_windows_amd64_fips.exe
docker buildx build --platform="windows/amd64" --push -f Dockerfile.windows -t $(REPOSITORY)/cp_windows_amd64_fips:$(VERSION) --build-arg cp=bin/cp_windows_amd64_fips.exe .

.PHONY := docker_windows_arm64_fips
docker_windows_arm64_fips: bin/cp_windows_arm64_fips.exe
docker buildx build --platform="windows/arm64" --push -f Dockerfile.windows -t $(REPOSITORY)/cp_windows_arm64_fips:$(VERSION) --build-arg cp=bin/cp_windows_arm64_fips.exe .

.PHONY := docker
docker: docker_linux_amd64 docker_linux_arm64 docker_linux_ppc64le docker_linux_s390x docker_windows_amd64 docker_windows_arm64 docker_linux_amd64_fips docker_linux_arm64_fips docker_windows_amd64_fips docker_windows_arm64_fips
docker buildx imagetools create -t $(REPOSITORY)/cp:$(VERSION) \
$(REPOSITORY)/cp_linux_amd64:$(VERSION) \
$(REPOSITORY)/cp_linux_arm64:$(VERSION) \
$(REPOSITORY)/cp_linux_ppc64le:$(VERSION) \
$(REPOSITORY)/cp_linux_s390x:$(VERSION) \
$(REPOSITORY)/cp_windows_amd64:$(VERSION) \
$(REPOSITORY)/cp_windows_arm64:$(VERSION)

docker buildx imagetools create \
-t $(REPOSITORY)/cp:$(VERSION)-fips \
$(REPOSITORY)/cp_linux_amd64_fips:$(VERSION) \
$(REPOSITORY)/cp_linux_arm64_fips:$(VERSION) \
$(REPOSITORY)/cp_windows_amd64_fips:$(VERSION) \
$(REPOSITORY)/cp_windows_arm64_fips:$(VERSION)
27 changes: 27 additions & 0 deletions autoinstrumentation/cp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# cp

This project allows you to take a file and copy to a new location on disk with the 0400 permission mask (read-only).

# Install

## As binary

```bash
go install github.com/otel-warez/cp@latest
```

## As a docker image

```
docker pull ghcr.io/otel-warez/cp:latest
```

This image is built from scratch and will not be useful on its own, but you can use it as a layer. Here is an example:

```
FROM ghcr.io/otel-warez/cp:latest AS cp

FROM scratch AS final
COPY --from=cp /cp /usr/bin/cp
...
```
3 changes: 3 additions & 0 deletions autoinstrumentation/cp/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/otel-warez/cp

go 1.23.0
38 changes: 38 additions & 0 deletions autoinstrumentation/cp/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"fmt"
"log"
"os"
)

func main() {
if len(os.Args) != 3 {
log.Fatal("[USAGE] cp src dest")
}

data, err := os.ReadFile(os.Args[1])
if err != nil {
log.Fatal(fmt.Sprintf("error copying file: %v", err))
}

err = os.WriteFile(os.Args[2], data, 0400)

if err != nil {
log.Fatal(fmt.Sprintf("error copying file: %v", err))
}
}
1 change: 1 addition & 0 deletions autoinstrumentation/cp/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
Loading
Loading