Skip to content

Commit 3834052

Browse files
committed
print-api7-ingress-system-logs
1 parent 28da758 commit 3834052

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

.github/workflows/e2e-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
run: |
9090
ls *.log
9191
for log_file in $(find . -type f -name "*.log"); do
92-
echo "================= $log_file =======================>>"
92+
echo "\n================= $log_file =======================>>"
9393
cat "$log_file"
94-
echo "<<================= $log_file ======================="
94+
echo "<<================= $log_file =======================\n"
9595
done

internal/provider/adc/adc.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (d *adcClient) Delete(ctx context.Context, obj client.Object) error {
7777
func (d *adcClient) sync(task Task) error {
7878
log.Debugw("syncing task", zap.Any("task", task))
7979

80-
yaml, err := yaml.Marshal(task.Resources)
80+
data, err := yaml.Marshal(task.Resources)
8181
if err != nil {
8282
return err
8383
}
@@ -91,9 +91,9 @@ func (d *adcClient) sync(task Task) error {
9191
_ = os.Remove(tmpFile.Name())
9292
}()
9393

94-
log.Debugw("syncing resources", zap.String("file", tmpFile.Name()), zap.String("yaml", string(yaml)))
94+
log.Debugw("syncing resources", zap.String("file", tmpFile.Name()), zap.String("yaml", string(data)))
9595

96-
if _, err := tmpFile.Write(yaml); err != nil {
96+
if _, err := tmpFile.Write(data); err != nil {
9797
return err
9898
}
9999

@@ -118,5 +118,6 @@ func (d *adcClient) sync(task Task) error {
118118
)
119119
return err
120120
}
121+
121122
return nil
122123
}

internal/provider/adc/adc_cmd.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@ type adcSyncer struct {
4444
envs []string
4545
stdout io.Writer
4646
stderr io.Writer
47-
cmd *exec.Cmd
4847
}
4948

5049
func (adc *adcSyncer) Run() error {
5150
cmd := exec.Command("adc", adc.args...)
5251
cmd.Env = adc.envs
5352
cmd.Stdout = adc.stdout
5453
cmd.Stderr = adc.stderr
55-
return adc.cmd.Run()
54+
return cmd.Run()
5655
}
5756

5857
func (adc *adcSyncer) Stdout(stdout io.Writer) Syncer {
@@ -86,8 +85,10 @@ func (adc *adcSyncer) GatewayGroup(gatewayGroup string) Syncer {
8685
}
8786

8887
func (adc *adcSyncer) LabelSelectors(values map[string]string) Syncer {
89-
for key, value := range values {
90-
adc.LabelSelector(key, value)
88+
if len(values) > 0 {
89+
for key, value := range values {
90+
adc.LabelSelector(key, value)
91+
}
9192
}
9293
return adc
9394
}

test/e2e/scaffold/scaffold.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
package scaffold
1717

1818
import (
19+
"bytes"
1920
"context"
2021
"crypto/tls"
2122
"crypto/x509"
2223
"fmt"
24+
"io"
2325
"net"
2426
"net/http"
2527
"net/url"
@@ -456,18 +458,25 @@ func (s *Scaffold) afterEach() {
456458

457459
if CurrentSpecReport().Failed() {
458460
if os.Getenv("TSET_ENV") == "CI" {
461+
var buf = bytes.NewBuffer(nil)
459462
_, _ = fmt.Fprintln(GinkgoWriter, "Dumping namespace contents")
460463
output, _ := k8s.RunKubectlAndGetOutputE(GinkgoT(), s.kubectlOptions, "get", "deploy,sts,svc,pods")
461464
if output != "" {
462-
_, _ = fmt.Fprintln(GinkgoWriter, output)
465+
_, _ = fmt.Fprintln(io.MultiWriter(GinkgoWriter, buf), output)
463466
}
464467
output, _ = k8s.RunKubectlAndGetOutputE(GinkgoT(), s.kubectlOptions, "describe", "pods")
465468
if output != "" {
466-
_, _ = fmt.Fprintln(GinkgoWriter, output)
469+
_, _ = buf.WriteString("/n")
470+
_, _ = fmt.Fprintln(io.MultiWriter(GinkgoWriter, buf), output)
467471
}
468-
output, _ = k8s.RunKubectlAndGetOutputE(GinkgoT(), s.kubectlOptions, "logs", "-l", "control-plane=controller-manager")
472+
output, _ = k8s.RunKubectlAndGetOutputE(GinkgoT(), s.kubectlOptions, "logs", "-l",
473+
"control-plane=controller-manager")
469474
if output != "" {
470-
require.NoError(GinkgoT(), os.WriteFile("../../"+s.namespace+"-controller-manager.log", []byte(output), 0644))
475+
_, _ = buf.WriteString("/n")
476+
_, _ = buf.WriteString("controller-manager log\n")
477+
_, _ = buf.WriteString(output)
478+
_, _ = buf.WriteString("/n")
479+
require.NoError(GinkgoT(), os.WriteFile("../../"+s.namespace+"-controller-manager.log", buf.Bytes(), 0644))
471480
}
472481
}
473482
}

0 commit comments

Comments
 (0)