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

Auto-instrumentation cp operation not permitted #2726

Closed
smallc2009 opened this issue Mar 7, 2024 · 16 comments · Fixed by #3214
Closed

Auto-instrumentation cp operation not permitted #2726

smallc2009 opened this issue Mar 7, 2024 · 16 comments · Fixed by #3214
Labels
area:auto-instrumentation Issues for auto-instrumentation bug Something isn't working needs triage

Comments

@smallc2009
Copy link

Component(s)

instrumentation

What happened?

Description

when I add annotation to our .net application, it is not able to inject the library and produces the error logs from init container.

I set up USER 64189 in Dockerfile. I'm running pod with non-root user, the following securityContext options are set in our helm deployment template.

allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: false
runAsNonRoot: true

Steps to Reproduce

Enable RunAsNonRoot option

Expected Result

inti container copy library to the application pod without errors

Actual Result

Kubernetes Version

1.26.9

Operator version

0.93.0

Collector version

0.93.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")

Log output

2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration.binder/7.0.0/lib/net7.0': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration.binder/7.0.0/lib': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration.binder/7.0.0': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration.binder': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/runtimes/win/native/libzstd.dll': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/runtimes/win/native/snappy32.dll': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/runtimes/win/native/snappy64.dll': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/runtimes/win/native': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/runtimes/win': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/runtimes': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/lib/netstandard2.1/MongoDB.Driver.Core.dll': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/lib/netstandard2.1': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3/lib': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core/2.13.3': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/mongodb.driver.core': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration/7.0.0/lib/net7.0/Microsoft.Extensions.Configuration.dll': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration/7.0.0/lib/net7.0': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration/7.0.0/lib': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration/7.0.0': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0/microsoft.extensions.configuration': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64/net7.0': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store/x64': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/./store': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve times of '/otel-auto-instrumentation/.': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve ownership of '/otel-auto-instrumentation/.': Operation not permitted
2023-04-04T00:57:56-04:00 cp: can't preserve permissions of '/otel-auto-instrumentation/.': Operation not permitted

Additional context

No response

@pavolloffay
Copy link
Member

cc) @iblancasa

@pavolloffay pavolloffay added the area:auto-instrumentation Issues for auto-instrumentation label Mar 7, 2024
@iblancasa
Copy link
Contributor

@pavolloffay thanks for the heads-up!

Can you check if #2695 fixes your issue?

@berry2012
Copy link

berry2012 commented May 27, 2024

Looks like it is not resolved yet. Reproduced the issue with the ffg:

    spec:
      # securityContext:
      #   seccompProfile:
      #     type: RuntimeDefault
      #   runAsNonRoot: true 
      #   runAsUser: 5678    
      containers:
      - image: XYZ/app
        name: flask-app
        # securityContext:
        #   allowPrivilegeEscalation: false
        #   readOnlyRootFilesystem: true # or false
        #   capabilities:
        #     drop:
        #       - ALL       

Container user 5678

Error

     cp: preserving times for '/otel-auto-instrumentation-python/.': Operation not permitted

@iblancasa
Copy link
Contributor

Looks like it is not resolved yet. Reproduced the issue with the ffg:

  1. What does it mean ffg?
  2. What version of the operator are you using?
  3. Are you using the default container images for the autoinstrumentation?
  4. The configuration you provided seems it have a lot of commented fields. Can you try the examples we have as part of the E2E tests to see if you reproduce the issues?

@jurgenroels
Copy link

Hi @iblancasa ,

We are encountering the same issue when trying to instrument Nginx:
image

Some additional information:

  • Operator version: v0.104.0
  • We are using a default container image for Nginx: "NGINX_VERSION=1.23.3" unprivileged (We also tried other images)

Are there any suggestions on how to fix this?

@iblancasa
Copy link
Contributor

Would you be able to provide a reproducer? @jurgenroels

@jurgenroels
Copy link

@iblancasa What can we use to make the reproducer? This way we can see what it is collecting and if we can share it.

@iblancasa
Copy link
Contributor

@jurgenroels if you can reproduce it using kind and provide the image, Instrumentation CR and Deployment used it would help.

@jurgenroels
Copy link

jurgenroels commented Aug 9, 2024

@iblancasa in attachment you can find the files to reproduce. We also tested other Nginx images
We are using TKGI.
The files: yaml.zip

@iblancasa
Copy link
Contributor

Please, provide one of the images or Dockerfiles of the container image to instrument.

@jurgenroels
Copy link

@excitedbumpkin
Copy link

excitedbumpkin commented Aug 12, 2024

My guess would be "cp -ar ..." needs to be changed to "cp -r ..."

cp -ar /opt/opentelemetry/* ${NGINX_AGENT_DIR_FULL} \n

This has been done for other instrumentations but apparently not for nginx.

@iblancasa
Copy link
Contributor

I was not able to reproduce but... yes. There were other instrumentation where something similar happened.

@jurgenroels
Copy link

Thanks @excitedbumpkin and @iblancasa
We'll try it when the release is available

@tobgen
Copy link

tobgen commented Sep 6, 2024

I would like to reopen this one.
Because it applies not only for nginx, the nodejs image have the same issue as this one.

"cp: can't preserve permissions of '/otel-auto-instrumentation-nodejs/.': Operation not permitted"

This will fail on all containers running as a non-root user.

@iblancasa
Copy link
Contributor

I would like to reopen this one. Because it applies not only for nginx, the nodejs image have the same issue as this one.

"cp: can't preserve permissions of '/otel-auto-instrumentation-nodejs/.': Operation not permitted"

This will fail on all containers running as a non-root user.

Please, create a new issue for that. It should be a different issue because the NodeJS libraries are copied like:

Command:   []string{"cp", "-r", "/autoinstrumentation/.", nodejsInstrMountPath},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:auto-instrumentation Issues for auto-instrumentation bug Something isn't working needs triage
Projects
None yet
7 participants