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

file-log plugin fails to log to /dev/stdout with Permission Denied error #12129

Open
1 task done
gsadhani opened this issue Nov 30, 2023 · 8 comments
Open
1 task done

Comments

@gsadhani
Copy link

gsadhani commented Nov 30, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

3.4

Current Behavior

file-log plugin fails to log to /dev/stdout with Permission Denied error when running in a container.

kong-gateway-6d98fccc96-pzzvv proxy 2023/11/29 12:17:09 [error] 1263#0: *1315 [kong] handler.lua:56 [file-log] 
failed to open the file: Permission denied while logging request, client: xxx.18.82.100, server: kong,
request: "GET /v1/xxxxx/xxx HTTP/2.0", upstream: "http://100.64.92.168:9002/v1/xxxxx/xxx", host: "dev14.xxxxxxx.io"

I have tried the following:

  1. Changing permissions of /dev/stdout to 777
  2. Creating a link from /var/log/kong/kong.log to /dev/stdout and log to /var/log/kong/kong.log
ln -sf /dev/stdout /var/log/kong/kong.log

But the issue persists.

Expected Behavior

The file-log plugin should be able to log to /dev/stdout as indicated in the documentation.

Steps To Reproduce

  1. Configure file-log plugin as below:
apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
  name: file-log
  annotations:
    kubernetes.io/ingress.class: kong
  labels:
    global: "true"
config:
  path: "/dev/stdout"
plugin: file-log
  1. Make API calls routed through the gateway

Anything else?

No response

@chobits chobits added task/bug and removed task/bug labels Dec 1, 2023
@chobits
Copy link
Contributor

chobits commented Dec 4, 2023

Could you use some other methods, not using kong. to open this file to check if this file could be opened normally?

For example, echo "some messages blah blah..." > /dev/stdout, and make sure that the new command has the same user/group of your kong server.

@chobits chobits added the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label Dec 4, 2023
@gsadhani
Copy link
Author

gsadhani commented Dec 6, 2023

Sure @chobits.

See output below:

kubectl exec kong-gateway-7b5c4f9c5-jkznp -n kong -it -- sh
# echo "hello" > /dev/stdout
hello
# su - kong
su: warning: cannot change directory to /home/kong: No such file or directory
$
$ echo "hello as kong" > /dev/stdout
-sh: 1: cannot create /dev/stdout: Permission denied
$ whoami
kong
$ ls -lt /dev/stdout
lrwxrwxrwx 1 root root 15 Dec  6 05:51 /dev/stdout -> /proc/self/fd/1
$ ls -lt /proc/self/fd/1
lrwx------ 1 kong kong 64 Dec  6 11:56 /proc/self/fd/1 -> /dev/pts/0
$ su -
# 
# ls -lt /dev/stdout
lrwxrwxrwx 1 root root 15 Dec  6 05:51 /dev/stdout -> /proc/self/fd/1
# ls -lt /proc/self/fd/1
lrwx------ 1 root root 64 Dec  6 12:00 /proc/self/fd/1 -> /dev/pts/0

@chobits
Copy link
Contributor

chobits commented Dec 7, 2023

$ echo "hello as kong" > /dev/stdout
-sh: 1: cannot create /dev/stdout: Permission denied
$ whoami
kong

I'm not very familiar with the permission control under linux system, but it seems that your kong user/group could not modify the stdout file with irght permission

@chobits
Copy link
Contributor

chobits commented Dec 7, 2023

It seems a known issue, i search it and find some questions associated to it, but not find a good solution for k8s container.

https://discuss.konghq.com/t/file-log-plugin-not-able-to-log-to-dev-stdout/9347

#8067

@gsadhani
Copy link
Author

gsadhani commented Dec 7, 2023

@chobits thanks for taking a look. Yes, this is the same issue as #8067. I created this issue as that issue was closed without resolution.

Do you recommend opening another issue in https://github.com/Kong/docker-kong.

@chobits
Copy link
Contributor

chobits commented Dec 7, 2023

hi @gsadhani

keep your question here, discussion is more lively. And most kong developers and fans will see it.

@ADD-SP ADD-SP removed the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label Dec 18, 2023
@ADD-SP
Copy link
Contributor

ADD-SP commented Jan 8, 2024

I created an internal ticket (KAG-3501) to track this issue.

@chronolaw
Copy link
Contributor

@ADD-SP , could you add the ticket number here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants