-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RemoveVSMB uses the wrong hostPath for file shares #1974
Conversation
When attaching a file, `foo/bar`, `uvm.AddVSMB` adds the `VSMBShare`to `uvm.vsmbFileShares` as `foo/`, and then also sets `VSMBShare.HostPath` to `foo/`. So, when `(*VSMBShare).Release` calls `uvm.RemoveVSMB`, it uses `foo/` as the `hostPath`, which, it then assumes is a directory share (stored in `uvm.vsmbDirShares`) instead of a file share (stored in `uvm.vsmbFileShares`) since `foo/` is a directory. This then fails since it cannot find the VSMBShare in `uvm.vsmbDirShares`. Fix this by adding a `VSMBShare.isDirShare` field to indicate which `uvm.vsmb*Shares` map it is stored under. Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
st, err := os.Stat(hostPath) | ||
if err != nil { | ||
return err | ||
} | ||
isDir := st.IsDir() | ||
if !isDir { | ||
hostPath = filepath.Dir(hostPath) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to do this if we've already determined that a share is or isn't a directory in AddVSMB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly backwards compat, but also, RemoveVSMB
may be called on the original file name (instead of via Release
), so we still need the logic
Update and un-skip WCOW uVM and container tests (and add WCOW uVM benchmarks), as well as WCOW vSMB and LCOW boto files tests. Add WCOW host process tests, including dedicated tests for setting username, and verifying hostname and volume mounts. Moved: - `lcow_bench_test.go` to `uvm_bench_test.go` - `lcow_container_test.go` to `container_test.go` - `lcow_test.go` to `lcow_uvm_test.go` and `uvm_test.go` Fix bug where removing a direct-mapped vSMB share fails. Run (non-virtualization/uVM) functional tests within CI. Add `util.Context` function to create context that times out before test timeout, to help with timing issues and allow time for cleanup and logging. Make sure container specs are created with the default working directory (`C:\`), similar to how `internal\cmd` works). Rename `cri_util` to `criutil`, since underscores are frowned upon in package names. Relies on PR: microsoft#1974 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Update and un-skip WCOW uVM and container tests (and add WCOW uVM benchmarks), as well as WCOW vSMB and LCOW boto files tests. Add WCOW host process tests, including dedicated tests for setting username, and verifying hostname and volume mounts. Moved: - `lcow_bench_test.go` to `uvm_bench_test.go` - `lcow_container_test.go` to `container_test.go` - `lcow_test.go` to `lcow_uvm_test.go` and `uvm_test.go` Fix bug where removing a direct-mapped vSMB share fails. Run (non-virtualization/uVM) functional tests within CI. Add `util.Context` function to create context that times out before test timeout, to help with timing issues and allow time for cleanup and logging. Make sure container specs are created with the default working directory (`C:\`), similar to how `internal\cmd` works). Rename `cri_util` to `criutil`, since underscores are frowned upon in package names. Relies on PR: microsoft#1974 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Update and un-skip WCOW uVM and container tests (and add WCOW uVM benchmarks), as well as WCOW vSMB and LCOW boto files tests. Add WCOW host process tests, including dedicated tests for setting username, and verifying hostname and volume mounts. Moved: - `lcow_bench_test.go` to `uvm_bench_test.go` - `lcow_container_test.go` to `container_test.go` - `lcow_test.go` to `lcow_uvm_test.go` and `uvm_test.go` Fix bug where removing a direct-mapped vSMB share fails. Run (non-virtualization/uVM) functional tests within CI. Add `util.Context` function to create context that times out before test timeout, to help with timing issues and allow time for cleanup and logging. Make sure container specs are created with the default working directory (`C:\`), similar to how `internal\cmd` works). Rename `cri_util` to `criutil`, since underscores are frowned upon in package names. Relies on PR: microsoft#1974 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Update and un-skip WCOW uVM and container tests (and add WCOW uVM benchmarks), as well as WCOW vSMB and LCOW boto files tests. Add WCOW host process tests, including dedicated tests for setting username, and verifying hostname and volume mounts. Moved: - `lcow_bench_test.go` to `uvm_bench_test.go` - `lcow_container_test.go` to `container_test.go` - `lcow_test.go` to `lcow_uvm_test.go` and `uvm_test.go` Fix bug where removing a direct-mapped vSMB share fails. Run (non-virtualization/uVM) functional tests within CI. Make sure container specs are created with the default working directory (`C:\`), similar to how `internal\cmd` works). Relies on PR: microsoft#1974 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Update and un-skip WCOW uVM and container tests (and add WCOW uVM benchmarks), as well as WCOW vSMB and LCOW boto files tests. Add WCOW host process tests, including dedicated tests for setting username, and verifying hostname and volume mounts. Moved: - `lcow_bench_test.go` to `uvm_bench_test.go` - `lcow_container_test.go` to `container_test.go` - `lcow_test.go` to `lcow_uvm_test.go` and `uvm_test.go` Fix bug where removing a direct-mapped vSMB share fails. Run (non-virtualization/uVM) functional tests within CI. Make sure container specs are created with the default working directory (`C:\`), similar to how `internal\cmd` works). Relies on PR: microsoft#1974 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Update and un-skip WCOW uVM and container tests (and add WCOW uVM benchmarks), as well as WCOW vSMB and LCOW boto files tests. Add WCOW host process tests, including dedicated tests for setting username, and verifying hostname and volume mounts. Moved: - `lcow_bench_test.go` to `uvm_bench_test.go` - `lcow_container_test.go` to `container_test.go` - `lcow_test.go` to `lcow_uvm_test.go` and `uvm_test.go` Fix bug where removing a direct-mapped vSMB share fails. Run (non-virtualization/uVM) functional tests within CI. Make sure container specs are created with the default working directory (`C:\`), similar to how `internal\cmd` works). Relies on PR: microsoft#1974 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Update and un-skip WCOW uVM and container tests (and add WCOW uVM benchmarks), as well as WCOW vSMB and LCOW boto files tests. Add WCOW host process tests, including dedicated tests for setting username, and verifying hostname and volume mounts. Moved: - `lcow_bench_test.go` to `uvm_bench_test.go` - `lcow_container_test.go` to `container_test.go` - `lcow_test.go` to `lcow_uvm_test.go` and `uvm_test.go` Fix bug where removing a direct-mapped vSMB share fails. Run (non-virtualization/uVM) functional tests within CI. Make sure container specs are created with the default working directory (`C:\`), similar to how `internal\cmd` works). Relies on PR: microsoft#1974 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
When attaching a file,
foo/bar
,uvm.AddVSMB
adds theVSMBShare
touvm.vsmbFileShares
asfoo/
, and then also setsVSMBShare.HostPath
tofoo/
.So, when
(*VSMBShare).Release
callsuvm.RemoveVSMB
, it usesfoo/
as thehostPath
, which, it then assumes is a directory share (stored inuvm.vsmbDirShares
) instead of a file share (stored inuvm.vsmbFileShares
) sincefoo/
is a directory. This then fails since it cannot find the VSMBShare inuvm.vsmbDirShares
.Fix this by adding a
VSMBShare.isDirShare
field to indicate whichuvm.vsmb*Shares
map it is stored under.