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

fix custom-error-pages file not exist #7728

Merged
merged 1 commit into from
Dec 23, 2021
Merged

Conversation

learn0208
Copy link
Contributor

What this PR does / why we need it:

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation only

Which issue/s this PR fixes

HttpCode error, page not found.
image

How Has This Been Tested?

image

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 30, 2021
@k8s-ci-robot
Copy link
Contributor

@learn0208: This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot
Copy link
Contributor

Welcome @learn0208!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-nginx has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 30, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @learn0208. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-priority size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 30, 2021
@longwuyuan
Copy link
Contributor

What is the issue number/link that this PR fixes ?
How can I reproduce the problem this PR fixes ?

@learn0208
Copy link
Contributor Author

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.

Completed

@learn0208
Copy link
Contributor Author

What is the issue number/link that this PR fixes ? How can I reproduce the problem this PR fixes ?

# cd images/custom-error-pages/rootfs
# docker build -t defaultbackend:test .
# docker run --rm -p 808:8080  defaultbackend:test .
# curl -H "X-code: 404" 127.0.0.1:808

@longwuyuan
Copy link
Contributor

@learn0208 it is very likely that you have a valid and reasonable information updated to this PR.
But, not everyone can understand and reproduce the problem you seem to be hinting at.
I would not want to follow this process as ad-hoc changes like this lack transparency of a issue with details and a step-by-step process to reproduce the problem on a K8s cluster with ingress objects and ingress rules.

Lets wait for other opinions but I myself do not approve of this PR in its current state.

@learn0208
Copy link
Contributor Author

learn0208 commented Sep 30, 2021

We wanted to customize the ingress-nginx error page reponse. Build default-http-backend image from github, but got back was '404 page not found'. So the Dockerfile can be improved, such as adding such a line

COPY --from=builder /go/src/k8s.io/ingress-nginx/images/custom-error-pages/www /www

Our test step.

# kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.4", GitCommit:"67d2fcf276fcd9cf743ad4be9a9ef5828adc082f", GitTreeState:"clean", BuildDate:"2019-09-18T14:51:13Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.4", GitCommit:"67d2fcf276fcd9cf743ad4be9a9ef5828adc082f", GitTreeState:"clean", BuildDate:"2019-09-18T14:41:55Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}

build from https://github.com/kubernetes/ingress-nginx/blob/main/images/custom-error-pages/rootfs/Dockerfile as defaultbackend:test.
default-http-backend config

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: default-http-backend
  labels:
    k8s-app: default-http-backend
  namespace: ingress-nginx
spec:
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: default-http-backend
    spec:
      terminationGracePeriodSeconds: 60
      containers:
      - name: default-http-backend
        # Any image is permissable as long as:
        # 1. It serves a 404 page at /
        # 2. It serves 200 on a /healthz endpoint
        image: defaultbackend:test
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 30
          timeoutSeconds: 5
        ports:
        - containerPort: 8080
        resources:
          limits:
            cpu: 100m
            memory: 200Mi
          requests:
            cpu: 10m
            memory: 20Mi
---
apiVersion: v1
kind: Service
metadata:
  name: default-http-backend
  namespace: ingress-nginx
  labels:
    k8s-app: default-http-backend
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    k8s-app: default-http-backend

ingress-nginx information
version: 0.49.2
Host: 175.63.100.112
run args

          ...
          args:
            - /nginx-ingress-controller
            - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
            - --publish-service=$(POD_NAMESPACE)/ingress-nginx-controller
            - --election-id=ingress-controller-leader
            - --ingress-class=nginx
            - --configmap=$(POD_NAMESPACE)/ingress-nginx-controller
          ...

image

# curl 175.63.100.112
404 page not found

get default-http-backend pod log

