GenerateSupportBundle generates a new support bundle.
(cfg *BundleCfg)
| 103 | |
| 104 | // GenerateSupportBundle generates a new support bundle. |
| 105 | func (bb *bundleBuilder) GenerateSupportBundle(cfg *BundleCfg) (string, error) { |
| 106 | additionalFiles := cfg.AdditionalFiles |
| 107 | excludeFiles := cfg.ExcludeFiles |
| 108 | logLines := cfg.LogLines |
| 109 | |
| 110 | zipFileName := bundleFileName() |
| 111 | bb.logger.Debugf("Creating %s...", zipFileName) |
| 112 | zipFile, err := bb.fs.Create(zipFileName) |
| 113 | if err != nil { |
| 114 | return "", err |
| 115 | } |
| 116 | |
| 117 | zipPrefix := strings.TrimSuffix(zipFileName, filepath.Ext(zipFileName)) |
| 118 | |
| 119 | writer := zip.NewWriter(zipFile) |
| 120 | |
| 121 | _, err = writer.Create(fmt.Sprintf("%s/", zipPrefix)) |
| 122 | if err != nil { |
| 123 | return "", err |
| 124 | } |
| 125 | |
| 126 | platform, err := bb.getPlatformData() |
| 127 | if err != nil { |
| 128 | return "", err |
| 129 | } |
| 130 | |
| 131 | bb.logger.Debugln("Gathering platform data...") |
| 132 | err = writePlatformData(writer, platform, zipPrefix) |
| 133 | if err != nil { |
| 134 | return "", err |
| 135 | } |
| 136 | |
| 137 | bb.logger.Debugln("Collecting finch version output...") |
| 138 | version := bb.getFinchVersion() |
| 139 | err = writeVersionOutput(writer, version, zipPrefix) |
| 140 | if err != nil { |
| 141 | return "", err |
| 142 | } |
| 143 | |
| 144 | bb.logger.Debugln("Copying in log files...") |
| 145 | for _, file := range bb.config.LogFiles() { |
| 146 | if fileShouldBeExcluded(file, excludeFiles) { |
| 147 | bb.logger.Infof("Excluding %s...", file) |
| 148 | continue |
| 149 | } |
| 150 | bb.logger.Debugf("Copying %s...", file) |
| 151 | err = bb.copyFileFromVMOrLocal(writer, file, path.Join(zipPrefix, logPrefix), logLines) |
| 152 | if err != nil { |
| 153 | bb.logger.Warnf("Could not copy in %q. Error: %s", file, err) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | if slices.Contains(excludeFiles, allServices) { |
| 158 | bb.logger.Info("Excluding all service logs...") |
| 159 | } else { |
| 160 | bb.logger.Debugln("Copying in journal logs...") |
| 161 | for _, file := range bb.config.JournalServices() { |
| 162 | if fileShouldBeExcluded(file, excludeFiles) { |