Skip to content

Commit 7ed2f4b

Browse files
feat: Handle failure to load cluster specs gracefully in support-bundle command (#1660)
* feat: Handle failure to load cluster specs gracefully in support-bundle command In some scenarios, we don't want to fail when unable to load specs from the cluster. This is particularly useful when: - A host support bundle is available on disk. - There are specs defined in the cluster. - The cluster is malfunctioning or inaccessible. - We still need to generate a support bundle using only the host specs. - This change allows users to generate a support bundle even if the embedded cluster is not functioning properly, making the process more resilient. The primary motivation is to introduce a new command: ``` ./embedded-cluster support-bundle ``` When executed, this command attempts to collect both host and cluster specs. However, if the embedded cluster is broken or unavailable, the command will skip loading the cluster specs and focus on the host, ensuring that users can still gather critical information without interruption. * chore: use fmt printf instead of klog * Update internal/specs/specs.go Co-authored-by: Evans Mungai <[email protected]> --------- Co-authored-by: Evans Mungai <[email protected]>
1 parent af8f682 commit 7ed2f4b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/specs/specs.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,14 @@ func LoadFromCLIArgs(ctx context.Context, client kubernetes.Interface, args []st
221221
if vp.GetBool("load-cluster-specs") {
222222
clusterKinds, err := LoadFromCluster(ctx, client, vp.GetStringSlice("selector"), vp.GetString("namespace"))
223223
if err != nil {
224-
return nil, types.NewExitCodeError(constants.EXIT_CODE_SPEC_ISSUES, err)
224+
if kinds.IsEmpty() {
225+
return nil, types.NewExitCodeError(constants.EXIT_CODE_SPEC_ISSUES, err)
226+
}
227+
// TODO: Consider colour coding and graceful failures when loading specs
228+
fmt.Printf("failed to load specs from the cluster: %v\n", err)
229+
} else {
230+
kinds.Add(clusterKinds)
225231
}
226-
227-
kinds.Add(clusterKinds)
228232
}
229233

230234
return kinds, nil

0 commit comments

Comments
 (0)