소스 검색

Windows: support docker diff

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 8 년 전
부모
커밋
4fac603682
2개의 변경된 파일10개의 추가작업 그리고 5개의 파일을 삭제
  1. 6 0
      daemon/changes.go
  2. 4 5
      daemon/graphdriver/windows/windows.go

+ 6 - 0
daemon/changes.go

@@ -1,6 +1,8 @@
 package daemon
 
 import (
+	"errors"
+	"runtime"
 	"time"
 
 	"github.com/docker/docker/pkg/archive"
@@ -14,6 +16,10 @@ func (daemon *Daemon) ContainerChanges(name string) ([]archive.Change, error) {
 		return nil, err
 	}
 
+	if runtime.GOOS == "windows" && container.IsRunning() {
+		return nil, errors.New("Windows does not support diff of a running container")
+	}
+
 	container.Lock()
 	defer container.Unlock()
 	c, err := container.RWLayer.Changes()

+ 4 - 5
daemon/graphdriver/windows/windows.go

@@ -366,7 +366,7 @@ func (d *Driver) Diff(id, parent string) (_ io.ReadCloser, err error) {
 
 // Changes produces a list of changes between the specified layer
 // and its parent layer. If parent is "", then all changes will be ADD changes.
-// The layer should be mounted when calling this function
+// The layer should not be mounted when calling this function.
 func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
 	rID, err := d.resolveID(id)
 	if err != nil {
@@ -377,13 +377,12 @@ func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
 		return nil, err
 	}
 
-	// this is assuming that the layer is unmounted
-	if err := hcsshim.UnprepareLayer(d.info, rID); err != nil {
+	if err := hcsshim.ActivateLayer(d.info, rID); err != nil {
 		return nil, err
 	}
 	defer func() {
-		if err := hcsshim.PrepareLayer(d.info, rID, parentChain); err != nil {
-			logrus.Warnf("Failed to Deactivate %s: %s", rID, err)
+		if err2 := hcsshim.DeactivateLayer(d.info, rID); err2 != nil {
+			logrus.Errorf("changes() failed to DeactivateLayer %s %s: %s", id, rID, err2)
 		}
 	}()