Skip to content

Prepare procedure source URL for remote tarballs #92

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

Merged
merged 4 commits into from
Jun 10, 2025

Conversation

8W9aG
Copy link
Contributor

@8W9aG 8W9aG commented Jun 9, 2025

  • If someone has a URL path for a procedure that contains multiple directories this currently fail
  • Hash the path so the directories are standardised

@8W9aG 8W9aG requested a review from nevillelyh June 9, 2025 17:37
@8W9aG 8W9aG requested a review from a team as a code owner June 9, 2025 17:38
@@ -203,7 +205,8 @@ func (h *Handler) Predict(w http.ResponseWriter, r *http.Request) {
http.Error(w, "invalid procedure_source_url", http.StatusBadRequest)
return
}
srcDir := u.Path
hash := md5.Sum([]byte(u.Path))
Copy link
Contributor

Choose a reason for hiding this comment

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

We use SHA256 in most places. Do that for consistency? Performance is not an issue here.

Copy link
Contributor

@nevillelyh nevillelyh Jun 9, 2025

Choose a reason for hiding this comment

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

We were assuming req.ProcedureSourceURL was a file:///<path> type local path that already exists.
But here we should probably dome something like:

var srcDir string
if u.Scheme == "file" {
    srcDir = u.Path
}
else {
    // URL is (http|https)://...
    sha := <sha sum of URL>
    srcDir = path.Join(os.TempDir(), "procedure-" + sha)
    os.MkdirAll(srcDir)
    <pget -x URL srcDir>
}

Copy link
Contributor

Choose a reason for hiding this comment

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

pget -x <URL> <dir> creates the <dir> so don't even need os.MkdirAll

@@ -120,6 +120,7 @@ func NewRunner(awaitExplicitShutdown bool, uploadUrl string) *Runner {

func NewProcedureRunner(awaitExplicitShutdown bool, uploadUrl string, srcDir string) *Runner {
r := NewRunner(awaitExplicitShutdown, uploadUrl)
os.Mkdir(srcDir, 0o755)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd move this to server.go where we hash URL & extract tarball. Runner should always assume dir is prepared.

8W9aG added 3 commits June 10, 2025 14:26
* If someone has a URL path for a procedure that
contains multiple directories this currently fail
* Hash the path so the directories are
standardised
@nevillelyh nevillelyh force-pushed the sackfield/hash-src-dir branch from 4f8d514 to f870ab9 Compare June 10, 2025 18:31
@nevillelyh nevillelyh changed the title Hash src dir so paths are sanitised Prepare procedure source URL for remote tarballs Jun 10, 2025
@nevillelyh nevillelyh force-pushed the sackfield/hash-src-dir branch 4 times, most recently from d7508d1 to 3f985d8 Compare June 10, 2025 18:54
@nevillelyh nevillelyh force-pushed the sackfield/hash-src-dir branch from 3f985d8 to e10a9c9 Compare June 10, 2025 18:57
@nevillelyh nevillelyh merged commit 7db82aa into main Jun 10, 2025
14 checks passed
@nevillelyh nevillelyh deleted the sackfield/hash-src-dir branch June 10, 2025 18:58
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