From 9910dd14aa91cada262a9ea94cce796884da7b93 Mon Sep 17 00:00:00 2001 From: Daniel Canter Date: Tue, 24 Nov 2020 14:53:36 -0800 Subject: [PATCH] Remove automanaged vhd functionality Signed-off-by: Daniel Canter --- internal/hcsoci/resources_lcow.go | 6 +----- internal/hcsoci/resources_wcow.go | 6 +----- internal/uvm/automanagedvhd.go | 27 --------------------------- 3 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 internal/uvm/automanagedvhd.go diff --git a/internal/hcsoci/resources_lcow.go b/internal/hcsoci/resources_lcow.go index 8671776b78..8a1efefcb7 100644 --- a/internal/hcsoci/resources_lcow.go +++ b/internal/hcsoci/resources_lcow.go @@ -69,7 +69,6 @@ func allocateLinuxResources(ctx context.Context, coi *createOptionsInternal, r * case "bind": case "physical-disk": case "virtual-disk": - case "automanage-virtual-disk": default: // Unknown mount type continue @@ -103,7 +102,7 @@ func allocateLinuxResources(ctx context.Context, coi *createOptionsInternal, r * uvmPathForShare = scsiMount.UVMPath r.Add(scsiMount) coi.Spec.Mounts[i].Type = "none" - } else if mount.Type == "virtual-disk" || mount.Type == "automanage-virtual-disk" { + } else if mount.Type == "virtual-disk" { l.Debug("hcsshim::allocateLinuxResources Hot-adding SCSI virtual disk for OCI mount") uvmPathForShare = fmt.Sprintf(uvm.LCOWGlobalMountPrefix, coi.HostingSystem.UVMMountCounter()) @@ -116,9 +115,6 @@ func allocateLinuxResources(ctx context.Context, coi *createOptionsInternal, r * uvmPathForFile = scsiMount.UVMPath uvmPathForShare = scsiMount.UVMPath - if mount.Type == "automanage-virtual-disk" { - r.Add(uvm.NewAutoManagedVHD(scsiMount.HostPath)) - } r.Add(scsiMount) coi.Spec.Mounts[i].Type = "none" } else if strings.HasPrefix(mount.Source, "sandbox://") { diff --git a/internal/hcsoci/resources_wcow.go b/internal/hcsoci/resources_wcow.go index ce57448c97..9ace171729 100644 --- a/internal/hcsoci/resources_wcow.go +++ b/internal/hcsoci/resources_wcow.go @@ -71,7 +71,6 @@ func allocateWindowsResources(ctx context.Context, coi *createOptionsInternal, r case "": case "physical-disk": case "virtual-disk": - case "automanage-virtual-disk": default: return fmt.Errorf("invalid OCI spec - Type '%s' not supported", mount.Type) } @@ -94,16 +93,13 @@ func allocateWindowsResources(ctx context.Context, coi *createOptionsInternal, r } coi.Spec.Mounts[i].Type = "" r.Add(scsiMount) - } else if mount.Type == "virtual-disk" || mount.Type == "automanage-virtual-disk" { + } else if mount.Type == "virtual-disk" { l.Debug("hcsshim::allocateWindowsResources Hot-adding SCSI virtual disk for OCI mount") scsiMount, err := coi.HostingSystem.AddSCSI(ctx, mount.Source, uvmPath, readOnly, uvm.VMAccessTypeIndividual) if err != nil { return fmt.Errorf("adding SCSI virtual disk mount %+v: %s", mount, err) } coi.Spec.Mounts[i].Type = "" - if mount.Type == "automanage-virtual-disk" { - r.Add(uvm.NewAutoManagedVHD(scsiMount.HostPath)) - } r.Add(scsiMount) } else { if uvm.IsPipe(mount.Source) { diff --git a/internal/uvm/automanagedvhd.go b/internal/uvm/automanagedvhd.go deleted file mode 100644 index 09ff9296a0..0000000000 --- a/internal/uvm/automanagedvhd.go +++ /dev/null @@ -1,27 +0,0 @@ -package uvm - -import ( - "context" - "os" - - "github.com/Microsoft/hcsshim/internal/log" -) - -// AutoManagedVHD struct representing a VHD that will be cleaned up automatically. -type AutoManagedVHD struct { - hostPath string -} - -func NewAutoManagedVHD(hostPath string) *AutoManagedVHD { - return &AutoManagedVHD{ - hostPath: hostPath, - } -} - -// Release removes the vhd. -func (vhd *AutoManagedVHD) Release(ctx context.Context) error { - if err := os.Remove(vhd.hostPath); err != nil { - log.G(ctx).WithField("hostPath", vhd.hostPath).WithError(err).Error("failed to remove automanage-virtual-disk") - } - return nil -}