From 973b4c2c1db31024bab9a87ebb5dc86d44db3022 Mon Sep 17 00:00:00 2001 From: Ashmita152 Date: Mon, 7 Mar 2022 22:17:56 +0545 Subject: [PATCH 1/2] Fix favicon returning 500 inside container net/http depends on mime-type to set the Content-Type for a http response, mime-type is calculated using https://pkg.go.dev/mime#TypeByExtension (https://github.com/golang/go/blob/master/src/net/http/fs.go#L235) In alpine, there is no default installation of mime-type library hence net/http was setting application/text for favicon.ico which was leading to 500. Adding mailcap pacakge will install /etc/mime.types and fix the issue Signed-off-by: Ashmita152 --- docker/base/Dockerfile | 2 +- docker/debug/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index f22e85c4b83..bd15edafd62 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -2,7 +2,7 @@ ARG cert_image ARG root_image FROM $cert_image AS cert -RUN apk add --update --no-cache ca-certificates +RUN apk add --update --no-cache ca-certificates mailcap FROM $root_image COPY --from=cert /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/docker/debug/Dockerfile b/docker/debug/Dockerfile index 748f5e5cbc5..55bbd982e05 100644 --- a/docker/debug/Dockerfile +++ b/docker/debug/Dockerfile @@ -3,7 +3,7 @@ ARG golang_image FROM $golang_image AS build ARG TARGETARCH ENV GOPATH /go -RUN apk add --update --no-cache ca-certificates make git build-base +RUN apk add --update --no-cache ca-certificates make git build-base mailcap #Once go-delve adds support for s390x (see PR #2948), remove this entire conditional. #Once go-delve adds support for ppc64le (see PR go-delve/delve#1564), remove this entire conditional. RUN if [[ "$TARGETARCH" == "s390x" || "$TARGETARCH" == "ppc64le" ]] ; then \ From cef185bcec1f63f6b4eac9589bae5594f4f9af22 Mon Sep 17 00:00:00 2001 From: Ashmita152 Date: Tue, 8 Mar 2022 11:23:22 +0545 Subject: [PATCH 2/2] Feedbacks Signed-off-by: Ashmita152 --- cmd/all-in-one/all_in_one_test.go | 16 ++++++++++++++++ docker/base/Dockerfile | 1 + docker/debug/Dockerfile | 1 + 3 files changed, 18 insertions(+) diff --git a/cmd/all-in-one/all_in_one_test.go b/cmd/all-in-one/all_in_one_test.go index d62e8128468..5943834b180 100644 --- a/cmd/all-in-one/all_in_one_test.go +++ b/cmd/all-in-one/all_in_one_test.go @@ -62,6 +62,10 @@ func TestAllInOne(t *testing.T) { if err := healthCheck(); err != nil { t.Fatal(err) } + // Check if the favicon icon is available + if err := faviconCheck(); err != nil { + t.Fatal(err) + } createTrace(t) getAPITrace(t) getSamplingStrategy(t) @@ -138,6 +142,18 @@ func healthCheck() error { return fmt.Errorf("query service is not ready") } +func faviconCheck() error { + println("Checking favicon...") + resp, err := http.Get(queryURL + "/favicon.ico") + if err == nil && resp.StatusCode == http.StatusOK { + println("Favicon check successful") + return nil + } else { + println("Favicon check failed") + return fmt.Errorf("all-in-one failed to serve favicon icon") + } +} + func getServicesAPIV3(t *testing.T) { req, err := http.NewRequest("GET", getServicesAPIV3URL, nil) require.NoError(t, err) diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index bd15edafd62..6fa10c92bd1 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -6,3 +6,4 @@ RUN apk add --update --no-cache ca-certificates mailcap FROM $root_image COPY --from=cert /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=cert /etc/mime.types /etc/mime.types diff --git a/docker/debug/Dockerfile b/docker/debug/Dockerfile index 55bbd982e05..b8e4ddc005d 100644 --- a/docker/debug/Dockerfile +++ b/docker/debug/Dockerfile @@ -15,3 +15,4 @@ RUN if [[ "$TARGETARCH" == "s390x" || "$TARGETARCH" == "ppc64le" ]] ; then \ FROM $golang_image COPY --from=build /go/bin/dlv /go/bin/dlv COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=build /etc/mime.types /etc/mime.types