mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #24427 from swernli/remove_custom_images
Removing Custom Images support
This commit is contained in:
commit
b215c4c974
4 changed files with 0 additions and 173 deletions
|
@ -545,10 +545,6 @@ func NewDaemon(config *Config, registryService registry.Service, containerdRemot
|
|||
return nil, fmt.Errorf("Couldn't create Tag store repositories: %s", err)
|
||||
}
|
||||
|
||||
if err := restoreCustomImage(d.imageStore, d.layerStore, referenceStore); err != nil {
|
||||
return nil, fmt.Errorf("Couldn't restore custom images: %s", err)
|
||||
}
|
||||
|
||||
migrationStart := time.Now()
|
||||
if err := v1.Migrate(config.Root, graphDriver, d.layerStore, d.imageStore, referenceStore, distributionMetadataStore); err != nil {
|
||||
logrus.Errorf("Graph migration failed: %q. Your old graph data was found to be too inconsistent for upgrading to content-addressable storage. Some of the old data was probably not upgraded. We recommend starting over with a clean storage directory if possible.", err)
|
||||
|
|
|
@ -19,12 +19,10 @@ import (
|
|||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/layer"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/parsers"
|
||||
"github.com/docker/docker/pkg/parsers/kernel"
|
||||
"github.com/docker/docker/pkg/sysinfo"
|
||||
"github.com/docker/docker/reference"
|
||||
"github.com/docker/docker/runconfig"
|
||||
runconfigopts "github.com/docker/docker/runconfig/opts"
|
||||
"github.com/docker/engine-api/types"
|
||||
|
@ -1068,11 +1066,6 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container
|
|||
return daemon.Unmount(container)
|
||||
}
|
||||
|
||||
func restoreCustomImage(is image.Store, ls layer.Store, rs reference.Store) error {
|
||||
// Unix has no custom images to register
|
||||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
||||
if !c.IsRunning() {
|
||||
return nil, errNotRunning{c.ID}
|
||||
|
|
|
@ -1,27 +1,18 @@
|
|||
package daemon
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/Microsoft/hcsshim"
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/daemon/graphdriver"
|
||||
"github.com/docker/docker/daemon/graphdriver/windows" // register the windows graph driver
|
||||
"github.com/docker/docker/dockerversion"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/layer"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/parsers"
|
||||
"github.com/docker/docker/pkg/sysinfo"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/docker/reference"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/docker/engine-api/types"
|
||||
pblkiodev "github.com/docker/engine-api/types/blkiodev"
|
||||
|
@ -383,85 +374,6 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container
|
|||
return nil
|
||||
}
|
||||
|
||||
func restoreCustomImage(is image.Store, ls layer.Store, rs reference.Store) error {
|
||||
type graphDriverStore interface {
|
||||
GraphDriver() graphdriver.Driver
|
||||
}
|
||||
|
||||
gds, ok := ls.(graphDriverStore)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
driver := gds.GraphDriver()
|
||||
wd, ok := driver.(*windows.Driver)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
imageInfos, err := wd.GetCustomImageInfos()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Convert imageData to valid image configuration
|
||||
for _, info := range imageInfos {
|
||||
name := strings.ToLower(info.Name)
|
||||
|
||||
type registrar interface {
|
||||
RegisterDiffID(graphID string, size int64) (layer.Layer, error)
|
||||
}
|
||||
r, ok := ls.(registrar)
|
||||
if !ok {
|
||||
return errors.New("Layerstore doesn't support RegisterDiffID")
|
||||
}
|
||||
if _, err := r.RegisterDiffID(info.ID, info.Size); err != nil {
|
||||
return err
|
||||
}
|
||||
// layer is intentionally not released
|
||||
|
||||
rootFS := image.NewRootFSWithBaseLayer(filepath.Base(info.Path))
|
||||
|
||||
// Create history for base layer
|
||||
config, err := json.Marshal(&image.Image{
|
||||
V1Image: image.V1Image{
|
||||
DockerVersion: dockerversion.Version,
|
||||
Architecture: runtime.GOARCH,
|
||||
OS: runtime.GOOS,
|
||||
Created: info.CreatedTime,
|
||||
},
|
||||
RootFS: rootFS,
|
||||
History: []image.History{},
|
||||
OSVersion: info.OSVersion,
|
||||
OSFeatures: info.OSFeatures,
|
||||
})
|
||||
|
||||
named, err := reference.ParseNamed(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ref, err := reference.WithTag(named, info.Version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id, err := is.Create(config)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to restore custom image %s with error: %s.", name, err)
|
||||
logrus.Warnf("Skipping image %s...", name)
|
||||
continue
|
||||
}
|
||||
|
||||
if err := rs.AddTag(ref, id, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Debugf("Registered base layer %s as %s", ref, id)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func driverOptions(config *Config) []nwconfig.Option {
|
||||
return []nwconfig.Option{}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ package windows
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"crypto/sha512"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -17,7 +16,6 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
|
@ -448,78 +446,6 @@ func (d *Driver) DiffSize(id, parent string) (size int64, err error) {
|
|||
return archive.ChangesSize(layerFs, changes), nil
|
||||
}
|
||||
|
||||
// CustomImageInfo is the object returned by the driver describing the base
|
||||
// image.
|
||||
type CustomImageInfo struct {
|
||||
ID string
|
||||
Name string
|
||||
Version string
|
||||
Path string
|
||||
Size int64
|
||||
CreatedTime time.Time
|
||||
OSVersion string `json:"-"`
|
||||
OSFeatures []string `json:"-"`
|
||||
}
|
||||
|
||||
// GetCustomImageInfos returns the image infos for window specific
|
||||
// base images which should always be present.
|
||||
func (d *Driver) GetCustomImageInfos() ([]CustomImageInfo, error) {
|
||||
strData, err := hcsshim.GetSharedBaseImages()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to restore base images: %s", err)
|
||||
}
|
||||
|
||||
type customImageInfoList struct {
|
||||
Images []CustomImageInfo
|
||||
}
|
||||
|
||||
var infoData customImageInfoList
|
||||
|
||||
if err = json.Unmarshal([]byte(strData), &infoData); err != nil {
|
||||
err = fmt.Errorf("JSON unmarshal returned error=%s", err)
|
||||
logrus.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var images []CustomImageInfo
|
||||
|
||||
for _, imageData := range infoData.Images {
|
||||
folderName := filepath.Base(imageData.Path)
|
||||
|
||||
// Use crypto hash of the foldername to generate a docker style id.
|
||||
h := sha512.Sum384([]byte(folderName))
|
||||
id := fmt.Sprintf("%x", h[:32])
|
||||
|
||||
if err := d.Create(id, "", "", nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Create the alternate ID file.
|
||||
if err := d.setID(id, folderName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
imageData.ID = id
|
||||
|
||||
// For now, hard code that all base images except nanoserver depend on win32k support
|
||||
if imageData.Name != "NanoServer" {
|
||||
imageData.OSFeatures = append(imageData.OSFeatures, "win32k")
|
||||
}
|
||||
|
||||
versionData := strings.Split(imageData.Version, ".")
|
||||
if len(versionData) != 4 {
|
||||
logrus.Warnf("Could not parse Windows version %s", imageData.Version)
|
||||
} else {
|
||||
// Include just major.minor.build, skip the fourth version field, which does not influence
|
||||
// OS compatibility.
|
||||
imageData.OSVersion = strings.Join(versionData[:3], ".")
|
||||
}
|
||||
|
||||
images = append(images, imageData)
|
||||
}
|
||||
|
||||
return images, nil
|
||||
}
|
||||
|
||||
// GetMetadata returns custom driver information.
|
||||
func (d *Driver) GetMetadata(id string) (map[string]string, error) {
|
||||
m := make(map[string]string)
|
||||
|
|
Loading…
Reference in a new issue