mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-02-14 10:19:54 +00:00
preflight: fix segfault when collector's are not defined in YAML (#939)
* preflight: fix segfault when collector's are not defined in YAML * fix bug with kind: Preflight specs with uploadResultsTo, wrong variable being used :) ref https://github.com/replicatedhq/troubleshoot/pull/894 Co-authored-by: Evans Mungai <evans@replicated.com>
This commit is contained in:
@@ -84,7 +84,9 @@ func (cr RemoteCollectResult) IsRBACAllowed() bool {
|
||||
// CollectHost runs the collection phase of host preflight checks
|
||||
func CollectHost(opts CollectOpts, p *troubleshootv1beta2.HostPreflight) (CollectResult, error) {
|
||||
collectSpecs := make([]*troubleshootv1beta2.HostCollect, 0, 0)
|
||||
collectSpecs = append(collectSpecs, p.Spec.Collectors...)
|
||||
if p != nil && p.Spec.Collectors != nil {
|
||||
collectSpecs = append(collectSpecs, p.Spec.Collectors...)
|
||||
}
|
||||
|
||||
allCollectedData := make(map[string][]byte)
|
||||
|
||||
@@ -128,7 +130,9 @@ func Collect(opts CollectOpts, p *troubleshootv1beta2.Preflight) (CollectResult,
|
||||
var foundForbidden bool
|
||||
|
||||
collectSpecs := make([]*troubleshootv1beta2.Collect, 0, 0)
|
||||
collectSpecs = append(collectSpecs, p.Spec.Collectors...)
|
||||
if p != nil && p.Spec.Collectors != nil {
|
||||
collectSpecs = append(collectSpecs, p.Spec.Collectors...)
|
||||
}
|
||||
collectSpecs = collect.EnsureCollectorInList(collectSpecs, troubleshootv1beta2.Collect{ClusterInfo: &troubleshootv1beta2.ClusterInfo{}})
|
||||
collectSpecs = collect.EnsureCollectorInList(collectSpecs, troubleshootv1beta2.Collect{ClusterResources: &troubleshootv1beta2.ClusterResources{}})
|
||||
collectSpecs = collect.EnsureClusterResourcesFirst(collectSpecs)
|
||||
@@ -267,7 +271,9 @@ func Collect(opts CollectOpts, p *troubleshootv1beta2.Preflight) (CollectResult,
|
||||
// Collect runs the collection phase of preflight checks
|
||||
func CollectRemote(opts CollectOpts, p *troubleshootv1beta2.HostPreflight) (CollectResult, error) {
|
||||
collectSpecs := make([]*troubleshootv1beta2.RemoteCollect, 0, 0)
|
||||
collectSpecs = append(collectSpecs, p.Spec.RemoteCollectors...)
|
||||
if p != nil && p.Spec.RemoteCollectors != nil {
|
||||
collectSpecs = append(collectSpecs, p.Spec.RemoteCollectors...)
|
||||
}
|
||||
|
||||
allCollectedData := make(map[string][]byte)
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ func RunPreflights(interactive bool, output string, format string, args []string
|
||||
preflightSpec = ConcatPreflightSpec(preflightSpec, spec)
|
||||
}
|
||||
} else {
|
||||
uploadResultSpecs = append(uploadResultSpecs, preflightSpec)
|
||||
uploadResultSpecs = append(uploadResultSpecs, spec)
|
||||
}
|
||||
} else if spec, ok := obj.(*troubleshootv1beta2.HostPreflight); ok {
|
||||
if i == 0 {
|
||||
|
||||
Reference in New Issue
Block a user