The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Find a file
Kir Kolyshkin 516010e92d Simplify/fix MkdirAll usage
This subtle bug keeps lurking in because error checking for `Mkdir()`
and `MkdirAll()` is slightly different wrt to `EEXIST`/`IsExist`:

 - for `Mkdir()`, `IsExist` error should (usually) be ignored
   (unless you want to make sure directory was not there before)
   as it means "the destination directory was already there"

 - for `MkdirAll()`, `IsExist` error should NEVER be ignored.

Mostly, this commit just removes ignoring the IsExist error, as it
should not be ignored.

Also, there are a couple of cases then IsExist is handled as
"directory already exist" which is wrong. As a result, some code
that never worked as intended is now removed.

NOTE that `idtools.MkdirAndChown()` behaves like `os.MkdirAll()`
rather than `os.Mkdir()` -- so its description is amended accordingly,
and its usage is handled as such (i.e. IsExist error is not ignored).

For more details, a quote from my runc commit 6f82d4b (July 2015):

    TL;DR: check for IsExist(err) after a failed MkdirAll() is both
    redundant and wrong -- so two reasons to remove it.

    Quoting MkdirAll documentation:

    > MkdirAll creates a directory named path, along with any necessary
    > parents, and returns nil, or else returns an error. If path
    > is already a directory, MkdirAll does nothing and returns nil.

    This means two things:

    1. If a directory to be created already exists, no error is
    returned.

    2. If the error returned is IsExist (EEXIST), it means there exists
    a non-directory with the same name as MkdirAll need to use for
    directory. Example: we want to MkdirAll("a/b"), but file "a"
    (or "a/b") already exists, so MkdirAll fails.

    The above is a theory, based on quoted documentation and my UNIX
    knowledge.

    3. In practice, though, current MkdirAll implementation [1] returns
    ENOTDIR in most of cases described in #2, with the exception when
    there is a race between MkdirAll and someone else creating the
    last component of MkdirAll argument as a file. In this very case
    MkdirAll() will indeed return EEXIST.

    Because of #1, IsExist check after MkdirAll is not needed.

    Because of #2 and #3, ignoring IsExist error is just plain wrong,
    as directory we require is not created. It's cleaner to report
    the error now.

    Note this error is all over the tree, I guess due to copy-paste,
    or trying to follow the same usage pattern as for Mkdir(),
    or some not quite correct examples on the Internet.

    [1] https://github.com/golang/go/blob/f9ed2f75/src/os/path.go

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-11-27 17:32:12 -08:00
.github Rename a few docker to moby 2017-10-25 13:56:12 +02:00
api Fix consumes MIME type for NetworkConnect 2017-11-18 22:34:23 -05:00
builder Merge pull request #35429 from dnephin/build-fails-on-long-label 2017-11-15 18:48:50 +01:00
cli Update logrus to v1.0.1 2017-07-31 13:16:46 -07:00
client Merge pull request #32914 from jamiehannaford/until-logging 2017-11-03 16:08:30 +01:00
cmd/dockerd Remove deprecated support for duplicate label-keys 2017-11-12 03:11:37 +01:00
container container: update real-time resources 2017-11-22 22:21:40 +01:00
contrib Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
daemon Simplify/fix MkdirAll usage 2017-11-27 17:32:12 -08:00
distribution Remove Docker from some functions 2017-10-25 14:39:51 +02:00
dockerversion Spelling fixes 2017-07-03 13:13:09 -07:00
docs Move "until" option to correct API version 2017-11-03 16:11:07 +01:00
hack graphdriver: custom build-time priority list 2017-11-16 19:43:34 -08:00
image LCOW: API change JSON header to string POST parameter 2017-10-06 15:26:48 -07:00
integration Fix layer DNE with duplicate layers. 2017-11-23 15:41:59 -05:00
integration-cli Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
internal internal: testutil: add DevZero helper 2017-11-08 03:45:55 +11:00
layer Remove solaris build tag and `contrib/mkimage/solaris 2017-11-02 00:01:46 +00:00
libcontainerd Cancelation errors should not be logged 2017-11-14 20:32:20 -05:00
migrate/v1 LCOW: API: Add platform to /images/create and /build 2017-10-06 11:44:18 -07:00
oci Don't special case /sys/firmware in masked paths 2017-11-08 12:10:42 -08:00
opts Updated GenericResource CLI 2017-11-06 21:47:26 +01:00
pkg Simplify/fix MkdirAll usage 2017-11-27 17:32:12 -08:00
plugin Merge pull request #35265 from cpuguy83/32609_defreference_voldriver_on_error 2017-11-07 09:47:07 -08:00
profiles Copy Inslice() to those parts that use it 2017-11-10 13:42:38 +08:00
project Fix GitHub spelling 2017-10-07 00:10:24 +08:00
reference Add gosimple linter 2017-09-12 12:09:59 -04:00
registry Remove solaris build tag and `contrib/mkimage/solaris 2017-11-02 00:01:46 +00:00
reports Add builder dev report for 2017-07-17 2017-07-18 18:31:42 -07:00
restartmanager Adding support for docker max restart time 2017-02-04 03:54:47 +00:00
runconfig Remove solaris build tag and `contrib/mkimage/solaris 2017-11-02 00:01:46 +00:00
vendor Update hcsshim to v0.6.7 for go1.9 support 2017-11-20 16:29:01 -08:00
volume Simplify/fix MkdirAll usage 2017-11-27 17:32:12 -08:00
.dockerignore [EXPERIMENTAL] Integration Test on Swarm 2017-02-28 02:10:09 +00:00
.gitignore Cleanup test output, and binaries. 2017-08-09 11:02:57 -04:00
.mailmap Update mailmap and authors 2017-10-04 14:44:24 +02:00
AUTHORS Update mailmap and authors 2017-10-04 14:44:24 +02:00
CHANGELOG.md Dropped hyphen in bind mount where appropriate 2017-08-19 21:25:07 +07:00
CONTRIBUTING.md First pass updating CONTRIBUTING 2017-11-03 11:54:55 +00:00
Dockerfile Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
Dockerfile.aarch64 Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
Dockerfile.armhf Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
Dockerfile.e2e Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
Dockerfile.ppc64le Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
Dockerfile.s390x Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
Dockerfile.simple Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
Dockerfile.windows Bump Go to 1.9.2 2017-11-21 20:57:02 +01:00
LICENSE Update copyright dates 2017-02-24 19:41:59 +00:00
MAINTAINERS Update Misty's GitHub handle 2017-11-02 16:46:37 +01:00
Makefile Fix "make test" failing on missing "test-unit" 2017-11-20 19:12:25 +01:00
NOTICE Update LICENSE date 2017-02-15 17:34:33 +01:00
poule.yml Disable auto-assigning PR's to milestones 2017-06-13 03:32:48 +02:00
README.md Add "Lego set" back in README.md 2017-10-10 14:10:39 +00:00
ROADMAP.md Update the Roadmap 2017-10-11 17:33:50 +01:00
TESTING.md Add testing.md 2017-08-04 17:36:18 -04:00
vendor.conf Update hcsshim to v0.6.7 for go1.9 support 2017-11-20 16:29:01 -08:00
VENDORING.md fix the bare url and the Summary of http://semver.org 2017-01-17 16:20:11 +08:00

The Moby Project

Moby Project logo

Moby is an open-source project created by Docker to enable and accelerate software containerization.

It provides a "Lego set" of toolkit components, the framework for assembling them into custom container-based systems, and a place for all container enthusiasts and professionals to experiment and exchange ideas. Components include container build tools, a container registry, orchestration tools, a runtime and more, and these can be used as building blocks in conjunction with other tools and projects.

Principles

Moby is an open project guided by strong principles, aiming to be modular, flexible and without too strong an opinion on user experience. It is open to the community to help set its direction.

  • Modular: the project includes lots of components that have well-defined functions and APIs that work together.
  • Batteries included but swappable: Moby includes enough components to build fully featured container system, but its modular architecture ensures that most of the components can be swapped by different implementations.
  • Usable security: Moby provides secure defaults without compromising usability.
  • Developer focused: The APIs are intended to be functional and useful to build powerful tools. They are not necessarily intended as end user tools but as components aimed at developers. Documentation and UX is aimed at developers not end users.

Audience

The Moby Project is intended for engineers, integrators and enthusiasts looking to modify, hack, fix, experiment, invent and build systems based on containers. It is not for people looking for a commercially supported system, but for people who want to work and learn with open source code.

Relationship with Docker

The components and tools in the Moby Project are initially the open source components that Docker and the community have built for the Docker Project. New projects can be added if they fit with the community goals. Docker is committed to using Moby as the upstream for the Docker Product. However, other projects are also encouraged to use Moby as an upstream, and to reuse the components in diverse ways, and all these uses will be treated in the same way. External maintainers and contributors are welcomed.

The Moby project is not intended as a location for support or feature requests for Docker products, but as a place for contributors to work on open source code, fix bugs, and make the code more useful. The releases are supported by the maintainers, community and users, on a best efforts basis only, and are not intended for customers who want enterprise or commercial support; Docker EE is the appropriate product for these use cases.


Legal

Brought to you courtesy of our legal counsel. For more context, please see the NOTICE document in this repo.

Use and transfer of Moby may be subject to certain restrictions by the United States and other governments.

It is your responsibility to ensure that your use and/or transfer does not violate applicable laws.

For more information, please see https://www.bis.doc.gov

Licensing

Moby is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.