Skip to content

Conversation

@cbuto
Copy link

@cbuto cbuto commented Oct 28, 2025

Description, Motivation and Context

This PR updates the cluster resources collector to use the proper output path for replicasets. It currently writes replicaset resources to a directory called statefulsets-errors.json

While collecting a support-bundle from a cluster with restricted permissions, I came across this error:

Error: failed to run collect and analyze process: create bundle file: failed to stat file: lstat /var/folders/j8/9dmckpr53fsgt2ttnjvc8x1h0000gn/T/supportbundle3684131245/support-bundle-2025-10-28T14_47_51/cluster-resources/statefulsets-errors.json/default.json: not a directory
Error: failed to run collect and analyze process: create bundle file: failed to stat file: lstat /var/folders/j8/9dmckpr53fsgt2ttnjvc8x1h0000gn/T/supportbundle3684131245/support-bundle-2025-10-28T14_47_51/cluster-resources/statefulsets-errors.json/default.json: not a directory

I only ran into it because of permissions issues with collecting statefulsets, so the statefulsets-errors.json file was created.

After building a binary from this branch, I was able to collect a bundle successfully.

Fixes: #1916

Checklist

  • New and existing tests pass locally with introduced changes.
  • Tests for the changes have been added (for bug fixes / features)
  • The commit message(s) are informative and highlight any breaking changes
  • Any documentation required has been added/updated. For changes to https://troubleshoot.sh/ create a PR here

Does this PR introduce a breaking change?

  • Yes
  • No

@cbuto
Copy link
Author

cbuto commented Oct 29, 2025

cc @NoaheCampbell @bennyyang11 (just grabbed from recent committers 😄)

@xavpaice
Copy link
Member

Thanks for the PR.

I suggest adding an update to the tests for this as well, something like:

--- a/test/e2e/support-bundle/cluster_resources_e2e_test.go
+++ b/test/e2e/support-bundle/cluster_resources_e2e_test.go
@@ -31,6 +31,8 @@ func TestClusterResources(t *testing.T) {
                                "namespaces.json",
                                "clusterrolebindings.json",
                                "storage-classes.json",
+                               "statefulsets-errors.json",
+                               "replicasets-errors.json",
                        },
                        expectType: "file",
                },
@@ -47,11 +49,11 @@ func TestClusterResources(t *testing.T) {
                                "roles",
                                "events",
                                "rolebindings",
-                               "statefulsets-errors.json",
                                "jobs",
                                "serviceaccounts",
                                "configmaps",
                                "statefulsets",
+                               "replicasets",
                                "endpoints",
                                "network-policy",
                                "resource-quota",

@cbuto
Copy link
Author

cbuto commented Nov 24, 2025

Thanks for the PR.

I suggest adding an update to the tests for this as well, something like:

--- a/test/e2e/support-bundle/cluster_resources_e2e_test.go
+++ b/test/e2e/support-bundle/cluster_resources_e2e_test.go
@@ -31,6 +31,8 @@ func TestClusterResources(t *testing.T) {
                                "namespaces.json",
                                "clusterrolebindings.json",
                                "storage-classes.json",
+                               "statefulsets-errors.json",
+                               "replicasets-errors.json",
                        },
                        expectType: "file",
                },
@@ -47,11 +49,11 @@ func TestClusterResources(t *testing.T) {
                                "roles",
                                "events",
                                "rolebindings",
-                               "statefulsets-errors.json",
                                "jobs",
                                "serviceaccounts",
                                "configmaps",
                                "statefulsets",
+                               "replicasets",
                                "endpoints",
                                "network-policy",
                                "resource-quota",

Thanks @xavpaice! I updated the e2es to check for the replicasets dir. The statefulsets-errors.json and replicasets-errors.json files won't exist by default so i didn't include those (test fails) 👍

@cbuto
Copy link
Author

cbuto commented Nov 24, 2025

ah looks like the regression tests failed since the structure changed 🤔 and we need to update the baseline artifacts?

@emosbaugh
Copy link
Member

Thanks for the contribution!

This proved to be more difficult than I had expected due to some issues with the regression test suite. All is fixed here: #1936

@xavpaice
Copy link
Member

I've merged #1936 which covers the change here - many thanks for kicking this off.

@xavpaice xavpaice closed this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cluster resources collector: replicasets output to wrong directory

3 participants