Merge pull request #16206 from spowelljr/checkForScannerErrors
cleanup: Check for scanner errorspull/16284/head
commit
9d9403c50f
|
@ -60,6 +60,9 @@ func TestAddonsList(t *testing.T) {
|
|||
pipeCount += strings.Count(buf.Text(), "|")
|
||||
got += buf.Text()
|
||||
}
|
||||
if err := buf.Err(); err != nil {
|
||||
t.Errorf("failed to read stdout: %v", err)
|
||||
}
|
||||
// The lines we pull should look something like
|
||||
// |------------|------------|(------|)
|
||||
// | ADDON NAME | MAINTAINER |( DOCS |)
|
||||
|
|
|
@ -501,7 +501,7 @@ func readEventLog(name string) ([]cloudevents.Event, time.Time, error) {
|
|||
events = append(events, ev)
|
||||
}
|
||||
|
||||
return events, st.ModTime(), nil
|
||||
return events, st.ModTime(), scanner.Err()
|
||||
}
|
||||
|
||||
// clusterState converts Status structs into a ClusterState struct
|
||||
|
|
|
@ -87,13 +87,13 @@ func main() {
|
|||
validDate = true
|
||||
write(dw, line)
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
log.Fatalf("failed to read file: %v", err)
|
||||
}
|
||||
|
||||
if err := dw.Flush(); err != nil {
|
||||
log.Fatalf("failed to flush data writer: %v", err)
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
log.Fatalf("scanner had an error: %v", err)
|
||||
}
|
||||
if err := data.Close(); err != nil {
|
||||
log.Fatalf("failed to close source file: %v", err)
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ func networkNamesByLabel(ociBin string, label string) ([]string, error) {
|
|||
lines = append(lines, strings.TrimSpace(scanner.Text()))
|
||||
}
|
||||
|
||||
return lines, nil
|
||||
return lines, scanner.Err()
|
||||
}
|
||||
|
||||
// DeleteAllKICKNetworksByLabel deletes all networks that have a specific label
|
||||
|
|
|
@ -407,6 +407,12 @@ func inspect(ociBin string, containerNameOrID, format string) ([]string, error)
|
|||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
if scanErr := scanner.Err(); scanErr != nil {
|
||||
klog.Warningf("failed to read output: %v", scanErr)
|
||||
if err == nil {
|
||||
err = scanErr
|
||||
}
|
||||
}
|
||||
return lines, err
|
||||
}
|
||||
|
||||
|
@ -473,6 +479,9 @@ func isUsernsRemapEnabled(ociBin string) bool {
|
|||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
klog.Warningf("failed to read output: %v", err)
|
||||
}
|
||||
|
||||
if len(lines) > 0 {
|
||||
if strings.Contains(lines[0], "name=userns") {
|
||||
|
@ -533,7 +542,7 @@ func ListContainersByLabel(ctx context.Context, ociBin string, label string, war
|
|||
names = append(names, n)
|
||||
}
|
||||
}
|
||||
return names, err
|
||||
return names, s.Err()
|
||||
}
|
||||
|
||||
// ListImagesRepository returns all the images names
|
||||
|
@ -554,10 +563,7 @@ func ListImagesRepository(ctx context.Context, ociBin string) ([]string, error)
|
|||
names = append(names, n)
|
||||
}
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return names, nil
|
||||
return names, s.Err()
|
||||
}
|
||||
|
||||
// PointToHostDockerDaemon will unset env variables that point to docker inside minikube
|
||||
|
|
|
@ -119,6 +119,12 @@ func allVolumesByLabel(ociBin string, label string) ([]string, error) {
|
|||
vols = append(vols, v)
|
||||
}
|
||||
}
|
||||
if scanErr := s.Err(); scanErr != nil {
|
||||
klog.Warningf("failed to read output: %v", scanErr)
|
||||
if err == nil {
|
||||
err = scanErr
|
||||
}
|
||||
}
|
||||
return vols, err
|
||||
}
|
||||
|
||||
|
|
|
@ -341,6 +341,9 @@ func outputKubeadmInitSteps(logs io.Reader, wg *sync.WaitGroup) {
|
|||
|
||||
nextStepIndex++
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
klog.Warningf("failed to read logs: %v", err)
|
||||
}
|
||||
wg.Done()
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ func teePrefix(prefix string, r io.Reader, w io.Writer, logger func(format strin
|
|||
if line.Len() > 0 {
|
||||
logger("%s%s", prefix, line.String())
|
||||
}
|
||||
return nil
|
||||
return scanner.Err()
|
||||
}
|
||||
|
||||
// fileExists checks that the same file exists on the other end
|
||||
|
|
|
@ -139,6 +139,9 @@ func FindProblems(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.C
|
|||
problems = append(problems, l)
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
klog.Warningf("failed to read output: %v", err)
|
||||
}
|
||||
if len(problems) > 0 {
|
||||
pMap[name] = problems
|
||||
}
|
||||
|
@ -198,6 +201,10 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
|
|||
for scanner.Scan() {
|
||||
l += scanner.Text() + "\n"
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
klog.Errorf("failed to read output: %v", err)
|
||||
failed = append(failed, name)
|
||||
}
|
||||
out.Styled(style.Empty, l)
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,9 @@ func parseLines(stdout string) []string {
|
|||
for s.Scan() {
|
||||
resp = append(resp, s.Text())
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
klog.Warningf("failed to read stdout: %v", err)
|
||||
}
|
||||
|
||||
return resp
|
||||
}
|
||||
|
|
|
@ -120,6 +120,9 @@ func KnownHost(host string, knownHosts string) bool {
|
|||
}
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
klog.Warningf("failed to read file: %v", err)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -186,6 +186,9 @@ func logOutput(r io.Reader, service string) {
|
|||
for s.Scan() {
|
||||
klog.Infof("%s tunnel: %s", service, s.Text())
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
klog.Warningf("failed to read: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *sshConn) stop() error {
|
||||
|
|
|
@ -43,8 +43,6 @@ import (
|
|||
|
||||
// TestDownloadOnly makes sure the --download-only parameter in minikube start caches the appropriate images and tarballs.
|
||||
func TestDownloadOnly(t *testing.T) {
|
||||
// Stores the startup run result for later error messages
|
||||
var rrr *RunResult
|
||||
profile := UniqueProfileName("download-only")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
|
||||
defer Cleanup(t, profile, cancel)
|
||||
|
@ -69,10 +67,6 @@ func TestDownloadOnly(t *testing.T) {
|
|||
// --force to avoid uid check
|
||||
args := append([]string{"start", "-o=json", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", containerRuntime)}, StartArgs()...)
|
||||
rt, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
||||
if rrr == nil {
|
||||
// Preserve the initial run-result for debugging
|
||||
rrr = rt
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("failed to download only. args: %q %v", args, err)
|
||||
}
|
||||
|
@ -91,6 +85,9 @@ func TestDownloadOnly(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
t.Errorf("failed to read output: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
preloadExists := false
|
||||
|
@ -101,15 +98,14 @@ func TestDownloadOnly(t *testing.T) {
|
|||
}
|
||||
// Driver does not matter here, since the only exception is none driver,
|
||||
// which cannot occur here.
|
||||
if download.PreloadExists(v, containerRuntime, "docker", true) {
|
||||
// Just make sure the tarball path exists
|
||||
if _, err := os.Stat(download.TarballPath(v, containerRuntime)); err != nil {
|
||||
t.Errorf("failed to verify preloaded tarball file exists: %v", err)
|
||||
}
|
||||
preloadExists = true
|
||||
} else {
|
||||
if !download.PreloadExists(v, containerRuntime, "docker", true) {
|
||||
t.Skip("No preload image")
|
||||
}
|
||||
// Just make sure the tarball path exists
|
||||
if _, err := os.Stat(download.TarballPath(v, containerRuntime)); err != nil {
|
||||
t.Errorf("failed to verify preloaded tarball file exists: %v", err)
|
||||
}
|
||||
preloadExists = true
|
||||
})
|
||||
|
||||
t.Run("cached-images", func(t *testing.T) {
|
||||
|
|
|
@ -52,5 +52,5 @@ func auditContains(substr string) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
return false, s.Err()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue