diff --git a/test/images/webhook/VERSION b/test/images/webhook/VERSION index fe9e4faa6b..42e1b6f225 100644 --- a/test/images/webhook/VERSION +++ b/test/images/webhook/VERSION @@ -1 +1 @@ -1.13v1 +1.14v1 diff --git a/test/images/webhook/alwaysallow.go b/test/images/webhook/alwaysallow.go new file mode 100644 index 0000000000..f9a4aa9a89 --- /dev/null +++ b/test/images/webhook/alwaysallow.go @@ -0,0 +1,36 @@ +/* +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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "time" + + "k8s.io/api/admission/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/klog" +) + +// alwaysAllowDelayFiveSeconds sleeps for five seconds and allows all requests made to this function. +func alwaysAllowDelayFiveSeconds(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse { + klog.V(2).Info("always-allow-with-delay sleeping for 5 seconds") + time.Sleep(5 * time.Second) + klog.V(2).Info("calling always-allow") + reviewResponse := v1beta1.AdmissionResponse{} + reviewResponse.Allowed = true + reviewResponse.Result = &metav1.Status{Message: "this webhook allows all requests"} + return &reviewResponse +} diff --git a/test/images/webhook/main.go b/test/images/webhook/main.go index 0d9460ca8b..87484b99ea 100644 --- a/test/images/webhook/main.go +++ b/test/images/webhook/main.go @@ -91,6 +91,10 @@ func serve(w http.ResponseWriter, r *http.Request, admit admitFunc) { } } +func serveAlwaysAllowDelayFiveSeconds(w http.ResponseWriter, r *http.Request) { + serve(w, r, alwaysAllowDelayFiveSeconds) +} + func serveAlwaysDeny(w http.ResponseWriter, r *http.Request) { serve(w, r, alwaysDeny) } @@ -132,10 +136,12 @@ func serveCRD(w http.ResponseWriter, r *http.Request) { } func main() { + klog.InitFlags(nil) var config Config config.addFlags() flag.Parse() + http.HandleFunc("/always-allow-delay-5s", serveAlwaysAllowDelayFiveSeconds) http.HandleFunc("/always-deny", serveAlwaysDeny) http.HandleFunc("/add-label", serveAddLabel) http.HandleFunc("/pods", servePods) diff --git a/test/utils/image/manifest.go b/test/utils/image/manifest.go index 266945a4bb..a4ac5dfcd3 100644 --- a/test/utils/image/manifest.go +++ b/test/utils/image/manifest.go @@ -93,7 +93,7 @@ var ( // Preconfigured image configs var ( CRDConversionWebhook = Config{e2eRegistry, "crd-conversion-webhook", "1.13rev2"} - AdmissionWebhook = Config{e2eRegistry, "webhook", "1.13v1"} + AdmissionWebhook = Config{e2eRegistry, "webhook", "1.14v1"} APIServer = Config{e2eRegistry, "sample-apiserver", "1.10"} AppArmorLoader = Config{e2eRegistry, "apparmor-loader", "1.0"} BusyBox = Config{dockerLibraryRegistry, "busybox", "1.29"}