Do not update a secret not referenced by ingress rules
This commit is contained in:
parent
90eff7d34c
commit
a36cd10041
5 changed files with 303 additions and 4 deletions
|
|
@ -172,6 +172,26 @@ func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) boo
|
|||
return wait.PollImmediate(Poll, time.Minute*2, f.matchNginxConditions(name, matcher))
|
||||
}
|
||||
|
||||
// NginxLogs returns the logs of the nginx ingress controller pod running
|
||||
func (f *Framework) NginxLogs() (string, error) {
|
||||
l, err := f.KubeClientSet.CoreV1().Pods("ingress-nginx").List(metav1.ListOptions{
|
||||
LabelSelector: "app=ingress-nginx",
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(l.Items) == 0 {
|
||||
return "", fmt.Errorf("no nginx ingress controller pod is running")
|
||||
}
|
||||
|
||||
if len(l.Items) != 1 {
|
||||
return "", fmt.Errorf("unexpected number of nginx ingress controller pod is running (%v)", len(l.Items))
|
||||
}
|
||||
|
||||
return f.Logs(&l.Items[0])
|
||||
}
|
||||
|
||||
func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) bool) wait.ConditionFunc {
|
||||
return func() (bool, error) {
|
||||
l, err := f.KubeClientSet.CoreV1().Pods("ingress-nginx").List(metav1.ListOptions{
|
||||
|
|
|
|||
52
test/e2e/framework/logs.go
Normal file
52
test/e2e/framework/logs.go
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
Copyright 2017 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 framework
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
func (f *Framework) Logs(pod *v1.Pod) (string, error) {
|
||||
var (
|
||||
execOut bytes.Buffer
|
||||
execErr bytes.Buffer
|
||||
)
|
||||
|
||||
if len(pod.Spec.Containers) != 1 {
|
||||
return "", fmt.Errorf("could not determine which container to use")
|
||||
}
|
||||
|
||||
args := fmt.Sprintf("kubectl logs -n %v %v", pod.Namespace, pod.Name)
|
||||
cmd := exec.Command("/bin/bash", "-c", args)
|
||||
cmd.Stdout = &execOut
|
||||
cmd.Stderr = &execErr
|
||||
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not execute: %v", err)
|
||||
}
|
||||
|
||||
if execErr.Len() > 0 {
|
||||
return "", fmt.Errorf("stderr: %v", execErr.String())
|
||||
}
|
||||
|
||||
return execOut.String(), nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue