diff --git a/daemon/monitor.go b/daemon/monitor.go index b88dff68909b66b7869940e333076f5e60753a2b..aec771fd17767b306bf659d62b5bbb789d4437b2 100644 --- a/daemon/monitor.go +++ b/daemon/monitor.go @@ -90,6 +90,7 @@ func (daemon *Daemon) StateChanged(id string, e libcontainerd.StateInfo) error { // Container is already locked in this case c.SetRunning(int(e.Pid), e.State == libcontainerd.StateStart) c.HasBeenManuallyStopped = false + c.HasBeenStartedBefore = true if err := c.ToDisk(); err != nil { c.Reset(false) return err diff --git a/daemon/oci_windows.go b/daemon/oci_windows.go index cb01cb26022738f3587d577efae342e128ca6125..d304220335d22b4e34b4be0e3c7eef8466d9b6e0 100644 --- a/daemon/oci_windows.go +++ b/daemon/oci_windows.go @@ -78,9 +78,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e s.Root.Path = c.BaseFS s.Root.Readonly = c.HostConfig.ReadonlyRootfs - // In s.Windows - s.Windows.FirstStart = !c.HasBeenStartedBefore - // s.Windows.LayerFolder. m, err := c.RWLayer.Metadata() if err != nil { diff --git a/daemon/start_windows.go b/daemon/start_windows.go index af3fe7602bc4b2141acb873e4e7706c9e7a94d4c..7804a877ff17237a6305a5c2e1f05d2859b1af4c 100644 --- a/daemon/start_windows.go +++ b/daemon/start_windows.go @@ -6,5 +6,7 @@ import ( ) 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 } diff --git a/libcontainerd/client_windows.go b/libcontainerd/client_windows.go index b164ca507b339ac6724f596d01f65c85f1e47bd9..9c750b39f9f83e8df85c76429623799e1143462f 100644 --- a/libcontainerd/client_windows.go +++ b/libcontainerd/client_windows.go @@ -41,12 +41,11 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir logrus.Debugln("libcontainerd: client.Create() with spec", spec) configuration := &hcsshim.ContainerConfig{ - SystemType: "Container", - Name: containerID, - Owner: defaultOwner, - + SystemType: "Container", + Name: containerID, + Owner: defaultOwner, VolumePath: spec.Root.Path, - IgnoreFlushesDuringBoot: spec.Windows.FirstStart, + IgnoreFlushesDuringBoot: false, LayerFolderPath: spec.Windows.LayerFolder, HostName: spec.Hostname, } @@ -106,6 +105,10 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir configuration.Servicing = s.IsServicing break } + if s, ok := option.(*FlushOption); ok { + configuration.IgnoreFlushesDuringBoot = s.IgnoreFlushesDuringBoot + break + } } for _, layerPath := range spec.Windows.LayerPaths { diff --git a/libcontainerd/types_windows.go b/libcontainerd/types_windows.go index fa96f0ed8db50093e7eebfc301bde51d9b9b43e9..5f3223316b19001c7297e43d8febf4144c5e271a 100644 --- a/libcontainerd/types_windows.go +++ b/libcontainerd/types_windows.go @@ -38,6 +38,13 @@ type ServicingOption struct { 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) type Checkpoint struct { Name string diff --git a/libcontainerd/utils_windows.go b/libcontainerd/utils_windows.go index 70e77bb81215f6ab5eed93d3e6d0436e5ddcfaad..fcd72145c64f5af052d483931a880f285deb3a9f 100644 --- a/libcontainerd/utils_windows.go +++ b/libcontainerd/utils_windows.go @@ -23,6 +23,11 @@ func (s *ServicingOption) Apply(interface{}) error { 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 // number. It returns 0 if the build number is not present. func buildFromVersion(osver string) int { diff --git a/libcontainerd/windowsoci/oci_windows.go b/libcontainerd/windowsoci/oci_windows.go index 63d5abdfb081d90e27ec90cf7f35bc92e5b96e1c..d6de7423b5a3c5ce826b48d287a3d11ea3a13072 100644 --- a/libcontainerd/windowsoci/oci_windows.go +++ b/libcontainerd/windowsoci/oci_windows.go @@ -39,8 +39,6 @@ type Windows struct { Resources *Resources `json:"resources,omitempty"` // Networking contains the platform specific network settings for the container. 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 string `json:"layer_folder,omitempty"` // Layer paths of the parent layers