diff --git a/Documentation/architecture.md b/Documentation/architecture.md index 98f33a2..1fd44c7 100644 --- a/Documentation/architecture.md +++ b/Documentation/architecture.md @@ -14,8 +14,8 @@ Execution with Rocket is divided into several distinct stages. The first stage is the actual `rkt` binary itself. When running a container, this binary is responsible for performing a number of initial preparatory tasks: - Fetching the specified ACIs, including the stage 1 ACI of --stage1-image if specified. -- Generating a Container UUID -- Generating a Container Runtime Manifest +- Generating a Pod UUID +- Generating a Pod Manifest - Creating a filesystem for the container - Setting up stage 1 and stage 2 directories in the filesystem - Unpacking the stage 1 ACI into the container filesystem @@ -55,7 +55,7 @@ At this point the stage0 execs `/stage1/rootfs/init` with the current working di The next stage is a binary that the user trusts to set up cgroups, execute processes, and perform other operations as root on the host. This stage has the responsibility of taking the execution group filesystem that was created by stage 0 and creating the necessary cgroups, namespaces and mounts to launch the execution group: -- Generate systemd unit files from the Image and Container Runtime Manifests. The Image Manifest defines the default `exec` specifications of each application; the Container Runtime Manifest defines the ordering of the units, as well as any `exec` overrides. +- Generate systemd unit files from the Image and Pod Manifests. The Image Manifest defines the default `exec` specifications of each application; the Pod Manifest defines the ordering of the units, as well as any `exec` overrides. - (containing, respectively, the exec specifications of each container and the ordering given by the user) - Set up any external volumes (undefined at this point) - nspawn attaching to the bridge and launch the execution group systemd diff --git a/Documentation/stage1-implementors-guide.md b/Documentation/stage1-implementors-guide.md index b615221..8af4aa1 100644 --- a/Documentation/stage1-implementors-guide.md +++ b/Documentation/stage1-implementors-guide.md @@ -12,11 +12,11 @@ Rocket's execution of containers is divided roughly into three separate stages: This separation of concerns is reflected in the file-system and layout of the composite image prepared by stage 0: -0. Stage 0: `rkt` executable, and the Container Runtime Manifest created at "/var/lib/rkt/containers/$uuid/container". -1. Stage 1: "stage1.aci", made available at "/var/lib/rkt/containers/$uuid/stage1" by `rkt run`. -2. Stage 2: "$app.aci", made available at "/var/lib/rkt/containers/$uuid/stage1/rootfs/opt/stage2/$imageid" by `rkt run`. +0. Stage 0: `rkt` executable, and the Pod Manifest created at "/var/lib/rkt/pods/$uuid/container". +1. Stage 1: "stage1.aci", made available at "/var/lib/rkt/pods/$uuid/stage1" by `rkt run`. +2. Stage 2: "$app.aci", made available at "/var/lib/rkt/pods/$uuid/stage1/rootfs/opt/stage2/$imageid" by `rkt run`. -The stage 1 implementation is what creates the execution environment for the contained applications. This occurs via entrypoints from stage 0 on behalf of `rkt run` and `rkt enter`. These entrypoints are nothing more than executable programs located via Annotations from within the stage 1 ACI manifest, and executed from within the stage 1 of a given container at "/var/lib/rkt/containers/$uuid/stage1/rootfs". +The stage 1 implementation is what creates the execution environment for the contained applications. This occurs via entrypoints from stage 0 on behalf of `rkt run` and `rkt enter`. These entrypoints are nothing more than executable programs located via Annotations from within the stage 1 ACI manifest, and executed from within the stage 1 of a given container at "/var/lib/rkt/pods/$uuid/stage1/rootfs". Stage 2 is the destination application images and stage 1 is the vehicle for getting us there from stage 0. For any given container instance, the stage 1 may be completely different, allowing for flexibility in containment strategies employed within the same host while utilizing reusable application ACIs. @@ -25,18 +25,18 @@ Entrypoints ### `rkt run` => "coreos.com/rocket/stage1/run" -0. rkt prepares the container's stage 1 and stage 2 images and Container Runtime Manifest under "/var/lib/rkt/containers/$uuid", acquiring an exclusive advisory lock on the directory. -1. chdirs to "/var/lib/rkt/containers/$uuid" -2. resolves the "coreos.com/rocket/stage1/run" entrypoint via Annotations found within "/var/lib/rkt/containers/$uuid/stage1/manifest" -3. executes the resolved entrypoint relative to "/var/lib/rkt/containers/$uuid/stage1/rootfs" +0. rkt prepares the container's stage 1 and stage 2 images and Pod Manifest under "/var/lib/rkt/pods/$uuid", acquiring an exclusive advisory lock on the directory. +1. chdirs to "/var/lib/rkt/pods/$uuid" +2. resolves the "coreos.com/rocket/stage1/run" entrypoint via Annotations found within "/var/lib/rkt/pods/$uuid/stage1/manifest" +3. executes the resolved entrypoint relative to "/var/lib/rkt/pods/$uuid/stage1/rootfs" -It is the responsibility of this entrypoint to consume the Container Runtime Manifest and execute the constituent apps in the appropriate environments as specified by the Container Runtime Manifest. +It is the responsibility of this entrypoint to consume the Pod Manifest and execute the constituent apps in the appropriate environments as specified by the Pod Manifest. -The environment variable "RKT_LOCK_FD" contains the file descriptor number of the open directory handle for "/var/lib/rkt/containers/$uuid". It is necessary that stage 1 leave this file descriptor open and in its locked state for the duration of the `rkt run`. +The environment variable "RKT_LOCK_FD" contains the file descriptor number of the open directory handle for "/var/lib/rkt/pods/$uuid". It is necessary that stage 1 leave this file descriptor open and in its locked state for the duration of the `rkt run`. -In the bundled rocket stage 1 which includes systemd-nspawn and systemd, the entrypoint is a static Go program found at "/init" within the stage 1 ACI rootfs. The majority of its execution entails generating a systemd-nspawn argument list and writing systemd unit files for the constituent apps before executing systemd-nspawn. Systemd-nspawn then boots the stage 1 systemd with the just-written unit files for launching the contained apps. The "/init" program is essentially a Container Runtime Manifest to systemd-nspawn + systemd.service translator. +In the bundled rocket stage 1 which includes systemd-nspawn and systemd, the entrypoint is a static Go program found at "/init" within the stage 1 ACI rootfs. The majority of its execution entails generating a systemd-nspawn argument list and writing systemd unit files for the constituent apps before executing systemd-nspawn. Systemd-nspawn then boots the stage 1 systemd with the just-written unit files for launching the contained apps. The "/init" program is essentially a Pod Manifest to systemd-nspawn + systemd.service translator. -An alternative stage 1 could forego systemd-nspawn and systemd altogether, or retain these and introduce something like novm or qemu-kvm for greater isolation by first starting a VM. All that is required is an executable at the place indicated by the "coreos.com/rocket/stage1/run" entrypoint which knows how to apply the Container Runtime Manifest and prepared ACI file-systems to good effect. +An alternative stage 1 could forego systemd-nspawn and systemd altogether, or retain these and introduce something like novm or qemu-kvm for greater isolation by first starting a VM. All that is required is an executable at the place indicated by the "coreos.com/rocket/stage1/run" entrypoint which knows how to apply the Pod Manifest and prepared ACI file-systems to good effect. #### Arguments @@ -47,9 +47,9 @@ An alternative stage 1 could forego systemd-nspawn and systemd altogether, or re ### `rkt enter` => "coreos.com/rocket/stage1/enter" 0. rkt verifies the container and image to enter are valid and running -1. chdirs to "/var/lib/rkt/containers/$uuid" -2. resolves the "coreos.com/rocket/stage1/enter" entrypoint via Annotations found within "/var/lib/rkt/containers/$uuid/stage1/manifest" -3. executes the resolved entrypoint relative to "/var/lib/rkt/containers/$uuid/stage1/rootfs" +1. chdirs to "/var/lib/rkt/pods/$uuid" +2. resolves the "coreos.com/rocket/stage1/enter" entrypoint via Annotations found within "/var/lib/rkt/pods/$uuid/stage1/manifest" +3. executes the resolved entrypoint relative to "/var/lib/rkt/pods/$uuid/stage1/rootfs" In the bundled rocket stage 1 the entrypoint is a statically-linked C program found at "/enter" within the stage 1 ACI rootfs. This program enters the namespaces of the systemd-nspawn container's PID 1 before executing the "/diagexec" program which then chroots into the specific application's rootfs loading the application's environment variables as well. diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 4e41570..aaaf716 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,6 +1,6 @@ { "ImportPath": "github.com/coreos/rocket", - "GoVersion": "go1.4.2", + "GoVersion": "go1.4.1", "Packages": [ "./..." ], @@ -25,33 +25,33 @@ }, { "ImportPath": "github.com/appc/spec/aci", - "Comment": "v0.4.0-10-g24650793e48a", - "Rev": "24650793e48a5a7fd04bf680e25c5ae192e4241d" + "Comment": "v0.5.0", + "Rev": "cffea391f209199b873af3f8a71a98ac658f073e" }, { "ImportPath": "github.com/appc/spec/actool", - "Comment": "v0.4.0-10-g24650793e48a", - "Rev": "24650793e48a5a7fd04bf680e25c5ae192e4241d" + "Comment": "v0.5.0", + "Rev": "cffea391f209199b873af3f8a71a98ac658f073e" }, { "ImportPath": "github.com/appc/spec/discovery", - "Comment": "v0.4.0-10-g24650793e48a", - "Rev": "24650793e48a5a7fd04bf680e25c5ae192e4241d" + "Comment": "v0.5.0", + "Rev": "cffea391f209199b873af3f8a71a98ac658f073e" }, { "ImportPath": "github.com/appc/spec/pkg/acirenderer", - "Comment": "v0.4.0-10-g24650793e48a", - "Rev": "24650793e48a5a7fd04bf680e25c5ae192e4241d" + "Comment": "v0.5.0", + "Rev": "cffea391f209199b873af3f8a71a98ac658f073e" }, { "ImportPath": "github.com/appc/spec/pkg/tarheader", - "Comment": "v0.4.0-10-g24650793e48a", - "Rev": "24650793e48a5a7fd04bf680e25c5ae192e4241d" + "Comment": "v0.5.0", + "Rev": "cffea391f209199b873af3f8a71a98ac658f073e" }, { "ImportPath": "github.com/appc/spec/schema", - "Comment": "v0.4.0-10-g24650793e48a", - "Rev": "24650793e48a5a7fd04bf680e25c5ae192e4241d" + "Comment": "v0.5.0", + "Rev": "cffea391f209199b873af3f8a71a98ac658f073e" }, { "ImportPath": "github.com/camlistore/lock", diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/build.go b/Godeps/_workspace/src/github.com/appc/spec/aci/build.go index 7a72d5e..0cfc6cc 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/aci/build.go +++ b/Godeps/_workspace/src/github.com/appc/spec/aci/build.go @@ -35,6 +35,9 @@ func BuildWalker(root string, aw ArchiveWriter) filepath.WalkFunc { link := "" var r io.Reader switch info.Mode() & os.ModeType { + case os.ModeSocket: + return nil + case os.ModeNamedPipe: case os.ModeCharDevice: case os.ModeDevice: case os.ModeDir: diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/file_test.go b/Godeps/_workspace/src/github.com/appc/spec/aci/file_test.go index 8ec62ad..939fd0e 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/aci/file_test.go +++ b/Godeps/_workspace/src/github.com/appc/spec/aci/file_test.go @@ -14,7 +14,7 @@ func newTestACI(usedotslash bool) (*os.File, error) { return nil, err } - manifestBody := `{"acKind":"ImageManifest","acVersion":"0.4.0","name":"example.com/app"}` + manifestBody := `{"acKind":"ImageManifest","acVersion":"0.5.0","name":"example.com/app"}` gw := gzip.NewWriter(tf) tw := tar.NewWriter(gw) diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/layout.go b/Godeps/_workspace/src/github.com/appc/spec/aci/layout.go index b394fd7..eecc7ef 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/aci/layout.go +++ b/Godeps/_workspace/src/github.com/appc/spec/aci/layout.go @@ -60,8 +60,7 @@ func ValidateLayout(dir string) error { if err != nil { return err } - name := filepath.Base(rpath) - switch name { + switch rpath { case ".": case ManifestFile: im, err = os.Open(fpath) @@ -85,7 +84,7 @@ func ValidateLayout(dir string) error { return validate(imOK, im, rfsOK, flist) } -// ValidateLayout takes a *tar.Reader and validates that the layout of the +// ValidateArchive takes a *tar.Reader and validates that the layout of the // filesystem the reader encapsulates matches that expected by the // Application Container Image format. If any errors are encountered during // the validation, it will abort and return the first one. diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/layout_test.go b/Godeps/_workspace/src/github.com/appc/spec/aci/layout_test.go new file mode 100644 index 0000000..8f28414 --- /dev/null +++ b/Godeps/_workspace/src/github.com/appc/spec/aci/layout_test.go @@ -0,0 +1,62 @@ +package aci + +import ( + "io/ioutil" + "os" + "path" + "testing" +) + +func newValidateLayoutTest() (string, error) { + td, err := ioutil.TempDir("", "") + if err != nil { + return "", err + } + + if err := os.MkdirAll(path.Join(td, "rootfs"), 0755); err != nil { + return "", err + } + + if err := os.MkdirAll(path.Join(td, "rootfs", "dir", "rootfs"), 0755); err != nil { + return "", err + } + + evilManifestBody := "malformedManifest" + manifestBody := `{"acKind":"ImageManifest","acVersion":"0.3.0","name":"example.com/app"}` + + evilManifestPath := "rootfs/manifest" + evilManifestPath = path.Join(td, evilManifestPath) + + em, err := os.Create(evilManifestPath) + if err != nil { + return "", err + } + + em.WriteString(evilManifestBody) + em.Close() + + manifestPath := path.Join(td, "manifest") + + m, err := os.Create(manifestPath) + if err != nil { + return "", err + } + + m.WriteString(manifestBody) + m.Close() + + return td, nil +} + +func TestValidateLayout(t *testing.T) { + layoutPath, err := newValidateLayoutTest() + if err != nil { + t.Fatalf("newValidateLayoutTest: unexpected error: %v", err) + } + defer os.RemoveAll(layoutPath) + + err = ValidateLayout(layoutPath) + if err != nil { + t.Fatalf("ValidateLayout: unexpected error: %v", err) + } +} diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/validate.go b/Godeps/_workspace/src/github.com/appc/spec/actool/validate.go index 61984d2..23dede8 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/validate.go +++ b/Godeps/_workspace/src/github.com/appc/spec/actool/validate.go @@ -123,8 +123,8 @@ func runValidate(args []string) (exit int) { case "ImageManifest": m := schema.ImageManifest{} err = m.UnmarshalJSON(b) - case "ContainerRuntimeManifest": - m := schema.ContainerRuntimeManifest{} + case "PodManifest": + m := schema.PodManifest{} err = m.UnmarshalJSON(b) default: // Should not get here; schema.Kind unmarshal should fail diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go b/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go index 153ec29..6fba728 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go +++ b/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go @@ -21,6 +21,7 @@ var ( func init() { t := &http.Transport{ + Proxy: http.ProxyFromEnvironment, Dial: func(n, a string) (net.Conn, error) { return net.DialTimeout(n, a, defaultDialTimeout) }, diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/container.go b/Godeps/_workspace/src/github.com/appc/spec/schema/container.go deleted file mode 100644 index a3ea5ef..0000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/container.go +++ /dev/null @@ -1,111 +0,0 @@ -package schema - -import ( - "encoding/json" - "errors" - - "github.com/coreos/rocket/Godeps/_workspace/src/github.com/appc/spec/schema/types" -) - -const ContainerRuntimeManifestKind = types.ACKind("ContainerRuntimeManifest") - -type ContainerRuntimeManifest struct { - ACVersion types.SemVer `json:"acVersion"` - ACKind types.ACKind `json:"acKind"` - UUID types.UUID `json:"uuid"` - Apps AppList `json:"apps"` - Volumes []types.Volume `json:"volumes"` - Isolators []types.Isolator `json:"isolators"` - Annotations types.Annotations `json:"annotations"` -} - -// containerRuntimeManifest is a model to facilitate extra validation during the -// unmarshalling of the ContainerRuntimeManifest -type containerRuntimeManifest ContainerRuntimeManifest - -func BlankContainerRuntimeManifest() *ContainerRuntimeManifest { - return &ContainerRuntimeManifest{ACKind: ContainerRuntimeManifestKind, ACVersion: AppContainerVersion} -} - -func (cm *ContainerRuntimeManifest) UnmarshalJSON(data []byte) error { - c := containerRuntimeManifest(*cm) - err := json.Unmarshal(data, &c) - if err != nil { - return err - } - ncm := ContainerRuntimeManifest(c) - if err := ncm.assertValid(); err != nil { - return err - } - *cm = ncm - return nil -} - -func (cm ContainerRuntimeManifest) MarshalJSON() ([]byte, error) { - if err := cm.assertValid(); err != nil { - return nil, err - } - return json.Marshal(containerRuntimeManifest(cm)) -} - -var cmKindError = types.InvalidACKindError(ContainerRuntimeManifestKind) - -// assertValid performs extra assertions on an ContainerRuntimeManifest to -// ensure that fields are set appropriately, etc. It is used exclusively when -// marshalling and unmarshalling an ContainerRuntimeManifest. Most -// field-specific validation is performed through the individual types being -// marshalled; assertValid() should only deal with higher-level validation. -func (cm *ContainerRuntimeManifest) assertValid() error { - if cm.ACKind != ContainerRuntimeManifestKind { - return cmKindError - } - return nil -} - -type AppList []RuntimeApp - -// Get retrieves an app by the specified name from the AppList; if there is -// no such app, nil is returned. The returned *RuntimeApp MUST be considered -// read-only. -func (al AppList) Get(name types.ACName) *RuntimeApp { - for _, a := range al { - if name.Equals(a.Name) { - aa := a - return &aa - } - } - return nil -} - -// Mount describes the mapping between a volume and an apps -// MountPoint that will be fulfilled at runtime. -type Mount struct { - Volume types.ACName `json:"volume"` - MountPoint types.ACName `json:"mountPoint"` -} - -func (r Mount) assertValid() error { - if r.Volume.Empty() { - return errors.New("volume must be set") - } - if r.MountPoint.Empty() { - return errors.New("mountPoint must be set") - } - return nil -} - -// RuntimeApp describes an application referenced in a ContainerRuntimeManifest -type RuntimeApp struct { - Name types.ACName `json:"name"` - Image RuntimeImage `json:"image"` - App *types.App `json:"app,omitempty"` - Mounts []Mount `json:"mounts"` - Annotations types.Annotations `json:"annotations"` -} - -// RuntimeImage describes an image referenced in a RuntimeApp -type RuntimeImage struct { - Name types.ACName `json:"name"` - ID types.Hash `json:"id"` - Labels types.Labels `json:"labels"` -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/container_test.go b/Godeps/_workspace/src/github.com/appc/spec/schema/container_test.go deleted file mode 100644 index b7645b3..0000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/container_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package schema - -import "testing" - -func TestContainerRuntimeManifestMerge(t *testing.T) { - cmj := `{}` - cm := &ContainerRuntimeManifest{} - - if cm.UnmarshalJSON([]byte(cmj)) == nil { - t.Fatal("Manifest JSON without acKind and acVersion unmarshalled successfully") - } - - cm = BlankContainerRuntimeManifest() - - err := cm.UnmarshalJSON([]byte(cmj)) - if err != nil { - t.Errorf("unexpected error: %v", err) - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/doc.go b/Godeps/_workspace/src/github.com/appc/spec/schema/doc.go index acb537a..8107c40 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/doc.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/doc.go @@ -2,7 +2,7 @@ // manifests in the App Container Specification. The manifests are canonically // represented in their respective structs: // - `ImageManifest` -// - `ContainerRuntimeManifest` +// - `PodManifest` // // Validation is performed through serialization: if a blob of JSON data will // unmarshal to one of the *Manifests, it is considered a valid implementation diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/image_test.go b/Godeps/_workspace/src/github.com/appc/spec/schema/image_test.go index 079af4a..2d832c9 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/image_test.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/image_test.go @@ -6,7 +6,7 @@ func TestEmptyApp(t *testing.T) { imj := ` { "acKind": "ImageManifest", - "acVersion": "0.4.0", + "acVersion": "0.5.0", "name": "example.com/test" } ` diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go b/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go new file mode 100644 index 0000000..e97be0d --- /dev/null +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go @@ -0,0 +1,147 @@ +package schema + +import ( + "encoding/json" + "errors" + "fmt" + + "github.com/coreos/rocket/Godeps/_workspace/src/github.com/appc/spec/schema/types" +) + +const PodManifestKind = types.ACKind("PodManifest") + +type PodManifest struct { + ACVersion types.SemVer `json:"acVersion"` + ACKind types.ACKind `json:"acKind"` + UUID types.UUID `json:"uuid"` + Apps AppList `json:"apps"` + Volumes []types.Volume `json:"volumes"` + Isolators []types.Isolator `json:"isolators"` + Annotations types.Annotations `json:"annotations"` + Ports []types.ExposedPort `json:"ports"` +} + +// podManifest is a model to facilitate extra validation during the +// unmarshalling of the PodManifest +type podManifest PodManifest + +func BlankPodManifest() *PodManifest { + return &PodManifest{ACKind: PodManifestKind, ACVersion: AppContainerVersion} +} + +func (pm *PodManifest) UnmarshalJSON(data []byte) error { + p := podManifest(*pm) + err := json.Unmarshal(data, &p) + if err != nil { + return err + } + npm := PodManifest(p) + if err := npm.assertValid(); err != nil { + return err + } + *pm = npm + return nil +} + +func (pm PodManifest) MarshalJSON() ([]byte, error) { + if err := pm.assertValid(); err != nil { + return nil, err + } + return json.Marshal(podManifest(pm)) +} + +var pmKindError = types.InvalidACKindError(PodManifestKind) + +// assertValid performs extra assertions on an PodManifest to +// ensure that fields are set appropriately, etc. It is used exclusively when +// marshalling and unmarshalling an PodManifest. Most +// field-specific validation is performed through the individual types being +// marshalled; assertValid() should only deal with higher-level validation. +func (pm *PodManifest) assertValid() error { + if pm.ACKind != PodManifestKind { + return pmKindError + } + return nil +} + +type AppList []RuntimeApp + +type appList AppList + +func (al *AppList) UnmarshalJSON(data []byte) error { + a := appList{} + err := json.Unmarshal(data, &a) + if err != nil { + return err + } + nal := AppList(a) + if err := nal.assertValid(); err != nil { + return err + } + *al = nal + return nil +} + +func (al AppList) MarshalJSON() ([]byte, error) { + if err := al.assertValid(); err != nil { + return nil, err + } + return json.Marshal(appList(al)) +} + +func (al AppList) assertValid() error { + seen := map[types.ACName]bool{} + for _, a := range al { + if _, ok := seen[a.Name]; ok { + return fmt.Errorf(`duplicate apps of name %q`, a.Name) + } + seen[a.Name] = true + } + return nil +} + +// Get retrieves an app by the specified name from the AppList; if there is +// no such app, nil is returned. The returned *RuntimeApp MUST be considered +// read-only. +func (al AppList) Get(name types.ACName) *RuntimeApp { + for _, a := range al { + if name.Equals(a.Name) { + aa := a + return &aa + } + } + return nil +} + +// Mount describes the mapping between a volume and an apps +// MountPoint that will be fulfilled at runtime. +type Mount struct { + Volume types.ACName `json:"volume"` + MountPoint types.ACName `json:"mountPoint"` +} + +func (r Mount) assertValid() error { + if r.Volume.Empty() { + return errors.New("volume must be set") + } + if r.MountPoint.Empty() { + return errors.New("mountPoint must be set") + } + return nil +} + +// RuntimeApp describes an application referenced in a PodManifest +type RuntimeApp struct { + Name types.ACName `json:"name"` + Image RuntimeImage `json:"image"` + App *types.App `json:"app,omitempty"` + Mounts []Mount `json:"mounts,omitempty"` + Annotations types.Annotations `json:"annotations,omitempty"` +} + +// RuntimeImage describes an image referenced in a RuntimeApp +type RuntimeImage struct { + Name *types.ACName `json:"name,omitempty"` + ID types.Hash `json:"id"` + Labels types.Labels `json:"labels,omitempty"` +} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/pod_test.go b/Godeps/_workspace/src/github.com/appc/spec/schema/pod_test.go new file mode 100644 index 0000000..96ccd1d --- /dev/null +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/pod_test.go @@ -0,0 +1,59 @@ +package schema + +import ( + "testing" + + "github.com/coreos/rocket/Godeps/_workspace/src/github.com/appc/spec/schema/types" +) + +func TestPodManifestMerge(t *testing.T) { + pmj := `{}` + pm := &PodManifest{} + + if pm.UnmarshalJSON([]byte(pmj)) == nil { + t.Fatal("Manifest JSON without acKind and acVersion unmarshalled successfully") + } + + pm = BlankPodManifest() + + err := pm.UnmarshalJSON([]byte(pmj)) + if err != nil { + t.Errorf("unexpected error: %v", err) + } +} + +func TestAppList(t *testing.T) { + ri := RuntimeImage{ + ID: *types.NewHashSHA512([]byte{}), + } + al := AppList{ + RuntimeApp{ + Name: "foo", + Image: ri, + }, + RuntimeApp{ + Name: "bar", + Image: ri, + }, + } + if _, err := al.MarshalJSON(); err != nil { + t.Errorf("want err=nil, got %v", err) + } + dal := AppList{ + RuntimeApp{ + Name: "foo", + Image: ri, + }, + RuntimeApp{ + Name: "bar", + Image: ri, + }, + RuntimeApp{ + Name: "foo", + Image: ri, + }, + } + if _, err := dal.MarshalJSON(); err == nil { + t.Errorf("want err, got nil") + } +} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind.go index 29a529a..0be7c75 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind.go @@ -21,7 +21,7 @@ func (a ACKind) String() string { func (a ACKind) assertValid() error { s := a.String() switch s { - case "ImageManifest", "ContainerRuntimeManifest": + case "ImageManifest", "PodManifest": return nil case "": return ErrNoACKind diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind_test.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind_test.go index 7fcbec5..9adb4c4 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind_test.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind_test.go @@ -31,7 +31,7 @@ func TestACKindMarshalBad(t *testing.T) { func TestACKindMarshalGood(t *testing.T) { for i, in := range []string{ "ImageManifest", - "ContainerRuntimeManifest", + "PodManifest", } { a := ACKind(in) b, err := json.Marshal(a) @@ -64,8 +64,8 @@ func TestACKindUnmarshalBad(t *testing.T) { func TestACKindUnmarshalGood(t *testing.T) { tests := map[string]ACKind{ - `"ContainerRuntimeManifest"`: ACKind("ContainerRuntimeManifest"), - `"ImageManifest"`: ACKind("ImageManifest"), + `"PodManifest"`: ACKind("PodManifest"), + `"ImageManifest"`: ACKind("ImageManifest"), } for in, w := range tests { var a ACKind diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/app.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/app.go index 733a922..e799322 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/app.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/app.go @@ -16,7 +16,7 @@ type App struct { Environment Environment `json:"environment,omitempty"` MountPoints []MountPoint `json:"mountPoints,omitempty"` Ports []Port `json:"ports,omitempty"` - Isolators []Isolator `json:"isolators,omitempty"` + Isolators Isolators `json:"isolators,omitempty"` } // app is a model to facilitate extra validation during the diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/port.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/port.go index 37e739b..bfc06f8 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/port.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/port.go @@ -6,3 +6,8 @@ type Port struct { Port uint `json:"port"` SocketActivated bool `json:"socketActivated"` } + +type ExposedPort struct { + Name ACName `json:"name"` + HostPort uint `json:"hostPort"` +} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume.go index 8b57c78..a3c92d6 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume.go @@ -11,7 +11,7 @@ import ( ) // Volume encapsulates a volume which should be mounted into the filesystem -// of all apps in a ContainerRuntimeManifest +// of all apps in a PodManifest type Volume struct { Name ACName `json:"name"` Kind string `json:"kind"` @@ -19,7 +19,7 @@ type Volume struct { // currently used only by "host" // TODO(jonboulle): factor out? Source string `json:"source,omitempty"` - ReadOnly bool `json:"readOnly,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` } type volume Volume @@ -69,7 +69,7 @@ func (v Volume) MarshalJSON() ([]byte, error) { } func (v Volume) String() string { - s := fmt.Sprintf("%s,kind=%s,readOnly=%t", v.Name, v.Kind, v.ReadOnly) + s := fmt.Sprintf("%s,kind=%s,readOnly=%t", v.Name, v.Kind, *v.ReadOnly) if v.Source != "" { s = s + fmt.Sprintf("source=%s", v.Source) } @@ -110,7 +110,7 @@ func VolumeFromString(vp string) (*Volume, error) { if err != nil { return nil, err } - vol.ReadOnly = ro + vol.ReadOnly = &ro default: return nil, fmt.Errorf("unknown volume parameter %q", key) } diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume_test.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume_test.go index 94a0449..d9674b5 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume_test.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume_test.go @@ -6,6 +6,8 @@ import ( ) func TestVolumeFromString(t *testing.T) { + trueVar := true + falseVar := false tests := []struct { s string v Volume @@ -16,7 +18,16 @@ func TestVolumeFromString(t *testing.T) { Name: "foobar", Kind: "host", Source: "/tmp", - ReadOnly: false, + ReadOnly: nil, + }, + }, + { + "foobar,kind=host,source=/tmp,readOnly=false", + Volume{ + Name: "foobar", + Kind: "host", + Source: "/tmp", + ReadOnly: &falseVar, }, }, { @@ -25,14 +36,15 @@ func TestVolumeFromString(t *testing.T) { Name: "foobar", Kind: "host", Source: "/tmp", - ReadOnly: true, + ReadOnly: &trueVar, }, }, { "foobar,kind=empty", Volume{ - Name: "foobar", - Kind: "empty", + Name: "foobar", + Kind: "empty", + ReadOnly: nil, }, }, { @@ -40,7 +52,7 @@ func TestVolumeFromString(t *testing.T) { Volume{ Name: "foobar", Kind: "empty", - ReadOnly: true, + ReadOnly: &trueVar, }, }, } diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go index b9dfed8..4260595 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go @@ -8,7 +8,7 @@ const ( // version represents the canonical version of the appc spec and tooling. // For now, the schema and tooling is coupled with the spec itself, so // this must be kept in sync with the VERSION file in the root of the repo. - version string = "0.4.0+git" + version string = "0.5.0" ) var ( diff --git a/common/common.go b/common/common.go index 76803ba..d84951d 100644 --- a/common/common.go +++ b/common/common.go @@ -54,8 +54,8 @@ func Stage1ManifestPath(root string) string { return filepath.Join(Stage1ImagePath(root), aci.ManifestFile) } -// ContainerManifestPath returns the path in root to the Container Runtime Manifest -func ContainerManifestPath(root string) string { +// PodManifestPath returns the path in root to the Pod Manifest +func PodManifestPath(root string) string { return filepath.Join(root, "container") } diff --git a/rkt/containers.go b/rkt/containers.go index 7c23642..5ebff7c 100644 --- a/rkt/containers.go +++ b/rkt/containers.go @@ -43,14 +43,14 @@ type container struct { nets []netinfo.NetInfo // list of networks (name, IP, iface) this container is using isEmbryo bool // directory starts as embryo before entering preparing state, serves as stage for acquiring lock before rename to prepare/. - isPreparing bool // when locked at containers/prepare/$uuid the container is actively being prepared - isAbortedPrepare bool // when unlocked at containers/prepare/$uuid the container never finished preparing - isPrepared bool // when at containers/prepared/$uuid the container is prepared, serves as stage for acquiring lock before rename to run/. - isExited bool // when locked at containers/run/$uuid the container is running, when unlocked it's exited. - isExitedGarbage bool // when unlocked at containers/exited-garbage/$uuid the container is exited and is garbage - isExitedDeleting bool // when locked at containers/exited-garbage/$uuid the container is exited, garbage, and is being actively deleted - isGarbage bool // when unlocked at containers/garbage/$uuid the container is garbage that never ran - isDeleting bool // when locked at containers/garbage/$uuid the container is garbage that never ran, and is being actively deleted + isPreparing bool // when locked at pods/prepare/$uuid the container is actively being prepared + isAbortedPrepare bool // when unlocked at pods/prepare/$uuid the container never finished preparing + isPrepared bool // when at pods/prepared/$uuid the container is prepared, serves as stage for acquiring lock before rename to run/. + isExited bool // when locked at pods/run/$uuid the container is running, when unlocked it's exited. + isExitedGarbage bool // when unlocked at pods/exited-garbage/$uuid the container is exited and is garbage + isExitedDeleting bool // when locked at pods/exited-garbage/$uuid the container is exited, garbage, and is being actively deleted + isGarbage bool // when unlocked at pods/garbage/$uuid the container is garbage that never ran + isDeleting bool // when locked at pods/garbage/$uuid the container is garbage that never ran, and is being actively deleted isGone bool // when a container no longer can be located at its uuid anywhere XXX: only set by refreshState() } @@ -162,7 +162,7 @@ func newContainer() (*container, error) { } // At this point we we have: - // /var/lib/rkt/containers/prepare/$uuid << exclusively locked to indicate "preparing" + // /var/lib/rkt/pods/prepare/$uuid << exclusively locked to indicate "preparing" return c, nil } @@ -695,17 +695,17 @@ func (c *container) getStage1Hash() (*types.Hash, error) { // getAppsHashes returns a list of the app hashes in the container func (c *container) getAppsHashes() ([]types.Hash, error) { - crmb, err := c.readFile("container") + pmb, err := c.readFile("pod") if err != nil { return nil, err } - var crm *schema.ContainerRuntimeManifest - if err = json.Unmarshal(crmb, &crm); err != nil { + var pm *schema.PodManifest + if err = json.Unmarshal(pmb, &pm); err != nil { return nil, err } var imgs []types.Hash - for _, app := range crm.Apps { + for _, app := range pm.Apps { imgs = append(imgs, app.Image.ID) } @@ -734,12 +734,12 @@ func (c *container) getAppCount() (int, error) { return -1, fmt.Errorf("error: only prepared containers can get their app count") } - b, err := ioutil.ReadFile(common.ContainerManifestPath(c.path())) + b, err := ioutil.ReadFile(common.PodManifestPath(c.path())) if err != nil { return -1, fmt.Errorf("error reading container manifest: %v", err) } - m := schema.ContainerRuntimeManifest{} + m := schema.PodManifest{} if err = m.UnmarshalJSON(b); err != nil { return -1, fmt.Errorf("unable to load manifest: %v", err) } diff --git a/rkt/enter.go b/rkt/enter.go index 053a8ea..24c78c4 100644 --- a/rkt/enter.go +++ b/rkt/enter.go @@ -111,20 +111,20 @@ func runEnter(args []string) (exit int) { // getAppImageID returns the image id to enter // If one was supplied in the flags then it's simply returned -// If the CRM contains a single image, that image's id is returned -// If the CRM has multiple images, the ids and names are printed and an error is returned +// If the PM contains a single image, that image's id is returned +// If the PM has multiple images, the ids and names are printed and an error is returned func getAppImageID(c *container) (*types.Hash, error) { if !flagAppImageID.Empty() { return &flagAppImageID, nil } // figure out the image id, or show a list if multiple are present - b, err := ioutil.ReadFile(common.ContainerManifestPath(c.path())) + b, err := ioutil.ReadFile(common.PodManifestPath(c.path())) if err != nil { return nil, fmt.Errorf("error reading container manifest: %v", err) } - m := schema.ContainerRuntimeManifest{} + m := schema.PodManifest{} if err = m.UnmarshalJSON(b); err != nil { return nil, fmt.Errorf("unable to load manifest: %v", err) } diff --git a/rkt/list.go b/rkt/list.go index 1576431..f4f87c1 100644 --- a/rkt/list.go +++ b/rkt/list.go @@ -48,12 +48,12 @@ func runList(args []string) (exit int) { } if err := walkContainers(includeMostDirs, func(c *container) { - m := schema.ContainerRuntimeManifest{} + m := schema.PodManifest{} app_zero := "" if !c.isPreparing && !c.isAbortedPrepare && !c.isExitedDeleting { // TODO(vc): we should really hold a shared lock here to prevent gc of the container - manifFile, err := c.readFile(common.ContainerManifestPath("")) + manifFile, err := c.readFile(common.PodManifestPath("")) if err != nil { stderr("Unable to read manifest: %v", err) return diff --git a/rkt/metadata_service.go b/rkt/metadata_service.go index 25ebeda..b68df72 100644 --- a/rkt/metadata_service.go +++ b/rkt/metadata_service.go @@ -46,7 +46,7 @@ var ( ) type mdsContainer struct { - manifest schema.ContainerRuntimeManifest + manifest schema.PodManifest apps map[string]*schema.ImageManifest ip string } @@ -253,7 +253,7 @@ func handleContainerAnnotation(w http.ResponseWriter, r *http.Request, c *mdsCon w.Write([]byte(v)) } -func handleContainerManifest(w http.ResponseWriter, r *http.Request, c *mdsContainer) { +func handlePodManifest(w http.ResponseWriter, r *http.Request, c *mdsContainer) { defer r.Body.Close() w.Header().Add("Content-Type", "application/json") @@ -274,7 +274,7 @@ func handleContainerUID(w http.ResponseWriter, r *http.Request, c *mdsContainer) w.Write([]byte(uid)) } -func mergeAppAnnotations(im *schema.ImageManifest, cm *schema.ContainerRuntimeManifest) types.Annotations { +func mergeAppAnnotations(im *schema.ImageManifest, cm *schema.PodManifest) types.Annotations { merged := types.Annotations{} for _, annot := range im.Annotations { @@ -449,9 +449,9 @@ func logReq(h func(w http.ResponseWriter, r *http.Request)) http.HandlerFunc { func makeHandlers() http.Handler { r := mux.NewRouter() - r.HandleFunc("/containers/", logReq(handleRegisterContainer)).Methods("POST") - r.HandleFunc("/containers/{uid}", logReq(handleUnregisterContainer)).Methods("DELETE") - r.HandleFunc("/containers/{uid}/{app:.*}", logReq(handleRegisterApp)).Methods("PUT") + r.HandleFunc("/pods/", logReq(handleRegisterContainer)).Methods("POST") + r.HandleFunc("/pods/{uid}", logReq(handleUnregisterContainer)).Methods("DELETE") + r.HandleFunc("/pods/{uid}/{app:.*}", logReq(handleRegisterApp)).Methods("PUT") acRtr := r.Headers("Metadata-Flavor", "AppContainer"). PathPrefix("/acMetadata/v1").Subrouter() @@ -460,7 +460,7 @@ func makeHandlers() http.Handler { mr.HandleFunc("/container/annotations/", logReq(containerGet(handleContainerAnnotations))) mr.HandleFunc("/container/annotations/{name}", logReq(containerGet(handleContainerAnnotation))) - mr.HandleFunc("/container/manifest", logReq(containerGet(handleContainerManifest))) + mr.HandleFunc("/container/manifest", logReq(containerGet(handlePodManifest))) mr.HandleFunc("/container/uid", logReq(containerGet(handleContainerUID))) mr.HandleFunc("/apps/{app:.*}/annotations/", logReq(appGet(handleAppAnnotations))) diff --git a/stage0/run.go b/stage0/run.go index 8fca8e6..3d59819 100644 --- a/stage0/run.go +++ b/stage0/run.go @@ -64,19 +64,19 @@ type PrepareConfig struct { // configuration parameters needed by Run type RunConfig struct { CommonConfig - PrivateNet bool // container should have its own network stack + PrivateNet bool // pod should have its own network stack SpawnMetadataService bool // launch metadata service LockFd int // lock file descriptor - Interactive bool // whether the container is interactive or not + Interactive bool // whether the pod is interactive or not } // configuration shared by both Run and Prepare type CommonConfig struct { - Store *cas.Store // store containing all of the configured application images - Stage1Image types.Hash // stage1 image containing usable /init and /enter entrypoints - Images []types.Hash // application images - ContainersDir string // root directory for rocket containers - Debug bool + Store *cas.Store // store containing all of the configured application images + Stage1Image types.Hash // stage1 image containing usable /init and /enter entrypoints + Images []types.Hash // application images + PodsDir string // root directory for rocket pods + Debug bool } func init() { @@ -106,7 +106,7 @@ func MergeEnvs(appEnv *types.Environment, inheritEnv bool, setEnv []string) { } } -// Prepare sets up a container based on the given config. +// Prepare sets up a pod based on the given config. func Prepare(cfg PrepareConfig, dir string, uuid *types.UUID) error { if cfg.Debug { log.SetOutput(os.Stderr) @@ -119,9 +119,8 @@ func Prepare(cfg PrepareConfig, dir string, uuid *types.UUID) error { return fmt.Errorf("error preparing stage1: %v", err) } - cm := schema.ContainerRuntimeManifest{ - ACKind: "ContainerRuntimeManifest", - UUID: *uuid, // TODO(vc): later appc spec omits uuid from the crm, this is a temp hack. + cm := schema.PodManifest{ + ACKind: "PodManifest", Apps: make(schema.AppList, 0), } @@ -146,7 +145,7 @@ func Prepare(cfg PrepareConfig, dir string, uuid *types.UUID) error { // TODO(vc): leverage RuntimeApp.Name for disambiguating the apps Name: am.Name, Image: schema.RuntimeImage{ - Name: am.Name, + Name: &am.Name, ID: img, }, Annotations: am.Annotations, @@ -172,13 +171,13 @@ func Prepare(cfg PrepareConfig, dir string, uuid *types.UUID) error { cdoc, err := json.Marshal(cm) if err != nil { - return fmt.Errorf("error marshalling container manifest: %v", err) + return fmt.Errorf("error marshalling pod manifest: %v", err) } - log.Printf("Writing container manifest") - fn := common.ContainerManifestPath(dir) + log.Printf("Writing pod manifest") + fn := common.PodManifestPath(dir) if err := ioutil.WriteFile(fn, cdoc, 0700); err != nil { - return fmt.Errorf("error writing container manifest: %v", err) + return fmt.Errorf("error writing pod manifest: %v", err) } fn = path.Join(dir, common.Stage1IDFilename) @@ -187,7 +186,7 @@ func Prepare(cfg PrepareConfig, dir string, uuid *types.UUID) error { } if useOverlay { - // mark the container as prepared with overlay + // mark the pod as prepared with overlay f, err := os.Create(filepath.Join(dir, overlayFilename)) if err != nil { return fmt.Errorf("error writing overlay marker file: %v", err) @@ -227,14 +226,14 @@ func preparedWithOverlay(dir string) (bool, error) { } if !supportsOverlay() { - return false, fmt.Errorf("the container was prepared with overlay but overlay is not supported") + return false, fmt.Errorf("the pod was prepared with overlay but overlay is not supported") } return true, nil } // Run mounts the right overlay filesystems and actually runs the prepared -// container by exec()ing the stage1 init inside the container filesystem. +// pod by exec()ing the stage1 init inside the pod filesystem. func Run(cfg RunConfig, dir string) { useOverlay, err := preparedWithOverlay(dir) if err != nil { @@ -243,7 +242,7 @@ func Run(cfg RunConfig, dir string) { if useOverlay { // create a separate mount namespace so the overlay mounts are - // unmounted when exiting the container + // unmounted when exiting the pod if err := syscall.Unshare(syscall.CLONE_NEWNS); err != nil { log.Fatalf("error unsharing: %v", err) } @@ -434,7 +433,7 @@ func overlayRender(cfg RunConfig, img types.Hash, cdir string, dest string) erro log.Printf("Writing image manifest") if err := ioutil.WriteFile(filepath.Join(dest, "manifest"), mb, 0700); err != nil { - return fmt.Errorf("error writing container manifest: %v", err) + return fmt.Errorf("error writing pod manifest: %v", err) } destRootfs := path.Join(dest, "rootfs") diff --git a/stage1/init/container.go b/stage1/init/container.go index 901b425..31aa8ae 100644 --- a/stage1/init/container.go +++ b/stage1/init/container.go @@ -33,16 +33,16 @@ import ( "github.com/coreos/rocket/common" ) -// Container encapsulates a ContainerRuntimeManifest and ImageManifests +// Container encapsulates a PodManifest and ImageManifests type Container struct { Root string // root directory where the container will be located - Manifest *schema.ContainerRuntimeManifest + Manifest *schema.PodManifest Apps map[string]*schema.ImageManifest MetadataServiceURL string Networks []string } -// LoadContainer loads a Container Runtime Manifest (as prepared by stage0) and +// LoadContainer loads a Pod Manifest (as prepared by stage0) and // its associated Application Manifests, under $root/stage1/opt/stage1/$apphash func LoadContainer(root string) (*Container, error) { c := &Container{ @@ -50,14 +50,14 @@ func LoadContainer(root string) (*Container, error) { Apps: make(map[string]*schema.ImageManifest), } - buf, err := ioutil.ReadFile(common.ContainerManifestPath(c.Root)) + buf, err := ioutil.ReadFile(common.PodManifestPath(c.Root)) if err != nil { - return nil, fmt.Errorf("failed reading container runtime manifest: %v", err) + return nil, fmt.Errorf("failed reading pod manifest: %v", err) } - cm := &schema.ContainerRuntimeManifest{} + cm := &schema.PodManifest{} if err := json.Unmarshal(buf, cm); err != nil { - return nil, fmt.Errorf("failed unmarshalling container runtime manifest: %v", err) + return nil, fmt.Errorf("failed unmarshalling pod manifest: %v", err) } c.Manifest = cm diff --git a/stage1/init/registration.go b/stage1/init/registration.go index e44b162..6d37e84 100644 --- a/stage1/init/registration.go +++ b/stage1/init/registration.go @@ -26,13 +26,13 @@ import ( ) func registerContainer(c *Container, ip net.IP) error { - cmf, err := os.Open(common.ContainerManifestPath(c.Root)) + cmf, err := os.Open(common.PodManifestPath(c.Root)) if err != nil { return fmt.Errorf("failed opening runtime manifest: %v", err) } defer cmf.Close() - pth := fmt.Sprintf("/containers/?ip=%v", ip.To4().String()) + pth := fmt.Sprintf("/pods/?ip=%v", ip.To4().String()) if err := httpRequest("POST", pth, cmf); err != nil { return fmt.Errorf("failed to register container with metadata svc: %v", err) }