func (p *provider) CollectLogs(dir string, nodes []nodes.Node) error {
	execToPathFn := func(cmd exec.Cmd, path string) func() error {
		return func() error {
			f, err := common.FileOnHost(path)
			if err != nil {
				return err
			}
			defer f.Close()
			return cmd.SetStdout(f).SetStderr(f).Run()
		}
	}
	// construct a slice of methods to collect logs
	fns := []func() error{
		// record info about the host podman
		execToPathFn(
			exec.Command("podman", "info"),
			filepath.Join(dir, "podman-info.txt"),
		),
	}

	// collect /var/log for each node and plan collecting more logs
	var errs []error
	for _, n := range nodes {
		node := n // https://golang.org/doc/faq#closures_and_goroutines
		name := node.String()
		path := filepath.Join(dir, name)
		if err := internallogs.DumpDir(p.logger, node, "/var/log", path); err != nil {
			errs = append(errs, err)
		}

		fns = append(fns,
			func() error { return common.CollectLogs(node, path) },
			execToPathFn(exec.Command("podman", "inspect", name), filepath.Join(path, "inspect.json")),
			func() error {
				f, err := common.FileOnHost(filepath.Join(path, "serial.log"))
				if err != nil {
					return err
				}
				return node.SerialLogs(f)
			},
		)
	}

	// run and collect up all errors
	errs = append(errs, errors.AggregateConcurrent(fns))
	return errors.NewAggregate(errs)
}
// CollectLogs will populate dir with cluster logs and other debug files
CollectLogs will populate dir with cluster logs and other debug files
// CollectLogs will populate dir with cluster logs and other debug files
func (p *provider) CollectLogs(dir string, nodes []nodes.Node) error {
	execToPathFn := func(cmd exec.Cmd, path string) func() error {
		return func() error {
			f, err := common.FileOnHost(path)
			if err != nil {
				return err
			}
			defer f.Close()
			return cmd.SetStdout(f).SetStderr(f).Run()
		}
	}
	fns := []func() error{
		execToPathFn(
			exec.Command("podman", "info"),
			filepath.Join(dir, "podman-info.txt"),
		),
	}
	var errs []error
	for _, n := range nodes {
		node := n 
		name := node.String()
		path := filepath.Join(dir, name)
		if err := internallogs.DumpDir(p.logger, node, "/var/log", path); err != nil {
			errs = append(errs, err)
		}
		fns = append(fns,
			func() error { return common.CollectLogs(node, path) },
			execToPathFn(exec.Command("podman", "inspect", name), filepath.Join(path, "inspect.json")),
			func() error {
				f, err := common.FileOnHost(filepath.Join(path, "serial.log"))
				if err != nil {
					return err
				}
				return node.SerialLogs(f)
			},
		)
	}
	errs = append(errs, errors.AggregateConcurrent(fns))
	return errors.NewAggregate(errs)
}
func ( p * provider ) CollectLogs ( dir string , nodes [ ] nodes . Node ) error { execToPathFn := func ( cmd exec . Cmd , path string ) func ( ) error { return func ( ) error { f , err := common . FileOnHost ( path ) if err != nil { return err } defer f . Close ( ) return cmd . SetStdout ( f ) . SetStderr ( f ) . Run ( ) } } fns := [ ] func ( ) error { execToPathFn ( exec . Command ( " " , " " ) , filepath . Join ( dir , " " ) , ) , } var errs [ ] error for _ , n := range nodes { node := n name := node . String ( ) path := filepath . Join ( dir , name ) if err := internallogs . DumpDir ( p . logger , node , " " , path ) ; err != nil { errs = append ( errs , err ) } fns = append ( fns , func ( ) error { return common . CollectLogs ( node , path ) } , execToPathFn ( exec . Command ( " " , " " , name ) , filepath . Join ( path , " " ) ) , func ( ) error { f , err := common . FileOnHost ( filepath . Join ( path , " " ) ) if err != nil { return err } return node . SerialLogs ( f ) } , ) } errs = append ( errs , errors . AggregateConcurrent ( fns ) ) return errors . NewAggregate ( errs ) }
CollectLogs will populate dir with cluster logs and other debug files
CollectLogs will populate dir with cluster logs and other debug files
// construct a slice of methods to collect logs // record info about the host podman // collect /var/log for each node and plan collecting more logs // https://golang.org/doc/faq#closures_and_goroutines // run and collect up all errors