Merge pull request #34738 from wgliang/optimization1

Optimize some wrong usage and spelling
This commit is contained in:
Yong Tang 2017-09-07 09:45:14 -07:00 committed by GitHub
commit 2dcb77b24c
13 changed files with 25 additions and 27 deletions

View file

@ -181,7 +181,7 @@ type ImageBuildOptions struct {
SessionID string
// TODO @jhowardmsft LCOW Support: This will require extending to include
// `Platform string`, but is ommited for now as it's hard-coded temporarily
// `Platform string`, but is omitted for now as it's hard-coded temporarily
// to avoid API changes.
}

View file

@ -168,7 +168,7 @@ func (daemon *Daemon) containerAttach(c *container.Container, cfg *stream.Attach
// Wait for the container to stop before returning.
waitChan := c.Wait(context.Background(), container.WaitConditionNotRunning)
defer func() {
_ = <-waitChan // Ignore returned exit code.
<-waitChan // Ignore returned exit code.
}()
}

View file

@ -859,7 +859,7 @@ func (daemon *Daemon) shutdownContainer(c *container.Container) error {
// Wait without timeout for the container to exit.
// Ignore the result.
_ = <-c.Wait(context.Background(), container.WaitConditionNotRunning)
<-c.Wait(context.Background(), container.WaitConditionNotRunning)
return nil
}

View file

