1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-13 21:52:08 +00:00

Add etcd snapshot fix and more log messages to certificate bundle

Add function to collect stdout and stderr logs from containers
This commit is contained in:
galal-hussein
2018-07-18 22:44:55 +02:00
committed by Alena Prokharchyk
parent b483981539
commit 3ce50d28d3
5 changed files with 52 additions and 28 deletions

View File

@@ -1,14 +1,12 @@
package cluster
import (
"bytes"
"context"
"fmt"
"net"
"strings"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/go-connections/nat"
"github.com/rancher/rke/docker"
"github.com/rancher/rke/hosts"
@@ -404,8 +402,6 @@ func (c *Cluster) runServicePortChecks(ctx context.Context) error {
func checkPlaneTCPPortsFromHost(ctx context.Context, host *hosts.Host, portList []string, planeHosts []*hosts.Host, image string, prsMap map[string]v3.PrivateRegistry) error {
var hosts []string
var containerStdout bytes.Buffer
var containerStderr bytes.Buffer
for _, host := range planeHosts {
hosts = append(hosts, host.InternalAddress)
@@ -435,14 +431,10 @@ func checkPlaneTCPPortsFromHost(ctx context.Context, host *hosts.Host, portList
return err
}
clogs, err := docker.ReadContainerLogs(ctx, host.DClient, PortCheckContainer, true, "all")
if err != nil {
return err
containerLog, logsErr := docker.GetContainerLogsStdoutStderr(ctx, host.DClient, PortCheckContainer, "1")
if logsErr != nil {
log.Warnf(ctx, "[network] Failed to get network port check logs: %v", logsErr)
}
defer clogs.Close()
stdcopy.StdCopy(&containerStdout, &containerStderr, clogs)
containerLog := containerStderr.String()
logrus.Debugf("[network] containerLog [%s] on host: %s", containerLog, host.Address)
if err := docker.RemoveContainer(ctx, host.DClient, host.Address, PortCheckContainer); err != nil {