HPC pack 2019 job submission filters doesn't work

saszhuqing 1 Reputation point
2021-12-03T02:21:04.863+00:00

Hello, everyone,
I am using HPC Pack 2019, and I want to add a submission filter (filter.bat) in HPC Cluster Manager-Options-Job Scheduler Configuration-Filter , to make changes to job property values by modifying the job XML file, such like Priority, RequestedNodes, OrderBy, etc.
In this page https://learn.microsoft.com/en-us/powershell/high-performance-computing/understanding-activation-and-submission-filters?view=hpc19-ps, I knew the job submission filter should return an exit code 0 or 1. So I wrote the filter.bat and filter.ps1 like below:
filter.bat

REM @ echo off
set pscmdline='PowerShell .\filter.ps1 ""%1""'
for /f %%a in (%pscmdline%) do ( set var=%%a)
set CODE=%var%
exit /b %CODE%
endlocal

filter.ps1

param($xml)

$xmlAttr = New-Object -TypeName XML
$xmlAttr.Load($xml)

$CsvPath = (Split-Path -Parent $MyInvocation.MyCommand.Definition) + "\NodeValue.csv"
$csvdata = Import-Csv $CsvPath

foreach ($f in $csvdata) {
if ( $f.Metric -eq "HPCCoresInUse" -and $f.Value -eq 0 ) {
$xmlAttr.Job.Priority="Normal"
$xmlAttr.Save($xml)
return 1
}
}
return 0

But when I submitted a job, it failed at once with the error "The Job has encountered an error: "An unexpected exception occurred while validating the job. Please try submitting the job later. If the problem persists, please contact your system administrator or check the HPC Server event log for more details.""
I also tried to convert to the filter.ps1 to filter.exe, but it also failed when I submitted a job with another error "Submission Filter timed out after 15000ms"

I also wrote an job activation filters in the same way, and it works very well. What can I do to solve this problem? Thanks.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,033 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Chenling Zhang 76 Reputation points
    2021-12-06T09:16:55.403+00:00

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.