(logDir string)
| 194 | } |
| 195 | |
| 196 | func uploadLogfilesToGCS(logDir string) error { |
| 197 | cmd := exec.Command("/bin/sh", "-c", fmt.Sprintf("ls %v/*", logDir)) |
| 198 | output, err := cmd.Output() |
| 199 | if err != nil { |
| 200 | return fmt.Errorf("Could not list any logfiles: %w", err) |
| 201 | } |
| 202 | klog.Infof("List of logfiles available: %v", string(output)) |
| 203 | |
| 204 | gcsLogPath := *gcsPath + "/" + *nodeName |
| 205 | klog.Infof("Uploading logfiles to GCS at path '%v'", gcsLogPath) |
| 206 | for uploadAttempt := 0; uploadAttempt < 3; uploadAttempt++ { |
| 207 | // Upload the files with compression (-z) and parallelism (-m) for speeding up. |
| 208 | if err = runCommand("gsutil", "-m", "-q", "cp", "-c", |
| 209 | "-z", "log,txt,xml", logDir+"/*", gcsLogPath); err != nil { |
| 210 | klog.Errorf("Attempt %v to upload to GCS failed: %v", uploadAttempt, err) |
| 211 | continue |
| 212 | } |
| 213 | return writeSuccessMarkerFile() |
| 214 | } |
| 215 | return fmt.Errorf("Multiple attempts of gsutil failed, the final one due to: %w", err) |
| 216 | } |
| 217 | |
| 218 | // Write a marker file to GCS named after this node to indicate logexporter's success. |
| 219 | // The directory to which we write this file can then be used as a registry to quickly |
no test coverage detected