From c27fad2dd2fc50191def7f4d3fe50ec699c95966 Mon Sep 17 00:00:00 2001 From: Benjamin Yang Date: Thu, 9 Oct 2025 15:45:12 -0500 Subject: [PATCH 1/5] Fix Windows filename issue in scheduled support bundles --- pkg/collect/util.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/collect/util.go b/pkg/collect/util.go index fabe7087e..e4e184acb 100644 --- a/pkg/collect/util.go +++ b/pkg/collect/util.go @@ -80,7 +80,18 @@ func DeterministicIDForCollector(collector *troubleshootv1beta2.Collect) string } func selectorToString(selector []string) string { - return strings.Replace(strings.Join(selector, "-"), "=", "-", -1) + result := strings.Replace(strings.Join(selector, "-"), "=", "-", -1) + // Sanitize characters that are invalid in Windows filenames: < > : " / \ | ? * + // Replace them with underscores to ensure cross-platform compatibility + result = strings.ReplaceAll(result, "*", "all") + result = strings.ReplaceAll(result, "?", "_") + result = strings.ReplaceAll(result, ":", "_") + result = strings.ReplaceAll(result, "<", "_") + result = strings.ReplaceAll(result, ">", "_") + result = strings.ReplaceAll(result, "|", "_") + result = strings.ReplaceAll(result, "\"", "_") + result = strings.ReplaceAll(result, "\\", "_") + return result } func pathToString(path string) string { From 21534ea8df75a693fcb5d1b966a5ca020d17c273 Mon Sep 17 00:00:00 2001 From: Benjamin Yang Date: Fri, 10 Oct 2025 09:28:10 -0500 Subject: [PATCH 2/5] fix bugbot --- pkg/collect/util.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/collect/util.go b/pkg/collect/util.go index e4e184acb..7728c71c8 100644 --- a/pkg/collect/util.go +++ b/pkg/collect/util.go @@ -90,6 +90,7 @@ func selectorToString(selector []string) string { result = strings.ReplaceAll(result, ">", "_") result = strings.ReplaceAll(result, "|", "_") result = strings.ReplaceAll(result, "\"", "_") + result = strings.ReplaceAll(result, "/", "_") result = strings.ReplaceAll(result, "\\", "_") return result } From 9c1fa208eb08dc96dce563f4245dbfbc1a9d4ffa Mon Sep 17 00:00:00 2001 From: Benjamin Yang Date: Fri, 10 Oct 2025 10:10:52 -0500 Subject: [PATCH 3/5] Fix: Close temp file before executing Ollama installer on Windows Windows requires files to be closed before they can be executed. This fix ensures the temporary installer file is properly closed before attempting to run it, preventing file access errors on Windows systems. --- pkg/analyze/ollama_helper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/analyze/ollama_helper.go b/pkg/analyze/ollama_helper.go index e19d6a728..b533c13bb 100644 --- a/pkg/analyze/ollama_helper.go +++ b/pkg/analyze/ollama_helper.go @@ -165,6 +165,9 @@ func (h *OllamaHelper) downloadAndInstallWindows() error { return errors.Wrap(err, "failed to write installer") } + // Close the file before executing it (required on Windows) + tmpFile.Close() + // Run installer klog.Info("Running Ollama installer...") cmd := exec.Command(tmpFile.Name()) From 143c1483f0c40caebf804881ce58ad4d33abd39e Mon Sep 17 00:00:00 2001 From: Benjamin Yang Date: Fri, 10 Oct 2025 12:19:07 -0500 Subject: [PATCH 4/5] fixing bugbot --- pkg/analyze/ollama_helper.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/analyze/ollama_helper.go b/pkg/analyze/ollama_helper.go index b533c13bb..8e550a3c5 100644 --- a/pkg/analyze/ollama_helper.go +++ b/pkg/analyze/ollama_helper.go @@ -146,7 +146,6 @@ func (h *OllamaHelper) downloadAndInstallWindows() error { return errors.Wrap(err, "failed to create temporary file") } defer os.Remove(tmpFile.Name()) - defer tmpFile.Close() // Download installer resp, err := http.Get(h.downloadURL) From 51a0329f538191a28b50a4da3ef5e8acffba7552 Mon Sep 17 00:00:00 2001 From: Benjamin Yang Date: Tue, 14 Oct 2025 09:53:52 -0500 Subject: [PATCH 5/5] fix bugbot --- pkg/analyze/ollama_helper.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/analyze/ollama_helper.go b/pkg/analyze/ollama_helper.go index 8e550a3c5..85ccb4667 100644 --- a/pkg/analyze/ollama_helper.go +++ b/pkg/analyze/ollama_helper.go @@ -146,6 +146,7 @@ func (h *OllamaHelper) downloadAndInstallWindows() error { return errors.Wrap(err, "failed to create temporary file") } defer os.Remove(tmpFile.Name()) + defer tmpFile.Close() // Ensures file is closed in error paths // Download installer resp, err := http.Get(h.downloadURL) @@ -165,7 +166,11 @@ func (h *OllamaHelper) downloadAndInstallWindows() error { } // Close the file before executing it (required on Windows) - tmpFile.Close() + // Note: This will be called twice (here and via defer), but that's safe + // The defer ensures cleanup on error paths, this ensures closure before execution + if err := tmpFile.Close(); err != nil { + return errors.Wrap(err, "failed to close installer file") + } // Run installer klog.Info("Running Ollama installer...")