Merge branch 'master' into oci-go-faster
commit
6ddb9343b2
|
@ -93,15 +93,21 @@ func NewMemoryAssetTarget(d []byte, targetPath, permissions string) *MemoryAsset
|
|||
// NewFileAsset creates a new FileAsset
|
||||
func NewFileAsset(src, targetDir, targetName, permissions string) (*FileAsset, error) {
|
||||
glog.V(4).Infof("NewFileAsset: %s -> %s", src, path.Join(targetDir, targetName))
|
||||
|
||||
f, err := os.Open(src)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "Error opening file asset: %s", src)
|
||||
return nil, errors.Wrap(err, "open")
|
||||
}
|
||||
|
||||
info, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "Error getting info for %s", src)
|
||||
return nil, errors.Wrapf(err, "stat")
|
||||
}
|
||||
r := io.NewSectionReader(f, 0, info.Size())
|
||||
|
||||
if info.Size() == 0 {
|
||||
glog.Warningf("NewFileAsset: %s is an empty file!", src)
|
||||
}
|
||||
|
||||
return &FileAsset{
|
||||
BaseAsset: BaseAsset{
|
||||
SourcePath: src,
|
||||
|
@ -109,7 +115,7 @@ func NewFileAsset(src, targetDir, targetName, permissions string) (*FileAsset, e
|
|||
TargetName: targetName,
|
||||
Permissions: permissions,
|
||||
},
|
||||
reader: r,
|
||||
reader: io.NewSectionReader(f, 0, info.Size()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -117,6 +123,7 @@ func NewFileAsset(src, targetDir, targetName, permissions string) (*FileAsset, e
|
|||
func (f *FileAsset) GetLength() (flen int) {
|
||||
fi, err := os.Stat(f.SourcePath)
|
||||
if err != nil {
|
||||
glog.Errorf("stat(%q) failed: %v", f.SourcePath, err)
|
||||
return 0
|
||||
}
|
||||
return int(fi.Size())
|
||||
|
@ -126,6 +133,7 @@ func (f *FileAsset) GetLength() (flen int) {
|
|||
func (f *FileAsset) GetModTime() (time.Time, error) {
|
||||
fi, err := os.Stat(f.SourcePath)
|
||||
if err != nil {
|
||||
glog.Errorf("stat(%q) failed: %v", f.SourcePath, err)
|
||||
return time.Time{}, err
|
||||
}
|
||||
return fi.ModTime(), nil
|
||||
|
|
|
@ -166,6 +166,7 @@ func ContainerStatusCommand() string {
|
|||
|
||||
// disableOthers disables all other runtimes except for me.
|
||||
func disableOthers(me Manager, cr CommandRunner) error {
|
||||
|
||||
// valid values returned by manager.Name()
|
||||
runtimes := []string{"containerd", "crio", "docker"}
|
||||
for _, name := range runtimes {
|
||||
|
@ -178,13 +179,22 @@ func disableOthers(me Manager, cr CommandRunner) error {
|
|||
if r.Name() == me.Name() {
|
||||
continue
|
||||
}
|
||||
|
||||
// Don't disable containerd if we are bound to it
|
||||
if me.Name() == "Docker" && r.Name() == "containerd" && dockerBoundToContainerd(cr) {
|
||||
glog.Infof("skipping containerd shutdown because we are bound to it")
|
||||
continue
|
||||
}
|
||||
|
||||
// runtime is already disabled, nothing to do.
|
||||
if !r.Active() {
|
||||
continue
|
||||
}
|
||||
|
||||
if err = r.Disable(); err != nil {
|
||||
glog.Warningf("disable failed: %v", err)
|
||||
}
|
||||
|
||||
// Validate that the runtime really is offline - and that Active & Disable are properly written.
|
||||
if r.Active() {
|
||||
return fmt.Errorf("%s is still active", r.Name())
|
||||
|
|
|
@ -364,3 +364,18 @@ func DockerImagesPreloaded(runner command.Runner, images []string) bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func dockerBoundToContainerd(runner command.Runner) bool {
|
||||
// NOTE: assumes systemd
|
||||
rr, err := runner.RunCmd(exec.Command("sudo", "systemctl", "cat", "docker.service"))
|
||||
if err != nil {
|
||||
glog.Warningf("unable to check if docker is bound to containerd")
|
||||
return false
|
||||
}
|
||||
|
||||
if strings.Contains(rr.Stdout.String(), "\nBindsTo=containerd") {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
// +build integration
|
||||
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestErrorSpam asserts that there are no errors displayed
|
||||
func TestErrorSpam(t *testing.T) {
|
||||
if NoneDriver() {
|
||||
t.Skip("none driver always shows a warning")
|
||||
}
|
||||
MaybeParallel(t)
|
||||
|
||||
profile := UniqueProfileName("nospam")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(25))
|
||||
defer CleanupWithLogs(t, profile, cancel)
|
||||
|
||||
// This should likely use multi-node once it's ready
|
||||
args := append([]string{"start", "-p", profile, "-n=1", "--memory=2250", "--wait=false"}, StartArgs()...)
|
||||
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
||||
if err != nil {
|
||||
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err)
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(rr.Stderr.String(), "\n") {
|
||||
if strings.HasPrefix(line, "E") {
|
||||
t.Errorf("unexpected error log in stderr: %q", line)
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(line, "kubectl") || strings.Contains(line, "slow") || strings.Contains(line, "long time") {
|
||||
continue
|
||||
}
|
||||
if len(strings.TrimSpace(line)) > 0 {
|
||||
t.Errorf("unexpected stderr line: %q", line)
|
||||
}
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(rr.Stdout.String(), "\n") {
|
||||
keywords := []string{"error", "fail", "warning", "conflict"}
|
||||
for _, keyword := range keywords {
|
||||
if strings.Contains(line, keyword) {
|
||||
t.Errorf("unexpected %q in stdout line: %q", keyword, line)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -814,11 +814,16 @@ func setupFileSync(ctx context.Context, t *testing.T, profile string) {
|
|||
|
||||
testPem := "./testdata/minikube_test.pem"
|
||||
|
||||
err = copy.Copy(testPem, localTestCertPath())
|
||||
if err != nil {
|
||||
// Write to a temp file for an atomic write
|
||||
tmpPem := localTestCertPath() + ".pem"
|
||||
if err := copy.Copy(testPem, tmpPem); err != nil {
|
||||
t.Fatalf("failed to copy %s: %v", testPem, err)
|
||||
}
|
||||
|
||||
if err := os.Rename(tmpPem, localTestCertPath()); err != nil {
|
||||
t.Fatalf("failed to rename %s: %v", tmpPem, err)
|
||||
}
|
||||
|
||||
want, err := os.Stat(testPem)
|
||||
if err != nil {
|
||||
t.Fatalf("stat failed: %v", err)
|
||||
|
|
Loading…
Reference in New Issue