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

Use volume-specific depot for Windows runtimes not on the main volume. #3432

Merged
merged 5 commits into from
Aug 6, 2024

Conversation

mitchell-as
Copy link
Contributor

@mitchell-as mitchell-as commented Aug 1, 2024

TaskDX-2943 We support setting up a runtime on the non-windows drive

@mitchell-as mitchell-as requested a review from Naatan August 1, 2024 20:59
@mitchell-as mitchell-as marked this pull request as ready for review August 1, 2024 20:59
Comment on lines 50 to 57
// Windows does not support hard-linking across drives, so determine if the runtime path is on a
// separate drive than the default depot path. If so, use a drive-specific depot path when
// initializing the depot.
runtimeVolume := filepath.VolumeName(path)
storageVolume := filepath.VolumeName(storage.CachePath())
if runtimeVolume == storageVolume {
runtimeVolume = ""
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic can live within depot, no need for runtime to deal with these concerns.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also does this need to be windows specific logic? What does filepath.VolumeName() do on non-windows systems? Probably safer to avoid using this logic outside of windows, even if the APIs are satisfied.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation says that filepath.VolumeName() returns the empty string for non-Windows OSes. However, I can wall it off behind a runtime.GOOS check.

@@ -46,7 +46,8 @@ func New(path string) (*Runtime, error) {
return nil, errs.Wrap(err, "Could not create runtime directory")
}

depot, err := newDepot()
runtimePath := path
depot, err := newDepot(runtimePath)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I wanted to pass path to newDepot(), but it didn't read right, so that's why I did the logic the way you originally saw it. I agree that the runtime shouldn't be concerned with what the depot can or cannot do, so I came up with something more readable here.

@mitchell-as mitchell-as requested a review from Naatan August 1, 2024 21:26
Copy link
Member

@Naatan Naatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, but could you add a validation under the two Deploy functions that validates that the absoluteDest matches this volume?

Comment on lines +52 to +60
// Windows does not support hard-linking across drives, so determine if the runtime path is on a
// separate drive than the default depot path. If so, use a drive-specific depot path.
if runtime.GOOS == "windows" {
runtimeVolume := filepath.VolumeName(runtimePath)
storageVolume := filepath.VolumeName(storage.CachePath())
if runtimeVolume != storageVolume {
depotPath = filepath.Join(runtimeVolume+"\\", "activestate", depotName)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see where you were coming from, it feels awkward dealing with the runtimePath here, since depot shouldn't have any concerns about that. But this might be an ok compromise for now, the only other solution I see is introduce some new construct that is responsible for this information, which feels like overkill for the current use-case.

That said, may be good to highlight this compromise as a comment so we hopefully avoid us further building on this by accident. ie. if we need to extend this logic then we should probably think more about the separate construct.

@mitchell-as
Copy link
Contributor Author

@Naatan I'm not sure what you're asking for. Are you asking for a func (d *depot) Validate(absoluteDest string) error {} below the two Deploy functions? Or are you asking for a if filepath.VolumeName(absoluteDest) != filepath.VolumeName(d.depotPath) { return errs.New("volume mismatch") } inside each of the Deploy functions?

If the former, what calls the validator and where? This is my first experience with the new runtime. I'm a n00b.

@mitchell-as
Copy link
Contributor Author

@Naatan ping

@Naatan
Copy link
Member

Naatan commented Aug 6, 2024

@mitchell-as sorry; I meant the latter; add some code to the two deploy functions to protect against miss-use. I suspect the low level error we would encounter would not be intuitive to interpret otherwise.

@mitchell-as
Copy link
Contributor Author

Thanks. Turns out that in order to avoid code duplication, I ended up doing both, heh.

@mitchell-as mitchell-as requested a review from Naatan August 6, 2024 17:03
@mitchell-as mitchell-as merged commit 513da94 into version/0-46-0-RC1 Aug 6, 2024
7 checks passed
@mitchell-as mitchell-as deleted the mitchell/dx-2943 branch August 6, 2024 18:16
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.

2 participants