From 451261f8c23fdbe527601557c9ef5404be4624c8 Mon Sep 17 00:00:00 2001 From: Patrick Barker Date: Tue, 29 Jan 2019 13:34:42 -0700 Subject: [PATCH] returns 500 on error; updates header dates for audit proxy --- test/images/audit-proxy/Dockerfile | 2 +- test/images/audit-proxy/Makefile | 2 +- test/images/audit-proxy/main.go | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/images/audit-proxy/Dockerfile b/test/images/audit-proxy/Dockerfile index c5d927b07d..7bbeb62b45 100644 --- a/test/images/audit-proxy/Dockerfile +++ b/test/images/audit-proxy/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2018 The Kubernetes Authors. +# Copyright 2019 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/images/audit-proxy/Makefile b/test/images/audit-proxy/Makefile index 3657cc5746..3f7976a459 100644 --- a/test/images/audit-proxy/Makefile +++ b/test/images/audit-proxy/Makefile @@ -1,4 +1,4 @@ -# Copyright 2018 The Kubernetes Authors. +# Copyright 2019 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/images/audit-proxy/main.go b/test/images/audit-proxy/main.go index 4cfc7cb3da..8438e5eda9 100644 --- a/test/images/audit-proxy/main.go +++ b/test/images/audit-proxy/main.go @@ -48,12 +48,16 @@ func main() { func handler(w http.ResponseWriter, req *http.Request) { body, err := ioutil.ReadAll(req.Body) if err != nil { - log.Fatalf("could not read request body: %v", err) + log.Printf("could not read request body: %v", err) + w.WriteHeader(http.StatusInternalServerError) + return } el := &auditv1.EventList{} if err := runtime.DecodeInto(decoder, body, el); err != nil { - log.Fatalf("failed decoding buf: %b, apiVersion: %s", body, auditv1.SchemeGroupVersion) + log.Printf("failed decoding buf: %b, apiVersion: %s", body, auditv1.SchemeGroupVersion) + w.WriteHeader(http.StatusInternalServerError) + return } defer req.Body.Close() @@ -61,9 +65,10 @@ func handler(w http.ResponseWriter, req *http.Request) { for _, event := range el.Items { err := encoder.Encode(&event, os.Stdout) if err != nil { - log.Fatalf("could not encode audit event: %v", err) + log.Printf("could not encode audit event: %v", err) + w.WriteHeader(http.StatusInternalServerError) + return } } w.WriteHeader(http.StatusOK) - return }