-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
chroot missing /dev/stdout
; permission failures trying to write during nginx.conf validation
#8572
Comments
@gcolten: This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/remove-kind bug I am using v1.2.0 of the controller and I am not able to reproduce this problem. Any developer working on this will need some kind of a step-by-step guide to reproduce the problem. Several Azure users deploy using this https://kubernetes.github.io/ingress-nginx/deploy/#azure . There is no other GitHub issue with commands and outputs or Slack chat messages that have similarities with this use case on Azure. So can you help out by providing more information. Its not even certain if /dev/stdout in a chromed environment is what all users of nginx-ingress controller are asking. |
Thanks for looking at this, @longwuyuan! I now realize this may be an enhancement request, but it seems reasonable, generalizable, and simple. Request: Add symlinks inside the
Reproducing the errorHere's a simple way to reproduce the error. While it is driven by custom configuration, I do not suspect I am alone in expecting to have access to
cat << 'EOF' | patch
--- a/deploy.yaml
+++ b/deploy.yaml
@@ -402,6 +402,7 @@ spec:
- --validating-webhook=:8443
- --validating-webhook-certificate=/usr/local/certificates/cert
- --validating-webhook-key=/usr/local/certificates/key
+ - --configmap=$(POD_NAMESPACE)/http-snippet-configmap
env:
- name: POD_NAME
valueFrom:
@@ -413,7 +414,7 @@ spec:
fieldPath: metadata.namespace
- name: LD_PRELOAD
value: /usr/local/lib/libmimalloc.so
- image: k8s.gcr.io/ingress-nginx/controller:v1.2.0@sha256:d8196e3bc1e72547c5dec66d6556c0ff92a23f6d0919b206be170bc90d5f9185
+ image: k8s.gcr.io/ingress-nginx/controller-chroot:v1.2.0
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
@@ -460,6 +461,7 @@ spec:
capabilities:
add:
- NET_BIND_SERVICE
+ - SYS_CHROOT
drop:
- ALL
runAsUser: 101
@@ -618,3 +620,18 @@ webhooks:
resources:
- ingresses
sideEffects: None
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: http-snippet-configmap
+ namespace: ingress-nginx
+data:
+ server-tokens: "false"
+ # create a variable 'iserrorstatus' which is set to '0' if
+ # the status is 2xx or 3xx, otherwise '1'
+ http-snippet: |
+ map $status $iserrorstatus {
+ ~^[23] 0;
+ default 1;
+ }
EOF
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-world
annotations:
# disable access logging for successful requests
nginx.ingress.kubernetes.io/configuration-snippet: |
access_log /dev/stdout upstreaminfo if=$iserrorstatus;
spec:
ingressClassName: "nginx"
rules:
- host: example.com
http:
paths:
- path: /hello
pathType: ImplementationSpecific
backend:
service:
name: hello-world
port:
name: http
tls:
- hosts:
- example.com
secretName: example-https-cert You will fail to deploy that ingress because it tries to write to We have many ingress definitions that attempt to write to Update (2022-05-12)I now see that It may be worth noting this as a possible breaking change with the upgrade. Any custom configuration that attempts to write to |
@gcolten thank you for updates. A lot of the specifics like /dev/stdout etc were informative from your earlier post as well. But this whole discussion is related to a chrooted process. So may I ask what is broken, with regards to what a ingress-controller should be doing, as per the specs of a ingress-controller described at Kubernetes.io. What do you want to achieve with a ingress object but are unable to achieve with the ingress-nginx controller. |
Fair question, @longwuyuan. At the end of the day, I think the behavior of the Users generally expect to have access to I don't know that there is a technical solution worth pursuing here. That said, it may be valuable to call more attention to the scope of changes introduced with this
|
ok. Maybe there is much deeper dive needed by a developer. But just to confirm, if you run If you are not pursuing a solution, then maybe the content here is good reference for anyone who searches for similar info in future. So consider closing the issue. Else you can wait and see if other comments come in. Thanks. |
The chroot image sends the log to an internal syslog, as the chroot process cannot write to std(err/output) (this is an Nginx limitation right now) We can indeed link stdout and stderr to /var/log/nginx/access.log but this is going to be a no-op unless you point logs there, and if you do so you are probably not getting the logs in Makes sense? :) |
FWIW, for reference, I've also hit a similar issue. I specify this on some ingresses (as I'm sure others might too):
when i try to update to the chroot image, it fails due to:
|
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close not-planned |
@k8s-triage-robot: Closing this issue, marking it as "Not Planned". In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
NGINX Ingress controller version:
Kubernetes version (use
kubectl version
):Environment:
uname -a
): Linux edge-router-mgmt-859668c9b7-94h9j 5.4.0-1074-azure Add support for IPV6 in dns resolvers #77~18.04.1-Ubuntu SMP Wed Mar 30 15:36:02 UTC 2022 x86_64 LinuxPlease mention how/where was the cluster created like kubeadm/kops/minikube/kind etc.
kubectl version
kubectl get nodes -o wide
How was the ingress-nginx-controller installed: manually via
kubectl apply ...
Others:
kubectl describe ...
of any custom configmap(s) created and in useWhat happened:
The configuration I'm trying to apply is not significant - the issue is that the presence of any issue is exceptionally challenging to troubleshoot.
After upgrading images from
k8s.gcr.io/ingress-nginx/controller:v1.1.3
tok8s.gcr.io/ingress-nginx/controller-chroot:v1.2.0
. I was unable to get ingress-nginx to accept the configuration and begin running.Kuberenetes logs showed this output:
What you expected to happen:
I expected the configuration to load successfully.
Suspected root cause:
Inside of the
chroot()
, the/dev
file directory (mounted inside of the Docker image at/chroot/dev
) does not include anything at/dev/stdout
. (My OS [Centos 8] has a symlink from/dev/stdout -> /proc/self/fd/1
.)As a result, anything inside the
chroot()
environment that attempts to write tostdout
is tasked with creating the new file under/dev
(really, under/chroot/dev
). Because processes are run by thewww-data
user (and, naturally,/chroot/dev
is owned by root), those processes are unable to create a new file there and write to it.I was able to resolve this by adding a line to the end of
chroot.sh
:How to reproduce it:
I don't have minimalistic steps for how to reproduce this.
In general, it should suffice to find anything inside of the
chroot()
environment that attempts to write to/dev/stdout
directly (could be from one of the many 3rd party packages loaded in), and it will fail with a "Permission Denied" error.Anything else we need to know:
If you know where you want the
stdout
from thechroot()
to be written to, this is a simple change. I'd recommend doing the analogous for/dev/stderr
, as well.The text was updated successfully, but these errors were encountered: