Merge pull request #26650 from Microsoft/jjh/firststart
Windows: OCI remove first start
This commit is contained in:
commit
bc60f5af84
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
|
||||
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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -44,9 +44,8 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
|
|||
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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue