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

[proposal] Use golang based cp tool rather than busybox in autoinstrumentation images. #1727

Closed
wants to merge 3 commits into from

Conversation

jvoravong
Copy link
Contributor

@jvoravong jvoravong commented May 10, 2023

Updates: #1600

As mentioned in previous SIG meeting and related issues, we would like to propose a replacement to the busybox base image used in the auto-instrumentation images. More work would still have to be done, but I think we have enough here start discussions. Happy to answer questions or take improvements.

This PR Proposal:

  • Adds a new autoinstrumentation utils docker image and integrates it into the java image.
  • I would like to propose creating and using a utils image because it could make it easier for downstream releases to adopt it. I'm having to work with several instrumentation team's and releases (example java dockerfile), having a utils image could help our downstream releases.
  • I would prefer if we went with a go based cp implementation because most of this code base is already written in go.

@jvoravong jvoravong requested a review from a team as a code owner May 10, 2023 00:49
args := os.Args[1:]

if len(args) < 2 {
return errors.New("Not enough arguments given.")
Copy link
Member

Choose a reason for hiding this comment

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

can we make this more user-friendly? How many arguments are expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still working on this and nearly done. I did upload another commit that is unrelated to this.

@@ -25,6 +25,7 @@ jobs:
grep -v '\#' versions.txt | grep opentelemetry-collector | awk -F= '{print "OTELCOL_VERSION="$2}' >> $GITHUB_ENV
grep -v '\#' versions.txt | grep targetallocator | awk -F= '{print "TARGETALLOCATOR_VERSION="$2}' >> $GITHUB_ENV
grep -v '\#' versions.txt | grep operator-opamp-bridge | awk -F= '{print "OPERATOR_OPAMP_BRIDGE_VERSION="$2}' >> $GITHUB_ENV
grep -v '\#' versions.txt | grep autoinstrumentation-utils | awk -F= '{print "AUTO_INSTRUMENTATION_UTILS_VERSION="$2}' >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why this is needed the utils version is not need to be listed in the root versions.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We probably don't need this, I was doing my best trying to understand the publish logic. WiIl fix later.

@@ -0,0 +1,11 @@
# This utils image is intended to be used as a base image for OpenTelemetry Operator
Copy link
Member

Choose a reason for hiding this comment

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

It's not a base image. The docker image is used just to get the tool into the base image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. After some more thought, I think we could rework this image and use it as a base image and cut down on lines of code in several areas. Checking...

Copy link
Contributor Author

@jvoravong jvoravong May 24, 2023

Choose a reason for hiding this comment

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

I was able to get change the utils image name to cp. I was able to make it a base image which I believe makes understandability and adoptability much easier. See: autoinstrumentation/cp/Dockerfil

Related Code Changes

Copy link
Member

Choose a reason for hiding this comment

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

Could we rename the directory to cp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Started the changes for this, still need to add more soon.

id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-utils
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to be more explicit here e.g. ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-cp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Depending on where the final code for this lives, this can vary. If we keep the cp code here in this repo, we will use the proposed name.

# This utils image is intended to be used as a base image for OpenTelemetry Operator
# autoinstrumentation images. The utils will allow autoinstrumentation packages to be
# copied (via a go based cp command) from the init container to the final destination volume.
FROM golang as utils
Copy link
Contributor

Choose a reason for hiding this comment

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

This Dockerfile still results in an image that is distributed with the golang base image right? What is golang built on top of? I think this would need to be a multistage build to avoid this where the last stage is FROM scratch.

Copy link
Contributor Author

@jvoravong jvoravong May 24, 2023

Choose a reason for hiding this comment

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

You are correct. I refactored the code and it now lives in autoinstrumentation/cp/Dockerfile.
I would really like us to follow a similar pattern shown in this file whether or not the code is based off of rust or golang. This way downstream auto-instrumentation vendors don't have to worry about the implementation because it is abstracted enough for them not to care about it.
Let me know your thoughts if you have them.

Related Code Changes

Copy link
Member

@frzifus frzifus left a comment

Choose a reason for hiding this comment

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

Only as a reference: #1698 (comment)

@jvoravong
Copy link
Contributor Author

  • Still finishing up the code that is being refactored from utils.go to cp.go based on the unresolved conversation above. Most of it is done, still adding support for edge cases and error checking.
  • Was able to make some good improvements to the Dockerfile (cp) to show how we can make our auto-instrumentation Docker files and images more extendable for downstream vendors.
  • I'm out sick today, so I wanted to make sure to get this update out before the next SIG meeting.

@jvoravong jvoravong mentioned this pull request May 24, 2023
@pavolloffay
Copy link
Member

@jvoravong what is the status of this PR?

@jvoravong
Copy link
Contributor Author

I haven't been able to commit more time to this work. Going to close this PR for now. Will open a new PR in the future if I can work on it later.

@jvoravong jvoravong closed this Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants