mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Merge pull request #6204 from pmorie/secrets-e2e
Fix log retrieval in secrets e2e
This commit is contained in:
commit
95c8e79c10
@ -69,11 +69,10 @@ var _ = Describe("Secrets", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
By(fmt.Sprintf("Creating a pod to consume secret %v", secret.Name))
|
By(fmt.Sprintf("Creating a pod to consume secret %v", secret.Name))
|
||||||
// Make a client pod that verifies that it has the service environment variables.
|
// Make a pod that verifies that it has the service environment variables.
|
||||||
clientName := "client-secrets-" + string(util.NewUUID())
|
pod := &api.Pod{
|
||||||
clientPod := &api.Pod{
|
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: clientName,
|
Name: "pod-secrets-" + string(util.NewUUID()),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Volumes: []api.Volume{
|
Volumes: []api.Volume{
|
||||||
@ -90,7 +89,7 @@ var _ = Describe("Secrets", func() {
|
|||||||
{
|
{
|
||||||
Name: "catcont",
|
Name: "catcont",
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Command: []string{"sh", "-c", "cat /etc/secret-volume/data-1; sleep 600"},
|
Command: []string{"sh", "-c", "cat /etc/secret-volume/data-1"},
|
||||||
VolumeMounts: []api.VolumeMount{
|
VolumeMounts: []api.VolumeMount{
|
||||||
{
|
{
|
||||||
Name: volumeName,
|
Name: volumeName,
|
||||||
@ -104,20 +103,20 @@ var _ = Describe("Secrets", func() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
defer c.Pods(ns).Delete(clientPod.Name)
|
defer c.Pods(ns).Delete(pod.Name)
|
||||||
if _, err := c.Pods(ns).Create(clientPod); err != nil {
|
if _, err := c.Pods(ns).Create(pod); err != nil {
|
||||||
Failf("Failed to create pod: %v", err)
|
Failf("Failed to create pod: %v", err)
|
||||||
}
|
}
|
||||||
// Wait for client pod to complete.
|
// Wait for client pod to complete.
|
||||||
expectNoError(waitForPodRunning(c, clientPod.Name))
|
expectNoError(waitForPodSuccess(c, pod.Name, "catcont"))
|
||||||
|
|
||||||
// Grab its logs. Get host first.
|
// Grab its logs. Get host first.
|
||||||
clientPodStatus, err := c.Pods(ns).Get(clientPod.Name)
|
podStatus, err := c.Pods(ns).Get(pod.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Failf("Failed to get clientPod to know host: %v", err)
|
Failf("Failed to get pod to know host: %v", err)
|
||||||
}
|
}
|
||||||
By(fmt.Sprintf("Trying to get logs from host %s pod %s container %s: %v",
|
By(fmt.Sprintf("Trying to get logs from host %s pod %s container %s: %v",
|
||||||
clientPodStatus.Status.Host, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name, err))
|
podStatus.Status.Host, podStatus.Name, podStatus.Spec.Containers[0].Name, err))
|
||||||
var logs []byte
|
var logs []byte
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
@ -126,15 +125,15 @@ var _ = Describe("Secrets", func() {
|
|||||||
logs, err = c.Get().
|
logs, err = c.Get().
|
||||||
Prefix("proxy").
|
Prefix("proxy").
|
||||||
Resource("minions").
|
Resource("minions").
|
||||||
Name(clientPodStatus.Status.Host).
|
Name(podStatus.Status.Host).
|
||||||
Suffix("containerLogs", ns, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name).
|
Suffix("containerLogs", ns, podStatus.Name, podStatus.Spec.Containers[0].Name).
|
||||||
Do().
|
Do().
|
||||||
Raw()
|
Raw()
|
||||||
fmt.Sprintf("clientPod logs:%v\n", string(logs))
|
fmt.Sprintf("pod logs:%v\n", string(logs))
|
||||||
By(fmt.Sprintf("clientPod logs:%v\n", string(logs)))
|
By(fmt.Sprintf("pod logs:%v\n", string(logs)))
|
||||||
if strings.Contains(string(logs), "Internal Error") {
|
if strings.Contains(string(logs), "Internal Error") {
|
||||||
By(fmt.Sprintf("Failed to get logs from host %s pod %s container %s: %v",
|
By(fmt.Sprintf("Failed to get logs from host %s pod %s container %s: %v",
|
||||||
clientPodStatus.Status.Host, clientPodStatus.Name, clientPodStatus.Spec.Containers[0].Name, string(logs)))
|
podStatus.Status.Host, podStatus.Name, podStatus.Spec.Containers[0].Name, string(logs)))
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user