| ... | ... |
@@ -52,7 +52,9 @@ func (graph *Graph) restore() error {
|
| 52 | 52 |
} |
| 53 | 53 |
for _, v := range dir {
|
| 54 | 54 |
id := v.Name() |
| 55 |
- graph.idIndex.Add(id) |
|
| 55 |
+ if graph.driver.Exists(id) {
|
|
| 56 |
+ graph.idIndex.Add(id) |
|
| 57 |
+ } |
|
| 56 | 58 |
} |
| 57 | 59 |
return nil |
| 58 | 60 |
} |
| ... | ... |
@@ -137,6 +139,14 @@ func (graph *Graph) Register(jsonData []byte, layerData archive.Archive, img *Im |
| 137 | 137 |
if graph.Exists(img.ID) {
|
| 138 | 138 |
return fmt.Errorf("Image %s already exists", img.ID)
|
| 139 | 139 |
} |
| 140 |
+ |
|
| 141 |
+ // Ensure that the image root does not exist on the filesystem |
|
| 142 |
+ // when it is not registered in the graph. |
|
| 143 |
+ // This is common when you switch from one graph driver to another |
|
| 144 |
+ if err := os.RemoveAll(graph.imageRoot(img.ID)); err != nil && !os.IsNotExist(err) {
|
|
| 145 |
+ return err |
|
| 146 |
+ } |
|
| 147 |
+ |
|
| 140 | 148 |
tmp, err := graph.Mktemp("")
|
| 141 | 149 |
defer os.RemoveAll(tmp) |
| 142 | 150 |
if err != nil {
|
| ... | ... |
@@ -38,6 +38,9 @@ func pathExists(pth string) bool {
|
| 38 | 38 |
// symlink. |
| 39 | 39 |
func (a *Driver) Migrate(pth string, setupInit func(p string) error) error {
|
| 40 | 40 |
if pathExists(path.Join(pth, "graph")) {
|
| 41 |
+ if err := a.migrateRepositories(pth); err != nil {
|
|
| 42 |
+ return err |
|
| 43 |
+ } |
|
| 41 | 44 |
if err := a.migrateImages(path.Join(pth, "graph")); err != nil {
|
| 42 | 45 |
return err |
| 43 | 46 |
} |
| ... | ... |
@@ -46,6 +49,14 @@ func (a *Driver) Migrate(pth string, setupInit func(p string) error) error {
|
| 46 | 46 |
return nil |
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 |
+func (a *Driver) migrateRepositories(pth string) error {
|
|
| 50 |
+ name := path.Join(pth, "repositories") |
|
| 51 |
+ if err := os.Rename(name, name+"-aufs"); err != nil && !os.IsNotExist(err) {
|
|
| 52 |
+ return err |
|
| 53 |
+ } |
|
| 54 |
+ return nil |
|
| 55 |
+} |
|
| 56 |
+ |
|
| 49 | 57 |
func (a *Driver) migrateContainers(pth string, setupInit func(p string) error) error {
|
| 50 | 58 |
fis, err := ioutil.ReadDir(pth) |
| 51 | 59 |
if err != nil {
|
| ... | ... |
@@ -671,7 +671,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
|
| 671 | 671 |
if err != nil {
|
| 672 | 672 |
return nil, err |
| 673 | 673 |
} |
| 674 |
- repositories, err := NewTagStore(path.Join(config.Root, "repositories"), g) |
|
| 674 |
+ repositories, err := NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), g) |
|
| 675 | 675 |
if err != nil {
|
| 676 | 676 |
return nil, fmt.Errorf("Couldn't create Tag store: %s", err)
|
| 677 | 677 |
} |