2021/09/29 09:16:18 format not specified. Using text/html
2021/09/29 09:16:18 unexpected error reading return code: strconv.Atoi: parsing "": invalid syntax. Using 404
2021/09/29 09:16:18 unexpected error opening file: open /www/404.html: no such file or directory
2021/09/29 09:16:18 unexpected error opening file: open /www/4xx.html: no such file or directory
2021/09/29 09:16:18 http: superfluous response.WriteHeader call from main.errorHandler.func1 (main.go:164)

rebuild docker image from https://github.com/learn0208/ingress-nginx/blob/main/images/custom-error-pages/rootfs/Dockerfile as defaultbackend:bugfix
image

# kubectl set image deployment/default-http-backend default-http-backend:defaultbackend:bugfix
# curl 175.63.100.112
<span>The page you're looking for could not be found.</span>

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 30, 2021
@longwuyuan
Copy link
Contributor

The change is text in response. In my opinion this is not a improvement for most use cases or most users. Also since users can change attributes like image, there is no compelling reason to approve this PR.

@learn0208
Copy link
Contributor Author

The change is text in response. In my opinion this is not a improvement for most use cases or most users. Also since users can change attributes like image, there is no compelling reason to approve this PR.

add images

@mrksngl
Copy link
Contributor

mrksngl commented Nov 6, 2021

@longwuyuan maybe I got you wrong here, but no, it's not just a change in the response text.

Thing is, that the docker image (without PR) misses the www directory. Then, when it's used as default backend (and wll, that's its purpose) and shall serve a customized 404 page (i.e. /www/404.html), it cannot find that file and replies a generic "404 Page not found" response instead.

The PR just copies the provided www directory into the image. I think users would more likely expect getting the /www/404.html instead of that file being totally absent, leading to an error.

But that is not even all: the PR is incomplete (this also goes to @learn0208):
There is also a etc/mime.types and this file should also be provided in the container.
It is needed to map the original Accept header (which is passed to the default backend as X-Format by ingress) to a file extension.
If it's missing, the program will fall back to .html for any format.

@rikatz
Copy link
Contributor

rikatz commented Dec 23, 2021

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 23, 2021
@rikatz
Copy link
Contributor

rikatz commented Dec 23, 2021

cycling back to this.

I understand the need but do we, in any case in nginx.tmpl refer to the /www as the custom error pages? (checking here, but let me know if you already know the answer)

@rikatz
Copy link
Contributor

rikatz commented Dec 23, 2021

/lgtm
/approve
Thanks!

We are clearly missing those files inside custom-errors containers.

We should probably bump now the image to a new version and promote it, feel free to ping us on #ingress-nginx-dev in Slack (me, @strongjz , @longwuyuan, etc) to know how to proceed next.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 23, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: learn0208, rikatz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 23, 2021
@k8s-ci-robot k8s-ci-robot merged commit 8e9bf7f into kubernetes:main Dec 23, 2021
@rikatz
Copy link
Contributor

rikatz commented Dec 23, 2021

#15 pushing manifest for gcr.io/k8s-staging-ingress-nginx/nginx-errors:v20211223-helm-chart-4.0.13-19-g8e9bf7f62@sha256:1d69f28d6412b0f2a6302f9df9a6bc49e83703336a35f95ab109cad10e039120 is the manifest of this one and needs promotion

@mrksngl
Copy link
Contributor

mrksngl commented Dec 24, 2021

Still misses /etc/mime.types, needed for https://github.com/kubernetes/ingress-nginx/blob/main/images/custom-error-pages/rootfs/main.go#L129 to work.

@rikatz
Copy link
Contributor

rikatz commented Dec 24, 2021

Can you add it via a new PR? Thanks!

rchshld pushed a commit to joomcode/ingress-nginx that referenced this pull request May 19, 2023
@lucasfcnunes
Copy link
Contributor

@rikatz @mrksngl

Can you add it via a new PR? Thanks!

Doing it at #10310

@mrksngl
Copy link
Contributor

mrksngl commented Aug 13, 2023

Oh I completely missed that request, thanks @lucasfcnunes for taking on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants