mirror of
https://github.com/rancher/rke.git
synced 2025-08-01 23:33:39 +00:00
Fix local port check
This commit is contained in:
parent
caa2c524a6
commit
b71fd3ba35
@ -431,7 +431,7 @@ func checkPlaneTCPPortsFromHost(ctx context.Context, host *hosts.Host, portList
|
||||
return err
|
||||
}
|
||||
|
||||
containerLog, logsErr := docker.GetContainerLogsStdoutStderr(ctx, host.DClient, PortCheckContainer, "1")
|
||||
containerLog, logsErr := docker.GetContainerLogsStdoutStderr(ctx, host.DClient, PortCheckContainer, "all", true)
|
||||
if logsErr != nil {
|
||||
log.Warnf(ctx, "[network] Failed to get network port check logs: %v", logsErr)
|
||||
}
|
||||
|
@ -364,11 +364,11 @@ func ReadContainerLogs(ctx context.Context, dClient *client.Client, containerNam
|
||||
return dClient.ContainerLogs(ctx, containerName, types.ContainerLogsOptions{Follow: follow, ShowStdout: true, ShowStderr: true, Timestamps: false, Tail: tail})
|
||||
}
|
||||
|
||||
func GetContainerLogsStdoutStderr(ctx context.Context, dClient *client.Client, containerName, tail string) (string, error) {
|
||||
func GetContainerLogsStdoutStderr(ctx context.Context, dClient *client.Client, containerName, tail string, follow bool) (string, error) {
|
||||
var containerStderr bytes.Buffer
|
||||
var containerStdout bytes.Buffer
|
||||
var containerLog string
|
||||
clogs, logserr := ReadContainerLogs(ctx, dClient, containerName, false, tail)
|
||||
clogs, logserr := ReadContainerLogs(ctx, dClient, containerName, follow, tail)
|
||||
if logserr != nil {
|
||||
logrus.Debug("logserr: %v", logserr)
|
||||
return containerLog, fmt.Errorf("Failed to get gather logs from container [%s]: %v", containerName, logserr)
|
||||
@ -376,7 +376,6 @@ func GetContainerLogsStdoutStderr(ctx context.Context, dClient *client.Client, c
|
||||
defer clogs.Close()
|
||||
stdcopy.StdCopy(&containerStdout, &containerStderr, clogs)
|
||||
containerLog = containerStderr.String()
|
||||
containerLog = strings.TrimSuffix(containerLog, "\n")
|
||||
return containerLog, nil
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ func ExtractBackupBundleOnHost(ctx context.Context, host *hosts.Host, alpineSyst
|
||||
return err
|
||||
}
|
||||
if status != 0 {
|
||||
containerLog, err := docker.GetContainerLogsStdoutStderr(ctx, host.DClient, BundleCertContainer, "5")
|
||||
containerLog, err := docker.GetContainerLogsStdoutStderr(ctx, host.DClient, BundleCertContainer, "5", false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ func RestoreEtcdSnapshot(ctx context.Context, etcdHost *hosts.Host, prsMap map[s
|
||||
return err
|
||||
}
|
||||
if status != 0 {
|
||||
containerLog, err := docker.GetContainerLogsStdoutStderr(ctx, etcdHost.DClient, EtcdRestoreContainerName, "5")
|
||||
containerLog, err := docker.GetContainerLogsStdoutStderr(ctx, etcdHost.DClient, EtcdRestoreContainerName, "5", false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ func runHealthcheck(ctx context.Context, host *hosts.Host, serviceName string, l
|
||||
return nil
|
||||
}
|
||||
logrus.Debug("Checking container logs")
|
||||
containerLog, logserr := docker.GetContainerLogsStdoutStderr(ctx, host.DClient, serviceName, "1")
|
||||
containerLog, logserr := docker.GetContainerLogsStdoutStderr(ctx, host.DClient, serviceName, "1", false)
|
||||
containerLog = strings.TrimSuffix(containerLog, "\n")
|
||||
if logserr != nil {
|
||||
return fmt.Errorf("Failed to verify healthcheck for service [%s]: %v", serviceName, logserr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user