mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: OCI remove first start
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
efe4e914ef
commit
f7fd408ba7
7 changed files with 24 additions and 11 deletions
|
@ -90,6 +90,7 @@ func (daemon *Daemon) StateChanged(id string, e libcontainerd.StateInfo) error {
|
||||||
// Container is already locked in this case
|
// Container is already locked in this case
|
||||||
c.SetRunning(int(e.Pid), e.State == libcontainerd.StateStart)
|
c.SetRunning(int(e.Pid), e.State == libcontainerd.StateStart)
|
||||||
c.HasBeenManuallyStopped = false
|
c.HasBeenManuallyStopped = false
|
||||||
|
c.HasBeenStartedBefore = true
|
||||||
if err := c.ToDisk(); err != nil {
|
if err := c.ToDisk(); err != nil {
|
||||||
c.Reset(false)
|
c.Reset(false)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -78,9 +78,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
|
||||||
s.Root.Path = c.BaseFS
|
s.Root.Path = c.BaseFS
|
||||||
s.Root.Readonly = c.HostConfig.ReadonlyRootfs
|
s.Root.Readonly = c.HostConfig.ReadonlyRootfs
|
||||||
|
|
||||||
// In s.Windows
|
|
||||||
s.Windows.FirstStart = !c.HasBeenStartedBefore
|
|
||||||
|
|
||||||
// s.Windows.LayerFolder.
|
// s.Windows.LayerFolder.
|
||||||
m, err := c.RWLayer.Metadata()
|
m, err := c.RWLayer.Metadata()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -6,5 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Container) (*[]libcontainerd.CreateOption, error) {
|
func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Container) (*[]libcontainerd.CreateOption, error) {
|
||||||
return &[]libcontainerd.CreateOption{}, nil
|
createOptions := []libcontainerd.CreateOption{}
|
||||||
|
createOptions = append(createOptions, &libcontainerd.FlushOption{IgnoreFlushesDuringBoot: !container.HasBeenStartedBefore})
|
||||||
|
return &createOptions, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,11 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
|
||||||
logrus.Debugln("libcontainerd: client.Create() with spec", spec)
|
logrus.Debugln("libcontainerd: client.Create() with spec", spec)
|
||||||
|
|
||||||
configuration := &hcsshim.ContainerConfig{
|
configuration := &hcsshim.ContainerConfig{
|
||||||
SystemType: "Container",
|
SystemType: "Container",
|
||||||
Name: containerID,
|
Name: containerID,
|
||||||
Owner: defaultOwner,
|
Owner: defaultOwner,
|
||||||
|
|
||||||
VolumePath: spec.Root.Path,
|
VolumePath: spec.Root.Path,
|
||||||
IgnoreFlushesDuringBoot: spec.Windows.FirstStart,
|
IgnoreFlushesDuringBoot: false,
|
||||||
LayerFolderPath: spec.Windows.LayerFolder,
|
LayerFolderPath: spec.Windows.LayerFolder,
|
||||||
HostName: spec.Hostname,
|
HostName: spec.Hostname,
|
||||||
}
|
}
|
||||||
|
@ -106,6 +105,10 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
|
||||||
configuration.Servicing = s.IsServicing
|
configuration.Servicing = s.IsServicing
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if s, ok := option.(*FlushOption); ok {
|
||||||
|
configuration.IgnoreFlushesDuringBoot = s.IgnoreFlushesDuringBoot
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, layerPath := range spec.Windows.LayerPaths {
|
for _, layerPath := range spec.Windows.LayerPaths {
|
||||||
|
|
|
@ -38,6 +38,13 @@ type ServicingOption struct {
|
||||||
IsServicing bool
|
IsServicing bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FlushOption is an empty CreateOption that signifies if the container should be
|
||||||
|
// started with flushes ignored until boot has completed. This is an optimisation
|
||||||
|
// for first boot of a container.
|
||||||
|
type FlushOption struct {
|
||||||
|
IgnoreFlushesDuringBoot bool
|
||||||
|
}
|
||||||
|
|
||||||
// Checkpoint holds the details of a checkpoint (not supported in windows)
|
// Checkpoint holds the details of a checkpoint (not supported in windows)
|
||||||
type Checkpoint struct {
|
type Checkpoint struct {
|
||||||
Name string
|
Name string
|
||||||
|
|
|
@ -23,6 +23,11 @@ func (s *ServicingOption) Apply(interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply for the flush option is a no-op.
|
||||||
|
func (s *FlushOption) Apply(interface{}) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// buildFromVersion takes an image version string and returns the Windows build
|
// buildFromVersion takes an image version string and returns the Windows build
|
||||||
// number. It returns 0 if the build number is not present.
|
// number. It returns 0 if the build number is not present.
|
||||||
func buildFromVersion(osver string) int {
|
func buildFromVersion(osver string) int {
|
||||||
|
|
|
@ -39,8 +39,6 @@ type Windows struct {
|
||||||
Resources *Resources `json:"resources,omitempty"`
|
Resources *Resources `json:"resources,omitempty"`
|
||||||
// Networking contains the platform specific network settings for the container.
|
// Networking contains the platform specific network settings for the container.
|
||||||
Networking *Networking `json:"networking,omitempty"`
|
Networking *Networking `json:"networking,omitempty"`
|
||||||
// FirstStart is used for an optimization on first boot of Windows
|
|
||||||
FirstStart bool `json:"first_start,omitempty"`
|
|
||||||
// LayerFolder is the path to the current layer folder
|
// LayerFolder is the path to the current layer folder
|
||||||
LayerFolder string `json:"layer_folder,omitempty"`
|
LayerFolder string `json:"layer_folder,omitempty"`
|
||||||
// Layer paths of the parent layers
|
// Layer paths of the parent layers
|
||||||
|
|
Loading…
Reference in a new issue