Skip to content

Commit 292b299

Browse files
authored
Merge pull request #619 from saikat-royc/pd-logs-on-gke
Collect managed pd csi driver logs from node
2 parents e266c21 + cc8a0ed commit 292b299

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

test/k8s-integration/driver.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
9191
klog.Infof("Waiting 5 minutes for the driver to start on Linux")
9292
time.Sleep(5 * time.Minute)
9393
}
94-
out, err := exec.Command("kubectl", "describe", "pods", "-n", driverNamespace).CombinedOutput()
94+
out, err := exec.Command("kubectl", "describe", "pods", "-n", getDriverNamespace()).CombinedOutput()
9595
klog.Infof("describe pods \n %s", string(out))
9696

9797
if err != nil {
@@ -169,13 +169,12 @@ 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+
if err = podlogs.CopyAllLogs(ctx, client, getDriverNamespace(), out); err != nil {
173173
return cancel, fmt.Errorf("failed to start pod logger: %v", err)
174174
}
175175
return cancel, nil
176176
}
177177
return nil, nil
178-
179178
}
180179

181180
// mergeArtifacts merges the results of doing multiple gingko runs, taking all junit files
@@ -194,3 +193,10 @@ func mergeArtifacts(subdirectories []string) error {
194193
}
195194
return MergeJUnit("External Storage", sourceDirs, filepath.Join(artifactsDir, "junit_pdcsi.xml"))
196195
}
196+
197+
func getDriverNamespace() string {
198+
if *useGKEManagedDriver {
199+
return managedDriverNamespace
200+
}
201+
return externalDriverNamespace
202+
}

test/k8s-integration/main.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ const (
7373
pdImagePlaceholder = "gke.gcr.io/gcp-compute-persistent-disk-csi-driver"
7474
k8sInDockerBuildBinDir = "_output/dockerized/bin/linux/amd64"
7575
k8sOutOfDockerBuildBinDir = "_output/bin"
76-
driverNamespace = "gce-pd-csi-driver"
76+
externalDriverNamespace = "gce-pd-csi-driver"
77+
managedDriverNamespace = "kube-system"
7778
)
7879

7980
func init() {
@@ -335,7 +336,7 @@ func handle() error {
335336
return fmt.Errorf("failed to prepull images: %s, err: %v", out, err)
336337
}
337338
time.Sleep(10 * time.Minute)
338-
out, err = exec.Command("kubectl", "describe", "pods", "-n", driverNamespace).CombinedOutput()
339+
out, err = exec.Command("kubectl", "describe", "pods", "-n", getDriverNamespace()).CombinedOutput()
339340
klog.Infof("describe pods \n %s", string(out))
340341

341342
if err != nil {
@@ -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, err := dumpDriverLogs()
365+
if err != nil {
366+
return fmt.Errorf("failed to start driver logging: %v", err)
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.
@@ -395,7 +396,6 @@ func handle() error {
395396
}
396397

397398
var cloudProviderArgs []string
398-
var err error
399399
switch *deploymentStrat {
400400
case "gke":
401401
cloudProviderArgs, err = getGKEKubeTestArgs(*gceZone, *gceRegion, *imageType)

0 commit comments

Comments
 (0)