From a6838f51ce0c389c07f6336a683f9d32c4146447 Mon Sep 17 00:00:00 2001 From: stas Date: Wed, 2 Dec 2020 09:41:59 -0800 Subject: [PATCH] Fix regression when common file share is used --- src/Agent/RESTlerAgent/RESTlerDriver.fs | 46 ++++++++++--------- .../OrchestratorLogic/Orchestrator.fs | 9 +++- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/Agent/RESTlerAgent/RESTlerDriver.fs b/src/Agent/RESTlerAgent/RESTlerDriver.fs index d86fe1e4..b7b2f3b0 100644 --- a/src/Agent/RESTlerAgent/RESTlerDriver.fs +++ b/src/Agent/RESTlerAgent/RESTlerDriver.fs @@ -467,30 +467,32 @@ let pollForBugFound workingDirectory (token: Threading.CancellationToken) (runSt let restlerExperimentLogs = experiment.FullName ++ "logs" if IO.Directory.Exists restlerExperimentLogs then - match! getListOfBugs workingDirectory runStartTime with - | None -> () - | Some bugFiles -> - let bugsFoundPosted = restlerExperimentLogs ++ "raft-bugsfound.posted.txt" - let! postedBugs = - async { - if IO.File.Exists bugsFoundPosted then - let! bugsPosted = IO.File.ReadAllLinesAsync(bugsFoundPosted) |> Async.AwaitTask - return Set.ofArray bugsPosted - else - return ignoreBugHashes - } - let! updatedBugsPosted = - bugFiles - |> Seq.map (fun (KeyValue(bugHash, bugFile)) -> + try + match! getListOfBugs workingDirectory runStartTime with + | None -> () + | Some bugFiles -> + let bugsFoundPosted = restlerExperimentLogs ++ "raft-bugsfound.posted.txt" + let! postedBugs = async { - if not <| postedBugs.Contains bugHash then - printfn "Posting bug found %s with hash %s" bugFile.file_path bugHash - do! onBugFound (Map.empty.Add("Experiment", experiment.Name).Add("BugBucket", bugFile.file_path).Add("BugHash", bugHash)) - return bugHash + if IO.File.Exists bugsFoundPosted then + let! bugsPosted = IO.File.ReadAllLinesAsync(bugsFoundPosted) |> Async.AwaitTask + return Set.ofArray bugsPosted + else + return ignoreBugHashes } - ) |> Async.Sequential - do! IO.File.WriteAllLinesAsync(bugsFoundPosted, updatedBugsPosted) |> Async.AwaitTask - + let! updatedBugsPosted = + bugFiles + |> Seq.map (fun (KeyValue(bugHash, bugFile)) -> + async { + if not <| postedBugs.Contains bugHash then + printfn "Posting bug found %s with hash %s" bugFile.file_path bugHash + do! onBugFound (Map.empty.Add("Experiment", experiment.Name).Add("BugBucket", bugFile.file_path).Add("BugHash", bugHash)) + return bugHash + } + ) |> Async.Sequential + do! IO.File.WriteAllLinesAsync(bugsFoundPosted, updatedBugsPosted) |> Async.AwaitTask + with + | :? System.ArgumentNullException as ex -> printfn "Got excpetion while polling for bug found: %A" ex return! poll() } poll() diff --git a/src/Orchestrator/OrchestratorLogic/Orchestrator.fs b/src/Orchestrator/OrchestratorLogic/Orchestrator.fs index efa3967c..fa1a1593 100644 --- a/src/Orchestrator/OrchestratorLogic/Orchestrator.fs +++ b/src/Orchestrator/OrchestratorLogic/Orchestrator.fs @@ -505,6 +505,11 @@ module ContainerInstances = ) r, isIdling + let getTaskWorkDirectoryPath (containerGroupName : string) (rootFileShare: string option) (workDirectory : string) (taskOutputFolder : string) = + match rootFileShare with + | None -> sprintf "%s/%s" workDirectory taskOutputFolder + | Some _ -> sprintf "%s/%s/%s" workDirectory containerGroupName taskOutputFolder + let getContainerGroupInstanceConfiguration (containerGroupName: string) (logger:ILogger) @@ -539,7 +544,7 @@ module ContainerInstances = return { RunDirectory = Some runDirectory - WorkDirectory = Some(sprintf "%s/%s" workDirectory task.OutputFolder) + WorkDirectory = Some(getTaskWorkDirectoryPath containerGroupName jobCreateRequest.JobDefinition.RootFileShare workDirectory task.OutputFolder) ContainerName = (sprintf "%d-%s" i task.OutputFolder).ToLowerInvariant() ToolConfiguration = toolConfig } @@ -803,7 +808,7 @@ module ContainerInstances = RunDirectory = None WorkDirectory = match target.OutputFolder with - | Some x -> Some(sprintf "%s/%s" workDirectory x) + | Some x -> Some(getTaskWorkDirectoryPath containerGroupName jobCreateRequest.JobDefinition.RootFileShare workDirectory x) | None -> None ToolConfiguration = {