Skip to content

Commit c36b421

Browse files
committed
Collect managed pd csi driver logs from node
1 parent e266c21 commit c36b421

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

test/k8s-integration/driver.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ func dumpDriverLogs() (context.CancelFunc, error) {
169169
LogPathPrefix: filepath.Join(artifactsDir, "pd-csi-driver") + "/",
170170
}
171171
ctx, cancel := context.WithCancel(context.Background())
172-
if err = podlogs.CopyAllLogs(ctx, client, driverNamespace, out); err != nil {
172+
namespace := driverNamespace
173+
if *useGKEManagedDriver {
174+
namespace = managedDriverNamespace
175+
}
176+
if err = podlogs.CopyAllLogs(ctx, client, namespace, out); err != nil {
173177
return cancel, fmt.Errorf("failed to start pod logger: %v", err)
174178
}
175179
return cancel, nil

test/k8s-integration/main.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const (
7474
k8sInDockerBuildBinDir = "_output/dockerized/bin/linux/amd64"
7575
k8sOutOfDockerBuildBinDir = "_output/bin"
7676
driverNamespace = "gce-pd-csi-driver"
77+
managedDriverNamespace = "kube-system"
7778
)
7879

7980
func init() {
@@ -357,18 +358,18 @@ func handle() error {
357358
if err != nil {
358359
return fmt.Errorf("failed to install CSI Driver: %v", err)
359360
}
361+
}
360362

361-
// Dump all driver logs to the test artifacts
362-
cancel, err := dumpDriverLogs()
363-
if err != nil {
364-
return fmt.Errorf("failed to start driver logging: %v", err)
365-
}
366-
defer func() {
367-
if cancel != nil {
368-
cancel()
369-
}
370-
}()
363+
// Dump all driver logs to the test artifacts
364+
cancel, dumpErr := dumpDriverLogs()
365+
if dumpErr != nil {
366+
return fmt.Errorf("failed to start driver logging: %v", dumpErr)
371367
}
368+
defer func() {
369+
if cancel != nil {
370+
cancel()
371+
}
372+
}()
372373

373374
// For windows cluster, it has both Windows nodes and Linux nodes. Before triggering the tests, taint Linux nodes
374375
// with NoSchedule to avoid test pods being scheduled on Linux. Need to do this step after driver is deployed.

0 commit comments

Comments
 (0)