Skip to content

Collect managed pd csi driver logs from node #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions test/k8s-integration/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func installDriver(platform, goPath, pkgDir, stagingImage, stagingVersion, deplo
klog.Infof("Waiting 5 minutes for the driver to start on Linux")
time.Sleep(5 * time.Minute)
}
out, err := exec.Command("kubectl", "describe", "pods", "-n", driverNamespace).CombinedOutput()
out, err := exec.Command("kubectl", "describe", "pods", "-n", getDriverNamespace()).CombinedOutput()
klog.Infof("describe pods \n %s", string(out))

if err != nil {
Expand Down Expand Up @@ -169,13 +169,12 @@ func dumpDriverLogs() (context.CancelFunc, error) {
LogPathPrefix: filepath.Join(artifactsDir, "pd-csi-driver") + "/",
}
ctx, cancel := context.WithCancel(context.Background())
if err = podlogs.CopyAllLogs(ctx, client, driverNamespace, out); err != nil {
if err = podlogs.CopyAllLogs(ctx, client, getDriverNamespace(), out); err != nil {
return cancel, fmt.Errorf("failed to start pod logger: %v", err)
}
return cancel, nil
}
return nil, nil

}

// mergeArtifacts merges the results of doing multiple gingko runs, taking all junit files
Expand All @@ -194,3 +193,10 @@ func mergeArtifacts(subdirectories []string) error {
}
return MergeJUnit("External Storage", sourceDirs, filepath.Join(artifactsDir, "junit_pdcsi.xml"))
}

func getDriverNamespace() string {
if *useGKEManagedDriver {
return managedDriverNamespace
}
return externalDriverNamespace
}
26 changes: 13 additions & 13 deletions test/k8s-integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ const (
pdImagePlaceholder = "gke.gcr.io/gcp-compute-persistent-disk-csi-driver"
k8sInDockerBuildBinDir = "_output/dockerized/bin/linux/amd64"
k8sOutOfDockerBuildBinDir = "_output/bin"
driverNamespace = "gce-pd-csi-driver"
externalDriverNamespace = "gce-pd-csi-driver"
managedDriverNamespace = "kube-system"
)

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

if err != nil {
Expand All @@ -357,18 +358,18 @@ func handle() error {
if err != nil {
return fmt.Errorf("failed to install CSI Driver: %v", err)
}
}

// Dump all driver logs to the test artifacts
cancel, err := dumpDriverLogs()
if err != nil {
return fmt.Errorf("failed to start driver logging: %v", err)
}
defer func() {
if cancel != nil {
cancel()
}
}()
// Dump all driver logs to the test artifacts
cancel, err := dumpDriverLogs()
if err != nil {
return fmt.Errorf("failed to start driver logging: %v", err)
}
defer func() {
if cancel != nil {
cancel()
}
}()

// For windows cluster, it has both Windows nodes and Linux nodes. Before triggering the tests, taint Linux nodes
// with NoSchedule to avoid test pods being scheduled on Linux. Need to do this step after driver is deployed.
Expand All @@ -395,7 +396,6 @@ func handle() error {
}

var cloudProviderArgs []string
var err error
switch *deploymentStrat {
case "gke":
cloudProviderArgs, err = getGKEKubeTestArgs(*gceZone, *gceRegion, *imageType)
Expand Down