Skip to content

Commit e76512c

Browse files
committed
env/windows-arm64/azure: fix problems with token generation setup
This patch revises the recipe for creating a scheduled task (via powershell commands) to run the LUCI token generator. Turns out that the default for scheduled tasks is to only run them when their specified user is logged in, meaning that the recipe as written was incorrect. The fix is to use the 'New-ScheduledTaskPrincipal' cmdlet to boost the priority of the task and run it as a service account / system user. Updates golang/go#64587. Change-Id: I281d8c5c11b0b41478524dfd456f4b1179c4d840 Reviewed-on: https://go-review.googlesource.com/c/build/+/549755 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 4d79046 commit e76512c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

env/windows-arm64/azure/startup.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,15 @@ $cmd | Out-File -Encoding ascii $run_tokend_batfile
239239
Add-Content -Encoding ascii -Path $run_tokend_batfile -Value "echo %date% %time% >> $cert_dir\lastrun.txt"
240240

241241
# Create a scheduled task to run 'luci_machine_tokend.exe' every 10
242-
# minutes (as tokend user) to regenerated token.json.
242+
# minutes to regenerate token.json. Note that this scheduled task
243+
# has to be run even when user "tokend" is not logged in, which requires
244+
# a bit of extra work (via -LogonType option to New-ScheduledTaskPrincipal).
243245
$task_action = New-ScheduledTaskAction -Execute $run_tokend_batfile
244-
$task_trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 1)
245-
$task_settings = New-ScheduledTaskSettingsSet
246-
$task = New-ScheduledTask -Action $task_action -Trigger $task_trigger -Settings $task_settings
247-
Register-ScheduledTask -TaskName 'Token Generator' -InputObject $task -User 'tokend'
246+
$task_trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 10)
247+
$task_settings = New-ScheduledTaskSettingsSet -MultipleInstances Parallel
248+
$principal = New-ScheduledTaskPrincipal -LogonType ServiceAccount -UserID "NT AUTHORITY\SYSTEM" -RunLevel Highest
249+
$task = New-ScheduledTask -Action $task_action -Trigger $task_trigger -Settings $task_settings -Principal $principal
250+
Register-ScheduledTask -TaskName 'Token Generator' -InputObject $task
248251

249252
# Run the swarming loop script on login
250253
Write-Host "setting bootstrapswarm to run on start"

0 commit comments

Comments
 (0)