Skip to content
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

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

helsaawy
Copy link
Contributor

When attaching a file, foo/bar, uvm.AddVSMB adds the VSMBShareto 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.

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>
@helsaawy helsaawy requested a review from a team as a code owner November 30, 2023 20:25
Comment on lines +241 to +248
st, err := os.Stat(hostPath)
if err != nil {
return err
}
isDir := st.IsDir()
if !isDir {
hostPath = filepath.Dir(hostPath)
}
Copy link
Contributor

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?

Copy link
Contributor Author

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

@helsaawy helsaawy changed the title Remove vSMB uses the wrong hostPath for file shares RemoveVSMB uses the wrong hostPath for file shares Dec 4, 2023
helsaawy added a commit to helsaawy/hcsshim that referenced this pull request Dec 5, 2023
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>
@helsaawy helsaawy merged commit 04f386f into microsoft:main Dec 5, 2023
18 of 19 checks passed
@helsaawy helsaawy deleted the vsmb-remove-bug branch December 5, 2023 21:16
helsaawy added a commit to helsaawy/hcsshim that referenced this pull request Dec 6, 2023
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>
helsaawy added a commit to helsaawy/hcsshim that referenced this pull request Dec 8, 2023
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>
helsaawy added a commit to helsaawy/hcsshim that referenced this pull request Dec 11, 2023
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>
helsaawy added a commit to helsaawy/hcsshim that referenced this pull request Dec 12, 2023
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>
helsaawy added a commit to helsaawy/hcsshim that referenced this pull request Mar 28, 2024
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>
helsaawy added a commit to helsaawy/hcsshim that referenced this pull request Mar 28, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants