Added logs from /var/log/pods (#1507)

Signed-off-by: Patryk Strusiewicz-Surmacki <patryk.pawel.strusiewicz-surmacki@external.telekom.de>
Co-authored-by: Patryk Strusiewicz-Surmacki <patryk.pawel.strusiewicz-surmacki@external.telekom.de>
This commit is contained in:
Patryk Strusiewicz-Surmacki
2026-04-09 13:53:48 +02:00
committed by GitHub
parent edeac48c40
commit d7882e9453
10 changed files with 161 additions and 99 deletions

View File

@@ -26,10 +26,10 @@ jobs:
- name: Run Manifest generation tests
run: make manifest-test
- name: Run ARP mode tests
run: E2E_KEEP_LOGS=true make e2e-tests-arp
run: DOCKER_API_VERSION=1.48 E2E_KEEP_LOGS=true make e2e-tests-arp
if: matrix.mode== 'arp'
- name: Run RT mode tests
run: E2E_KEEP_LOGS=true make e2e-tests-rt
run: DOCKER_API_VERSION=1.48 E2E_KEEP_LOGS=true make e2e-tests-rt
if: matrix.mode== 'rt'
- name: Get GoBGP binaries
run: make get-gobgp
@@ -62,10 +62,10 @@ jobs:
- name: Build image with iptables
run: make dockerx86ActionIPTables
- name: Run tests
run: DOCKERTAG=action E2E_KEEP_LOGS=true make service-tests
run: DOCKER_API_VERSION=1.48 DOCKERTAG=action E2E_KEEP_LOGS=true make service-tests
- name: Save logs
uses: actions/upload-artifact@v7
with:
name: services-test-logs-${{ steps.date.outputs.date }}
path: /tmp/kube-vip-service-tests*
path: /tmp/kube-vip-services*
if: always()

View File

@@ -5,6 +5,7 @@ package e2e_test
import (
"context"
"fmt"
"os"
"k8s.io/client-go/kubernetes"
@@ -45,7 +46,7 @@ var _ = Describe("kube-vip BGP when deployed as a regular pod", Ordered, func()
BeforeAll(func() {
var err error
tempDirPathRoot, err = os.MkdirTemp("", "kube-vip-test-arp")
tempDirPathRoot, err = os.MkdirTemp("", "kube-vip-test-bgp-ds")
Expect(err).NotTo(HaveOccurred())
})
@@ -70,7 +71,7 @@ var _ = Describe("kube-vip BGP when deployed as a regular pod", Ordered, func()
}
var err error
tempDirPath, err = os.MkdirTemp(tempDirPathRoot, "kube-vip-test")
tempDirPath, err = os.MkdirTemp(tempDirPathRoot, "kube-vip-test-ds")
Expect(err).NotTo(HaveOccurred())
clusterName, client, _ = prepareClusterForDS(tempDirPath, "bgp-ds", imagePath, k8sImagePath,
@@ -78,12 +79,16 @@ var _ = Describe("kube-vip BGP when deployed as a regular pod", Ordered, func()
})
AfterAll(func() {
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
AfterEach(func() {
tempDirPathLocal, err := os.MkdirTemp(tempDirPath, "kube-vip-test")
By(fmt.Sprintf("saving logs to %q", tempDirPathLocal))
err = e2e.GetLogs(ctx, client, tempDirPathLocal, clusterName)
Expect(err).ToNot(HaveOccurred())
})
It(clusterName+" exits gracefully when only control plane is enabled", func() {
manifestValues := &e2e.KubevipManifestValues{
Mode: Mode,

View File

@@ -158,7 +158,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
Eventually(func() error {
@@ -201,7 +201,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
Eventually(func() error {
@@ -244,7 +244,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
Eventually(func() error {
@@ -287,7 +287,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
Eventually(func() error {
@@ -330,7 +330,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
Eventually(func() error {
@@ -386,7 +386,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -440,7 +440,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -494,7 +494,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, n := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -549,7 +549,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -604,7 +604,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, n := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -658,7 +658,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
Eventually(func() error {
@@ -722,7 +722,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -784,7 +784,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -846,7 +846,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, n := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -909,7 +909,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -972,7 +972,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, n := range gobgpPeers {
_, err := gobgpClient.DeletePeer(ctx, &api.DeletePeerRequest{
@@ -1106,7 +1106,7 @@ var _ = Describe("kube-vip BGP mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
for _, p := range gobgpPeers {
Eventually(func() error {

View File

@@ -54,7 +54,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor when deployed as a regular
BeforeAll(func() {
var err error
tempDirPathRoot, err = os.MkdirTemp("", "kube-vip-test-arp")
tempDirPathRoot, err = os.MkdirTemp("", "kube-vip-test-arp-ds")
Expect(err).NotTo(HaveOccurred())
})
@@ -87,13 +87,16 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor when deployed as a regular
})
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
AfterEach(func() {
tempDirPathLocal, err := os.MkdirTemp(tempDirPath, "kube-vip-test")
By(fmt.Sprintf("saving logs to %q", tempDirPathLocal))
err = e2e.GetLogs(ctx, client, tempDirPathLocal, clusterName)
Expect(err).ToNot(HaveOccurred())
})
It(clusterName+" deletes all IPv4 addresses on exit when only control plane is enabled", func() {
manifestValues := &e2e.KubevipManifestValues{
Mode: Mode,
@@ -212,13 +215,16 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor when deployed as a regular
})
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
AfterEach(func() {
tempDirPathLocal, err := os.MkdirTemp(tempDirPath, "kube-vip-test")
By(fmt.Sprintf("saving logs to %q", tempDirPathLocal))
err = e2e.GetLogs(ctx, client, tempDirPathLocal, clusterName)
Expect(err).ToNot(HaveOccurred())
})
It(clusterName+" deletes all IPv6 addresses on exit when only control plane is enabled", func() {
manifestValues := &e2e.KubevipManifestValues{
Mode: Mode,
@@ -337,13 +343,16 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor when deployed as a regular
})
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
AfterEach(func() {
tempDirPathLocal, err := os.MkdirTemp(tempDirPath, "kube-vip-test")
By(fmt.Sprintf("saving logs to %q", tempDirPathLocal))
err = e2e.GetLogs(ctx, client, tempDirPathLocal, clusterName)
Expect(err).ToNot(HaveOccurred())
})
It(clusterName+" deletes all addresses on exit when only control plane is enabled", func() {
manifestValues := &e2e.KubevipManifestValues{
Mode: Mode,

View File

@@ -46,7 +46,7 @@ var _ = Describe("kube-vip RT functionality when deployed as a regular pod", Ord
BeforeAll(func() {
var err error
tempDirPathRoot, err = os.MkdirTemp("", "kube-vip-test-arp")
tempDirPathRoot, err = os.MkdirTemp("", "kube-vip-test-rt-ds")
Expect(err).NotTo(HaveOccurred())
})
@@ -79,13 +79,16 @@ var _ = Describe("kube-vip RT functionality when deployed as a regular pod", Ord
})
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
AfterEach(func() {
tempDirPathLocal, err := os.MkdirTemp(tempDirPath, "kube-vip-test")
By(fmt.Sprintf("saving logs to %q", tempDirPathLocal))
err = e2e.GetLogs(ctx, client, tempDirPathLocal, clusterName)
Expect(err).ToNot(HaveOccurred())
})
It(clusterName+" exits gracefully on exit when only control plane is enabled", func() {
manifestValues := &e2e.KubevipManifestValues{
Mode: Mode,

View File

@@ -112,7 +112,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -173,7 +173,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -244,7 +244,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -321,7 +321,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -392,7 +392,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -462,7 +462,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -533,7 +533,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -606,7 +606,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -676,7 +676,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -755,7 +755,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -835,7 +835,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -917,7 +917,7 @@ var _ = Describe("kube-vip routing table mode", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
err := e2e.GetLogs(ctx, client, tempDirPath)
err := e2e.GetLogs(ctx, client, tempDirPath, clusterName)
Expect(err).ToNot(HaveOccurred())
cleanupCluster(clusterName, ConfigMtx, logger)
})

View File

@@ -146,7 +146,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -192,7 +192,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -252,7 +252,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -306,7 +306,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
Expect(err).ToNot(HaveOccurred())
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, c, tempDirPath)
return e2e.GetLogs(ctx, c, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -352,7 +352,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -412,7 +412,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -463,7 +463,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -509,7 +509,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -569,7 +569,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -622,7 +622,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -670,7 +670,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -732,7 +732,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -783,7 +783,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -829,7 +829,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})
@@ -883,7 +883,7 @@ var _ = Describe("kube-vip ARP/NDP broadcast neighbor", Ordered, func() {
AfterAll(func() {
By(fmt.Sprintf("saving logs to %q", tempDirPath))
Eventually(func() error {
return e2e.GetLogs(ctx, client, tempDirPath)
return e2e.GetLogs(ctx, client, tempDirPath, clusterName)
}, "60s", "5s").Should(Succeed())
cleanupCluster(clusterName, ConfigMtx, logger)
})

View File

@@ -4,12 +4,17 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
@@ -17,7 +22,9 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
)
func GetLogs(ctx context.Context, client kubernetes.Interface, tempDirPath string) error {
const logDir = "/var/log/pods"
func GetLogs(ctx context.Context, client kubernetes.Interface, tempDirPath string, clusterName string) error {
if os.Getenv("E2E_KEEP_LOGS") != "true" {
if err := os.RemoveAll(tempDirPath); err != nil {
return fmt.Errorf("failed to remove temporary directory %q: %w", tempDirPath, err)
@@ -28,6 +35,10 @@ func GetLogs(ctx context.Context, client kubernetes.Interface, tempDirPath strin
intCtx, cancel := context.WithTimeout(ctx, time.Second*20)
defer cancel()
if err := getLogsFromDir(intCtx, tempDirPath, clusterName); err != nil {
return fmt.Errorf("failed to get logs from /var/log/containers: %w", err)
}
path := filepath.Join(tempDirPath, "pods.json")
fpods, err := os.Create(path)
if err != nil {
@@ -128,3 +139,38 @@ func GetLogs(ctx context.Context, client kubernetes.Interface, tempDirPath strin
return nil
}
func getLogsFromDir(ctx context.Context, dir, clusterName string) error {
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
return fmt.Errorf("failed to create client: %w", err)
}
containers, err := cli.ContainerList(ctx, container.ListOptions{})
if err != nil {
return fmt.Errorf("failed to list containers: %w", err)
}
nodes := []string{}
for _, c := range containers {
if strings.Contains(c.Names[0], clusterName) &&
(strings.Contains(c.Names[0], "control-plane") || strings.Contains(c.Names[0], "worker")) {
nodes = append(nodes, c.Names[0][1:])
}
}
for i, n := range nodes {
out := filepath.Join(dir, n)
if i == 0 {
if err := os.Mkdir(out, 0o700); err != nil && !errors.Is(err, os.ErrExist) {
return fmt.Errorf("failed to create directory %s: %w", out, err)
}
}
cmd := exec.Command("docker", "cp", fmt.Sprintf("%s:%s", n, logDir), out) //nolint:gosec
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to get logs from container %s: %w", n, err)
}
}
return nil
}

View File

@@ -59,7 +59,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -76,7 +76,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -94,7 +94,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -112,7 +112,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -130,7 +130,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -148,7 +148,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -166,7 +166,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -184,7 +184,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -202,7 +202,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}
@@ -220,7 +220,7 @@ func (config *TestConfig) StartServiceTest(ctx context.Context, clientset *kuber
return []error{fmt.Errorf("failed to create temporary directory: %w", err)}
}
slog.Infof("saving logs to %q", tempDirPath)
if err := e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
if err := e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Error(err)
}
}

View File

@@ -64,13 +64,12 @@ func (config *TestConfig) SimpleDeployment(ctx context.Context, clientset *kuber
slog.Infof("🧪 ---> simple deployment defer <---")
tempDirPath, err := os.MkdirTemp(config.TempDirPath, "simple-deployment")
if err != nil {
slog.Infof("🧪 ---> simple deployment mkdir err <---: %w", err)
return err
}
slog.Infof("saving logs to %q", tempDirPath)
if err = e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
slog.Infof("🧪 ---> simple deployment getlogs err <---: %w", err)
if err = e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Infof("🧪 ---> simple deployment logs err <---: %s", err.Error())
return err
}
@@ -126,8 +125,8 @@ func (config *TestConfig) MultipleDeployments(ctx context.Context, clientset *ku
}
slog.Infof("saving logs to %q", tempDirPath)
if err = e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
slog.Infof("🧪 ---> simple deployment getlogs err <---: %w", err)
if err = e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Infof("🧪 ---> multiple deployment logs err <---: %s", err.Error())
return err
}
@@ -184,8 +183,8 @@ func (config *TestConfig) Failover(ctx context.Context, clientset *kubernetes.Cl
}
slog.Infof("saving logs to %q", tempDirPath)
if err = e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
slog.Infof("🧪 ---> simple deployment getlogs err <---: %w", err)
if err = e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Infof("🧪 ---> failover logs err <---: %s", err.Error())
return err
}
@@ -259,8 +258,8 @@ func (config *TestConfig) ActiveFailover(ctx context.Context, clientset *kuberne
}
slog.Infof("saving logs to %q", tempDirPath)
if err = e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
slog.Infof("🧪 ---> simple deployment getlogs err <---: %w", err)
if err = e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Infof("🧪 ---> active failover logs err <---: %s", err.Error())
return err
}
@@ -316,8 +315,8 @@ func (config *TestConfig) LocalDeployment(ctx context.Context, clientset *kubern
}
slog.Infof("saving logs to %q", tempDirPath)
if err = e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
slog.Infof("🧪 ---> simple deployment getlogs err <---: %w", err)
if err = e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Infof("🧪 ---> local deployment logs err <---: %s", err.Error())
return err
}
@@ -387,8 +386,8 @@ func (config *TestConfig) EgressDeployment(ctx context.Context, clientset *kuber
}
slog.Infof("saving logs to %q", tempDirPath)
if err = e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
slog.Infof("🧪 ---> simple deployment getlogs err <---: %w", err)
if err = e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Infof("🧪 ---> egress deployment logs err <---: %s", err.Error())
return err
}
@@ -477,8 +476,8 @@ func (config *TestConfig) Egressv6Deployment(ctx context.Context, clientset *kub
}
slog.Infof("saving logs to %q", tempDirPath)
if err = e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
slog.Infof("🧪 ---> simple deployment getlogs err <---: %w", err)
if err = e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Infof("🧪 ---> egress v6 deployment logs err <---: %s", err.Error())
return err
}
@@ -599,8 +598,8 @@ func (config *TestConfig) DualStackDeployment(ctx context.Context, clientset *ku
}
slog.Infof("saving logs to %q", tempDirPath)
if err = e2e.GetLogs(ctx, clientset, tempDirPath); err != nil {
slog.Infof("🧪 ---> simple deployment getlogs err <---: %w", err)
if err = e2e.GetLogs(ctx, clientset, tempDirPath, "services"); err != nil {
slog.Infof("🧪 ---> dualstack deployment logs err <---: %s", err.Error())
return err
}