@ -61,7 +61,7 @@ func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) e
return err
}
if bytes.Compare(fileContent, content) != 0 {
if !bytes.Equal(fileContent, content) {
return fmt.Errorf("mismatched file content %v, expecting %v", fileContent, content)
}
@ -211,7 +211,7 @@ func checkManyFiles(drv graphdriver.Driver, layer string, count int, seed int64)
content := randomContent(64, seed+int64(i+j))
if bytes.Compare(fileContent, content) != 0 {
if !bytes.Equal(fileContent, content) {
return fmt.Errorf("mismatched file content %v, expecting %v", fileContent, content)
}
}
@ -300,7 +300,7 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error {
return err
}
if bytes.Compare(layerIDBytes, []byte(layer)) != 0 {
if !bytes.Equal(layerIDBytes, []byte(layer)) {
return fmt.Errorf("mismatched file content %v, expecting %v", layerIDBytes, []byte(layer))
}
@ -311,7 +311,7 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error {
if err != nil {
return err
}
if bytes.Compare(thisLayerIDBytes, layerIDBytes) != 0 {
if !bytes.Equal(thisLayerIDBytes, layerIDBytes) {
return fmt.Errorf("mismatched file content %v, expecting %v", thisLayerIDBytes, layerIDBytes)
}
layerIDBytes, err = ioutil.ReadFile(path.Join(layerDir, "parent-id"))

View file

@ -23,33 +23,33 @@
//
// * lcow.sandboxsize - Specifies a custom sandbox size in GB for starting a container
// -- Possible values: >= default sandbox size (opengcs defined, currently 20)
// -- Default if ommitted: 20
// -- Default if omitted: 20
//
// The following options are read by opengcs:
//
// * lcow.kirdpath - Specifies a custom path to a kernel/initrd pair
// -- Possible values: Any local path that is not a mapped drive
// -- Default if ommitted: %ProgramFiles%\Linux Containers
// -- Default if omitted: %ProgramFiles%\Linux Containers
//
// * lcow.kernel - Specifies a custom kernel file located in the `lcow.kirdpath` path
// -- Possible values: Any valid filename
// -- Default if ommitted: bootx64.efi
// -- Default if omitted: bootx64.efi
//
// * lcow.initrd - Specifies a custom initrd file located in the `lcow.kirdpath` path
// -- Possible values: Any valid filename
// -- Default if ommitted: initrd.img
// -- Default if omitted: initrd.img
//
// * lcow.bootparameters - Specifies additional boot parameters for booting in kernel+initrd mode
// -- Possible values: Any valid linux kernel boot options
// -- Default if ommitted: <nil>
// -- Default if omitted: <nil>
//
// * lcow.vhdx - Specifies a custom vhdx file to boot (instead of a kernel+initrd)
// -- Possible values: Any valid filename
// -- Default if ommitted: uvm.vhdx under `lcow.kirdpath`
// -- Default if omitted: uvm.vhdx under `lcow.kirdpath`
//
// * lcow.timeout - Specifies a timeout for utility VM operations in seconds
// -- Possible values: >=0
// -- Default if ommitted: 300
// -- Default if omitted: 300
// TODO: Grab logs from SVM at terminate or errors
@ -836,7 +836,7 @@ func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) {
ci.Unlock()
// Start the SVM with a mapped virtual disk. Note that if the SVM is
// already runing and we are in global mode, this will be
// already running and we are in global mode, this will be
// hot-added.
mvd := &hcsshim.MappedVirtualDisk{
HostPath: ci.hostPath,

View file

@ -160,7 +160,7 @@ func (daemon *Daemon) Kill(container *containerpkg.Container) error {
// Wait for exit with no timeout.
// Ignore returned status.
_ = <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning)
<-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning)
return nil
}

View file

@ -78,7 +78,7 @@ func (daemon *Daemon) containerStop(container *containerpkg.Container, seconds i
// 3. If it doesn't, then send SIGKILL
if err := daemon.Kill(container); err != nil {
// Wait without a timeout, ignore result.
_ = <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning)
<-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning)
logrus.Warn(err) // Don't return error because we only care that container is stopped, not what function stopped it
}
}

View file

@ -73,14 +73,14 @@ func executeTests(funkerName string, testChunks [][]string) error {
}
log.Printf("Finished chunk %d [%d/%d] with %d test filters in %s, code=%d.",
chunkID, passed+failed, len(testChunks), len(tests),
time.Now().Sub(chunkBegin), result.Code)
time.Since(chunkBegin), result.Code)
}
}(chunkID, tests)
}
wg.Wait()
// TODO: print actual tests rather than chunks
log.Printf("Executed %d chunks in %s. PASS: %d, FAIL: %d.",
len(testChunks), time.Now().Sub(begin), passed, failed)
len(testChunks), time.Since(begin), passed, failed)
if failed > 0 {
return fmt.Errorf("%d chunks failed", failed)
}
@ -103,7 +103,7 @@ func executeTestChunk(funkerName string, args types.Args) (types.Result, error)
func executeTestChunkWithRetry(funkerName string, args types.Args) (types.Result, error) {
begin := time.Now()
for i := 0; time.Now().Sub(begin) < funkerRetryTimeout; i++ {
for i := 0; time.Since(begin) < funkerRetryTimeout; i++ {
result, err := executeTestChunk(funkerName, args)
if err == nil {
log.Printf("executeTestChunk(%q, %d) returned code %d in trial %d", funkerName, args.ChunkID, result.Code, i)

View file

@ -58,7 +58,7 @@ func handle(workerImageDigest string, executor testChunkExecutor) error {
RawLog: rawLog,
}
}
elapsed := time.Now().Sub(begin)
elapsed := time.Since(begin)
log.Printf("Finished chunk %d, code=%d, elapsed=%v", args.ChunkID, code, elapsed)
return types.Result{
ChunkID: args.ChunkID,

View file

@ -193,9 +193,7 @@ func runDockerCp(c *check.C, src, dst string, params []string) (err error) {
args := []string{"cp"}
for _, param := range params {
args = append(args, param)
}
args = append(args, params...)
args = append(args, src, dst)

View file

@ -36,7 +36,7 @@ func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) {
// List of available time formats to --since
unixTs := func(t time.Time) string { return fmt.Sprintf("%v", t.Unix()) }
rfc3339 := func(t time.Time) string { return t.Format(time.RFC3339) }
duration := func(t time.Time) string { return time.Now().Sub(t).String() }
duration := func(t time.Time) string { return time.Since(t).String() }
// --since=$start must contain only the 'untag' event
for _, f := range []func(time.Time) string{unixTs, rfc3339, duration} {

View file

@ -7,7 +7,7 @@ import (
"golang.org/x/net/context"
)
// CreateOpt is is passed used to change the defualt plugin config before
// CreateOpt is is passed used to change the default plugin config before
// creating it
type CreateOpt func(*Config)

View file

@ -12,7 +12,7 @@ import (
)
// DevmapperLogger defines methods required to register as a callback for
// logging events recieved from devicemapper. Note that devicemapper will send
// logging events received from devicemapper. Note that devicemapper will send
// *all* logs regardless to callbacks (including debug logs) so it's
// recommended to not spam the console with the outputs.
type DevmapperLogger interface {