Closed jakubgs closed 3 years ago
The service can be run using the https://github.com/winsw/winsw windows service wrapper that we use for the Jenkins Agent.
It might even make sense to create an infra-role-winsw
Ansible role to generalize this setup.
Some issues tho:
The priority is to get it working. We can handle other things later.
Having weird issues bootstrapping Windows host using the same infra-role-bootstrap-windows
role:
TASK [command] *****************************************************************
fatal: [35.232.80.244]: FAILED! => {
"changed": false,
"rc": 0
}
MSG:
MODULE FAILURE
See stdout/stderr for the exact error
MODULE_STDERR:
/bin/sh: PowerShell: command not found
I tried using newer windows-server-2004-dc-core-v20200813
instead of windows-server-2004-dc-core-v20200813
but it fails.
The issue must be with something like PATH
, because PowerShell HAS to be installed on a Windows Core image.
Especially since the sysprep-specialize-script-ps1
uses it:
https://github.com/status-im/infra-tf-google-cloud/blob/f81f21f23a9683e333bf7adc3a32f3576a775c18/main.tf#L130-L134
I can see the script running fine when I use ``:
gcloud compute --project=russia-servers instances get-serial-port-output windows-01-gc-us-central1-a-nimbus-prater --zone=us-central1-a
2021/06/02 11:48:52 GCEMetadataScripts: Starting specialize scripts (version 20200129.00).
2021/06/02 11:48:52 GCEMetadataScripts: Found sysprep-specialize-script-ps1 in metadata.
2021/06/02 11:48:53 GCEMetadataScripts: sysprep-specialize-script-ps1: >>> START: Initial Bootstrapping Script
2021/06/02 11:48:53 GCEMetadataScripts: sysprep-specialize-script-ps1: Enable Administrator account...
2021/06/02 11:48:53 GCEMetadataScripts: sysprep-specialize-script-ps1: Installing Scoop package manager...
2021/06/02 11:48:53 GCEMetadataScripts: sysprep-specialize-script-ps1: Initializing...
2021/06/02 11:48:54 GCEMetadataScripts: sysprep-specialize-script-ps1: Downloading scoop...
2021/06/02 11:48:54 GCEMetadataScripts: sysprep-specialize-script-ps1: Extracting...
...
2021/06/02 11:50:01 GCEMetadataScripts: sysprep-specialize-script-ps1: Installing OpenSSH Server...
And it takes a bit over a minute to finish.
If I run bootstrap afterwards it does connect, except it fails with a different Python error:
> ap ansible/bootstrap-win.yml -i '35.232.80.244,' -u Administrator
PLAY [Verify Ansible versions] *******************************************************************************************************************************************************************
TASK [command] ***********************************************************************************************************************************************************************************
ok: [35.232.80.244]
PLAY [Bootstrap windows host] ********************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************
fatal: [35.232.80.244]: FAILED! => {
"ansible_facts": {},
"changed": false,
"failed_modules": {
"setup": {
"ansible_facts": {
"discovered_interpreter_python": "/c/ProgramData/scoop/apps/python/current/python"
},
"exception": "Traceback (most recent call last):\r\n File \"<stdin>\", line 102, in <module>\r\n File \"<stdin>\", line 94, in _ansiballz_main\r\n File \"<stdin>\", line 37, in invoke_module\r\n File \"<frozen zipimport>\", line 259, in load_module\r\n File \"C:\\Users\\administrator\\AppData\\Local\\Temp\\ansible_setup_payload_g2ms70dm\\ansible_setup_payload.zip\\ansible\\module_utils\\basic.py\", line 38, in <module>\r\nModuleNotFoundError: No module named 'grp'\r\n",
"failed": true,
"module_stderr": "Traceback (most recent call last):\r\n File \"<stdin>\", line 102, in <module>\r\n File \"<stdin>\", line 94, in _ansiballz_main\r\n File \"<stdin>\", line 37, in invoke_module\r\n File \"<frozen zipimport>\", line 259, in load_module\r\n File \"C:\\Users\\administrator\\AppData\\Local\\Temp\\ansible_setup_payload_g2ms70dm\\ansible_setup_payload.zip\\ansible\\module_utils\\basic.py\", line 38, in <module>\r\nModuleNotFoundError: No module named 'grp'\r\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1,
"warnings": [
"Platform mingw64_nt-10.0-17763 on host 35.232.80.244 is using the discovered Python interpreter at /c/ProgramData/scoop/apps/python/current/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."
]
}
}
}
MSG:
The following modules failed to execute: setup
Oh wait, I know what's happening. It's the Ansible requirements version check that fails:
- name: Verify Ansible versions
hosts: all
tags: always
become: false
run_once: true
gather_facts: false
tasks:
- local_action: command ./versioncheck.py
changed_when: false
It fails because locally there is no PowerShell.
I tried setting ansible_shell_executable: '/bin/sh'
and ansible_shell_type: 'sh'
but it didn't work. For now I'll just drop it.
Some fixes I had to do to the GC Terraform module:
And the deployment of windows-01.gc-us-central1-a.nimbus.prater
: https://github.com/status-im/infra-nimbus/commit/b5cbe7fa
I created a separate repository for WinSW Ansible role: https://github.com/status-im/infra-role-winsw
And another separate one for Nimbus nodes on Windows: https://github.com/status-im/infra-role-beacon-node-windows
It's possible to schedule tasks on Windows using the win_scheduled_task
Ansible task:
https://docs.ansible.com/ansible/latest/collections/community/windows/win_scheduled_task_module.html
- name: Create task with multiple triggers
community.windows.win_scheduled_task:
name: TriggerTask
path: \Custom
actions:
- path: cmd.exe
triggers:
- type: daily
- type: monthlydow
username: SYSTEM
The node binaries build fine without issues in 8 minutes:
admin@windows-01 MINGW64 ~/nimbus-eth2 (stable)
$ make nimbus_beacon_node nimbus_signing_process
Tip of the day: this will probably build faster if you use "mingw32-make.exe -j4 ...".
Building: build/generate_makefile
Build completed successfully: build/generate_makefile
Building: build/nimbus_beacon_node
C:\Users\admin\nimbus-eth2\beacon_chain\nimbus_beacon_node.nim(14, 9) Warning: imported and not used: 'ansi_c' [UnusedImport]
C:\Users\admin\nimbus-eth2\beacon_chain\nimbus_beacon_node.nim(14, 9) Warning: imported and not used: 'ansi_c' [UnusedImport]
Build completed successfully: build/nimbus_beacon_node
Build completed successfully: build/nimbus_beacon_node
Building: build/nimbus_signing_process
Build completed successfully: build/nimbus_signing_process
I'm getting weird issues trying to create a scheduled task for building the node:
TASK [infra-role-beacon-node-windows : Schedule node builds] ***********************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: at Microsoft.PowerShell.Commands.JoinPathCommand.ProcessRecord()
fatal: [windows-01.gc-us-central1-a.nimbus.prater]: FAILED! => {
"changed": false
}
MSG:
Unhandled exception while executing module: Cannot find drive. A drive with the name '\C' does not exist.
This is a useful utility: https://github.com/gerardog/gsudo
Added some more global packages to be installed at bootstrap:
But according to this thread it's quite difficult to run as a different user in a shell: https://github.com/gerardog/gsudo/issues/79#issuecomment-786786330
I'm trying to run the script with runas
, but I get no output whatsoever:
admin@windows-01 MINGW64 /c/Users/nimbus/beacon-node-prater
$ runas /user:nimbus 'bash build.sh'
Enter the password for nimbus:
Attempting to start bash build.sh as user "WINDOWS-01\nimbus" ...
I can't even get a single command to run:
admin@windows-01 MINGW64 /c/Users/nimbus/beacon-node-prater
$ runas /user:nimbus 'bash -c "echo WTF"'
Enter the password for nimbus:
Attempting to start bash -c "echo WTF" as user "WINDOWS-01\nimbus" ...
I must be missing something.
I tried running from an RDP session, and I can see it start, but it just disappears right away, so I can't make out the error:
Noticed Arthur wasn't added to Windows bootstrap so I fixed that: https://github.com/status-im/infra-role-bootstrap-windows/commit/9f82c62a
The package manager we use - scoop
- is actually being abandoned by the maintainers, because issues like this go nowhere:
https://github.com/ScoopInstaller/Main/issues/1752
The actual proper alternative is actually WinGet: https://github.com/microsoft/winget-cli https://docs.microsoft.com/en-us/windows/package-manager/winget/ https://devblogs.microsoft.com/commandline/windows-package-manager-preview/
But if you look in it's community repository there is no sign of packages like GCC: https://github.com/microsoft/winget-pkgs
What's weird is that after installing GCC it's not available in PATH
:
admin@windows-01 MINGW64 ~
$ scoop install --global gcc
Installing 'gcc' (9.3.0-2) [64bit]
...(omitted)...
Running pre-install script...
Linking C:\ProgramData\scoop\apps\gcc\current => C:\ProgramData\scoop\apps\gcc\9.3.0-2
Creating shim for 'make'.
Running post-install script...
'gcc' (9.3.0-2) was installed successfully!
admin@windows-01 MINGW64 ~
$ which gcc
which: no gcc in (/mingw64/bin:/usr/bin:/c/Users/admin/bin:/c/ProgramData/scoop/apps/python/current/Scripts:/c/ProgramData/scoop/apps/python/current:/c/ProgramData/scoop/shims:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/
OpenSSH:/c/ProgramData/GooGet:/c/Program Files/Google/Compute Engine/metadata_scripts:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files/PowerShell/7:/c/Program Files/Google/Compute Engine/sysprep:/c/Windows/system32/config/systemprofile/scoop/shims:/c/Windows/system3
2/config/systemprofile/AppData/Local/Microsoft/WindowsApps:/c/Users/admin/scoop/shims:/c/Users/admin/AppData/Local/Microsoft/WindowsApps)
It appears Scoop doesn't create any shims for GCC:
admin@windows-01 MINGW64 ~
$ ls -l /c/ProgramData/scoop/shims/ | grep -i gcc
I'm trying to add it to system-wide PATH
using Ansible's win_path
:
- name: Add GCC to the system wide path
win_path:
name: 'PATH'
elements: ['C:/ProgramData/scoop/apps/gcc/current/bin']
scope: 'machine'
state: 'present'
But it doesn't seem to have any effect:
PS C:\Users\admin> Get-Item env:PATH | grep gcc
PS C:\Users\admin>
Weird, I even trying using setx
:
PS C:\Users\admin> setx /M PATH "$($env:PATH);C:\ProgramData\scoop\apps\gcc\current\bin"
SUCCESS: Specified value was saved.
But I see no result:
PS C:\Users\admin> Get-Item env:PATH | cat | tr ';' '\n'
C:\ProgramData\scoop\apps\git\2.32.0.windows.1\mingw64\bin
C:\ProgramData\scoop\apps\git\2.32.0.windows.1\usr\bin
C:\Users\admin\bin
C:\ProgramData\scoop\apps\python\current\Scripts
C:\ProgramData\scoop\apps\python\current
C:\ProgramData\scoop\shims
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\ProgramData\GooGet
C:\Program Files\Google\Compute Engine\metadata_scripts
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin
C:\Program Files\PowerShell\7\
C:\Program Files\Google\Compute Engine\sysprep
C:\Windows\system32\config\systemprofile\scoop\shims
C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps
C:\Users\admin\scoop\shims
C:\Users\admin\AppData\Local\Microsoft\WindowsApps
Issues with win_path
task not setting things correctly is known: https://github.com/ansible/ansible/issues/57815
Oh look, yet another issue I've never seen before:
Set-PsFzfOption : The 'Set-PsFzfOption' command was found in the module 'PSFzf', but the module
could not be loaded. For more information, run 'Import-Module PSFzf'.
At C:\Users\admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:5 char:1
+ Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t'
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-PsFzfOption:String) [], CommandNotFoundExcepti
on
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Set-PsFzfOption : The 'Set-PsFzfOption' command was found in the module 'PSFzf', but the module
could not be loaded. For more information, run 'Import-Module PSFzf'.
At C:\Users\admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:6 char:1
+ Set-PsFzfOption -PSReadlineChordReverseHistory 'Ctrl+r'
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-PsFzfOption:String) [], CommandNotFoundExcepti
on
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
scoop : The term 'scoop' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.
At line:1 char:65
+ ... ]::InputEncoding = New-Object Text.UTF8Encoding $false; scoop install ...
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (scoop:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I looks like win_path
takes effect after reboot:
admin@windows-01 MINGW64 ~
$ echo $PATH | tr ':' '\n' | grep gcc
/c/ProgramData/scoop/apps/gcc/current/bin
And indeed using win_reboot
does make it go into effect:
# WARNING: There's a known issue with broken GCC mirrors:
# https://github.com/ScoopInstaller/Main/issues/1752
- name: Install build dependencies
win_shell: 'scoop install --global {{ beacon_node_build_deps | join(" ") }}'
- name: Add GCC to the system wide PATH
win_path:
name: 'PATH'
elements: 'C:/ProgramData/scoop/apps/gcc/current/bin'
scope: 'machine'
state: 'present'
register: machine_path
- name: Restart host for PATH change to work
win_reboot:
reboot_timeout: 160
when: machine_path.changed
Okay, I got GCC installed, but now I'm seeing compilation errors:
gcc -Ic_code -w -O3 -fno-strict-aliasing -c -o c_code/1_2/stdlib_assertions.nim.o c_code/1_2/stdlib_assertions.nim.c
In file included from c_code/1_2/stdlib_assertions.nim.c:6:
c_code/nimbase.h: In function 'float64ToInt32':
c_code/nimbase.h:379:3: internal compiler error: Segmentation fault
379 | return x >= 0 ? (NI)(x+0.5) : (NI)(x-0.5);
| ^~~~~~
libbacktrace could not find executable to open
We've already seen these issues in https://github.com/status-im/infra-ci/issues/32 and https://github.com/status-im/nimbus-eth2/issues/2180, and according to https://github.com/msys2/MINGW-packages/issues/6674 the issue is with "messed up libgmp". So the solution is to downgrade Git back to 2.28.0.windows.1
.
After unpacking a tarball from another host with Git 2.28.0.windows.1
I've reset the version to that:
admin@windows-01 MINGW64 /c/ProgramData/scoop/apps/git
$ scoop reset git@2.28.0.windows.1
Resetting git (2.28.0.windows.1).
Linking C:\ProgramData\scoop\apps\git\current => C:\ProgramData\scoop\apps\git\2.28.0.windows.1
Creating shim for 'git'.
Creating shim for 'gitk'.
Creating shim for 'git-gui'.
Creating shim for 'tig'.
Creating shim for 'git-bash'.
Creating shortcut for Git Bash (git-bash.exe)
Creating shortcut for Git GUI (git-gui.exe)
The build now works fine:
nimbus@windows-01 MINGW64 ~/beacon-node-prater
$ ./build.sh
>>> Fetching changes...
HEAD is now at 7ffa8c28 nightly build: change tag name (#2643)
>>> Building binaries...
...(omitted)...
Build completed successfully: build/nimbus_signing_process
>>> SUCCESS
It seems like ln -s
on Windows just copies files:
nimbus@windows-01 MINGW64 ~/beacon-node-prater
$ ln -s repo/build/nimbus_beacon_node_7ffa8c28.exe ./nimbus_beacon_node
nimbus@windows-01 MINGW64 ~/beacon-node-prater
$ du -hsc nimbus_beacon_node
301M nimbus_beacon_node
301M total
nimbus@windows-01 MINGW64 ~/beacon-node-prater
$ readlink nimbus_beacon_node
NICE! It works with WinSW wrapper:
admin@windows-01 MINGW64 /c/Users/nimbus/beacon-node-prater
$ ls -l
total 4073
-rw-r--r-- 1 admin 197121 99 Jun 10 15:19 beacon-node-prater.err.log
-rwxr-xr-x 1 admin 197121 655872 Jun 10 14:59 beacon-node-prater.exe
-rw-r--r-- 1 admin 197121 3455386 Jun 10 15:48 beacon-node-prater.out.log
-rw-r--r-- 1 admin 197121 14732 Jun 10 15:46 beacon-node-prater.wrapper.log
-rw-r--r-- 1 admin 197121 924 Jun 10 15:44 beacon-node-prater.yml
drwxr-xr-x 1 admin 197121 0 Jun 10 14:48 bin
-rwxr-xr-x 1 admin 197121 2004 Jun 10 14:55 build.sh
drwxr-xr-x 1 admin 197121 0 Jun 10 15:45 data
drwxr-xr-x 1 admin 197121 0 Jun 10 14:04 repo
admin@windows-01 MINGW64 /c/Users/nimbus/beacon-node-prater
$ ./beacon-node-prater.exe start
2021-06-10 15:46:23,784 INFO - Starting service 'Nimbus Beacon Node (beacon-node-prater)'...
2021-06-10 15:46:24,023 INFO - Service 'Nimbus Beacon Node (beacon-node-prater)' started successfully.
admin@windows-01 MINGW64 /c/Users/nimbus/beacon-node-prater
$ tail -n2 beacon-node-prater.out.log
{"lvl":"INF","ts":"2021-06-10 15:46:38.539+00:00","msg":"Scheduling first slot action","topics":"beacnde","tid":4144,"file":"nimbus_beacon_node.nim:1006","
startTime":"11w2d1h46m38s539ms339us300ns","nextSlot":569334,"timeToNextSlot":"9s460ms660us700ns"}
{"lvl":"DBG","ts":"2021-06-10 15:46:38.539+00:00","msg":"Starting syncing worker","topics":"beacnde","tid":4144,"file":"sync_manager.ni
But we still have an issue because the firewall isn't properly open:
> sudo nmap -Pn -p9000 windows-01.gc-us-central1-a.nimbus.prater
Starting Nmap 7.80 ( https://nmap.org ) at 2021-06-10 17:51 CEST
Nmap scan report for windows-01.gc-us-central1-a.nimbus.prater (35.232.80.244)
Host is up.
rDNS record for 35.232.80.244: 244.80.232.35.bc.googleusercontent.com
PORT STATE SERVICE
9000/tcp filtered cslistener
Nmap done: 1 IP address (1 host up) scanned in 2.14 seconds
Changes:
I tried checking if my firewall rules exist, but they don't appear to exist:
PS C:\Users\nimbus\beacon-node-prater> Get-NetFirewallRule –Name beacon-node-prater-tcp
Set-NetFirewallRule : No MSFT_NetFirewallRule objects found with property 'InstanceID' equal to 'beacon-node-prater-tcp'. Verify the value of the property and retry.
At line:1 char:1
+ Set-NetFirewallRule –Name beacon-node-prater-tcp
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (beacon-node-prater-tcp:String) [Set-NetFirewallRule], CimJobException
+ FullyQualifiedErrorId : CmdletizationQuery_NotFound_InstanceID,Set-NetFirewallRule
Whoops, this is the correct way to do this:
PS C:\Users\nimbus> Get-NetFirewallRule | Where { $_.DisplayName.StartsWith("beacon-node") } | Format-Table
Name DisplayName DisplayGroup Enabled Profile Direction Action
---- ----------- ------------ ------- ------- --------- ------
{978A8444-8465-4AB0-B029-883D8D187351} beacon-node-prater-tcp True Any Inbound Allow
{440471F1-748A-4A1A-8A27-F215B480A063} beacon-node-prater-udp True Any Inbound Allow
So they do exist.
Okay, this works:
PS C:\Users\nimbus> Get-NetFirewallRule -DisplayName beacon-node-prater-tcp
Name : {978A8444-8465-4AB0-B029-883D8D187351}
DisplayName : beacon-node-prater-tcp
Description : Nimbus Eth2 Beacon Node ports
DisplayGroup :
Group :
Enabled : True
Profile : Any
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
PS C:\Users\nimbus> Get-NetFirewallRule -DisplayName beacon-node-prater-tcp | Get-NetFirewallPortFilter
Protocol : TCP
LocalPort : 9100
RemotePort : Any
IcmpType : Any
DynamicTarget : Any
So why is it not open...
This works pretty well:
PS C:\Users\nimbus> Get-NetFirewallRule -DisplayGroup 'Nimbus Beacon Node' |
>> Format-Table -Property DisplayName,
>> DisplayGroup,
>> @{Name='Protocol';Expression={($PSItem | Get-NetFirewallPortFilter).Protocol}},
>> @{Name='LocalPort';Expression={($PSItem | Get-NetFirewallPortFilter).LocalPort}},
>> @{Name='RemotePort';Expression={($PSItem | Get-NetFirewallPortFilter).RemotePort}},
>> @{Name='RemoteAddress';Expression={($PSItem | Get-NetFirewallAddressFilter).RemoteAddress}},
>> Enabled,
>> Profile,
>> Direction,
>> Action
DisplayName DisplayGroup Protocol LocalPort RemotePort RemoteAddress Enabled Profile Direction Action
----------- ------------ -------- --------- ---------- ------------- ------- ------- --------- ------
beacon-node-prater-tcp Nimbus Beacon Node TCP 9100 Any Any True Any Inbound Allow
beacon-node-prater-udp Nimbus Beacon Node UDP 9100 Any Any True Any Inbound Allow
Got that from here: https://itluke.online/2018/11/27/how-to-display-firewall-rule-ports-with-powershell/
Oh wait, I was checking the default role port, no the one configured, which is 9100
! It works:
> sudo nmap -Pn -p9100 windows-01.gc-us-central1-a.nimbus.prater
Starting Nmap 7.80 ( https://nmap.org ) at 2021-06-10 18:20 CEST
Nmap scan report for windows-01.gc-us-central1-a.nimbus.prater (35.232.80.244)
Host is up (0.14s latency).
rDNS record for 35.232.80.244: 244.80.232.35.bc.googleusercontent.com
PORT STATE SERVICE
9100/tcp open jetdirect
Nmap done: 1 IP address (1 host up) scanned in 0.19 seconds
Glorious success:
Still needs a bunch of cleanup and setup to run multiple nodes tho.
There's three Powershell commands for getting info about scheduled tasks:
PS C:\Users\admin> Get-Command -Module ScheduledTasks -Verb get
CommandType Name Version Source
----------- ---- ------- ------
Function Get-ClusteredScheduledTask 1.0.0.0 ScheduledTasks
Function Get-ScheduledTask 1.0.0.0 ScheduledTasks
Function Get-ScheduledTaskInfo 1.0.0.0 ScheduledTasks
PS C:\Users\admin> Get-ScheduledTask -TaskName beacon-node-prater-stable-build
TaskPath TaskName State
-------- -------- -----
\ beacon-node-prater-stable-build Ready
PS C:\Users\admin> Get-ScheduledTaskInfo -TaskName beacon-node-prater-stable-build
LastRunTime : 11/30/1999 12:00:00 AM
LastTaskResult : 267011
NextRunTime : 6/15/2021 1:00:00 AM
NumberOfMissedRuns : 0
TaskName : beacon-node-prater-stable-build
TaskPath :
PSComputerName :
But neither of those give access to the task logs. It appears that getting logs is MUCH more elaborate:
https://devblogs.microsoft.com/scripting/use-powershell-to-show-results-of-scheduled-tasks/
These instructions look quite absurd:
PS C:\Users\admin> Get-ScheduledTaskInfo -TaskName beacon-node-prater-stable-build | Format-Table
LastRunTime LastTaskResult NextRunTime NumberOfMissedRuns TaskName TaskPath PSComputerName
----------- -------------- ----------- ------------------ -------- -------- --------------
11/30/1999 12:00:00 AM 267011 6/15/2021 1:00:00 AM 0 beacon-node-prater-stable-bui
I'm trying to use Start-ScheduledTask
:
PS C:\Users\admin> Start-ScheduledTask -TaskName beacon-node-prater-stable-build | Write-Output
PS C:\Users\admin>
But there's not output, and it doesn't seem to change info about the task:
PS C:\Users\admin> Get-ScheduledTaskInfo -TaskName beacon-node-prater-stable-build | Format-Table
LastRunTime LastTaskResult NextRunTime NumberOfMissedRuns TaskName TaskPath PSComputerName
----------- -------------- ----------- ------------------ -------- -------- --------------
11/30/1999 12:00:00 AM 267011 6/15/2021 1:00:00 AM 0 beacon-node-prater-stable-build
Some settings don't make sense to me:
PS C:\Users\admin> $t = Get-ScheduledTask -TaskName beacon-node-prater-stable-build
PS C:\Users\admin> $t.Actions
Id :
Arguments :
Execute : C:/Users/nimbus/beacon-node-prater-stable/build.sh
WorkingDirectory :
PSComputerName :
PS C:\Users\admin> $t.Settings
AllowDemandStart : True
AllowHardTerminate : True
Compatibility : Vista
DeleteExpiredTaskAfter :
DisallowStartIfOnBatteries : True
Enabled : True
ExecutionTimeLimit : PT72H
Hidden : False
IdleSettings : MSFT_TaskIdleSettings
MultipleInstances : IgnoreNew
NetworkSettings : MSFT_TaskNetworkSettings
Priority : 7
RestartCount : 0
RestartInterval :
RunOnlyIfIdle : False
RunOnlyIfNetworkAvailable : False
StartWhenAvailable : False
StopIfGoingOnBatteries : True
WakeToRun : False
DisallowStartOnRemoteAppSession : False
UseUnifiedSchedulingEngine : False
MaintenanceSettings :
volatile : False
PSComputerName :
For example, why is StopIfGoingOnBatteries
set to True
? Or DisallowStartIfOnBatteries
also set to True
.
I tried putting the script into the arguments
and using path
set as git-bash.exe
:
PS C:\Users\nimbus> (Get-ScheduledTask -TaskName beacon-node-prater-stable-build).Actions
Id :
Arguments : C:/Users/nimbus/beacon-node-prater-stable/build.sh
Execute : C:/ProgramData/scoop/shims/git-bash.exe
WorkingDirectory :
PSComputerName :
But that doesn't work either...
I tried setting path
:
PS C:\Users\nimbus> Get-ScheduledTask -TaskName beacon-node-prater-stable-build
TaskPath TaskName State
-------- -------- -----
\NimbusBuilds\ beacon-node-prater-stable-build Ready
But that just causes it to fail because it doesn't exist:
PS C:\Users\nimbus> Start-ScheduledTask -TaskName beacon-node-prater-stable-build
Start-ScheduledTask : The system cannot find the file specified.
At line:1 char:1
+ Start-ScheduledTask -TaskName beacon-node-prater-stable-build
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Start-ScheduledTask], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070002,Start-ScheduledTask
Oh, it needs the path to be found:
PS C:\Users\nimbus> Start-ScheduledTask -TaskPath \NimbusBuilds\ -TaskName beacon-node-prater-stable-build
PS C:\Users\nimbus> Get-ScheduledTaskInfo -TaskPath \NimbusBuilds\ -TaskName beacon-node-prater-stable-build | Format-Table
LastRunTime LastTaskResult NextRunTime NumberOfMissedRuns TaskName TaskPath PSComputerName
----------- -------------- ----------- ------------------ -------- -------- --------------
11/30/1999 12:00:00 AM 267011 6/15/2021 1:00:00 AM 0 beacon-node-prater-stable-build \NimbusBuilds\
But I still can't start it...
This makes absolutely no sense to me:
This is just awful:
The only thing that is really missing from a scheduled task is the native ability to capture and manipulate the output of the task. Because a scheduled task can run almost anything that is runnable on a Windows computer, it’s not possible to anticipate and capture the output of a scheduled task. According to Windows PowerShell MVP, Karl Prosser, the output of scheduled tasks goes to “the same place where your clothes dryer puts your lost socks.”
https://devblogs.microsoft.com/scripting/using-scheduled-tasks-and-scheduled-jobs-in-powershell/
I don't get how any of this is supposed to work...
PS C:\Users\admin> $taskName = "PowershellCommandTest"
PS C:\Users\admin> $description = "Just fuck my shit up..."
PS C:\Users\admin> $1minuteLater = New-TimeSpan -Minutes 1
PS C:\Users\admin> $taskTrigger = New-ScheduledTaskTrigger -Once -At ((Get-Date) + $1minuteLater)
PS C:\Users\admin> $taskAction = New-ScheduledTaskAction `
>> -Execute 'powershell.exe' `
>> -Argument '-Command {"TEST" | Out-FIle ~/test.log}'
PS C:\Users\admin> Register-ScheduledTask `
>> -TaskName $taskName `
>> -Action $taskAction `
>> -Trigger $taskTrigger `
>> -Description $description
TaskPath TaskName State
-------- -------- -----
\ PowershellCommandTest Ready
PS C:\Users\admin> Get-ScheduledTaskInfo -TaskName $taskName | Format-Table
LastRunTime LastTaskResult NextRunTime NumberOfMissedRuns TaskName TaskPath PSComputerName
----------- -------------- ----------- ------------------ -------- -------- --------------
11/30/1999 12:00:00 AM 267011 6/15/2021 10:54:54 AM 0 PowershellCommandTest
PS C:\Users\admin> date
Tue Jun 15 10:54:03 GST 2021
PS C:\Users\admin> date
Tue Jun 15 10:54:52 GST 2021
PS C:\Users\admin> Get-ScheduledTaskInfo -TaskName $taskName | Format-Table
LastRunTime LastTaskResult NextRunTime NumberOfMissedRuns TaskName TaskPath PSComputerName
----------- -------------- ----------- ------------------ -------- -------- --------------
11/30/1999 12:00:00 AM 267011 0 PowershellCommandTest
PS C:\Users\admin> cat ~/test.log
cat : Cannot find path 'C:\Users\admin\test.log' because it does not exist.
At line:1 char:1
+ cat ~/test.log
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\admin\test.log:String) [Get-Content], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
We need a Windows host for Prater testnet nodes. The minimum hardware requirements:
It will run 3 instances of
infra-role-beacon-node
connected to the Prater testnet. Each instance will run a build from a different branch (unstable
,testing
,stable
). The nodes will take over validators of the current Prater testnet nodes with03
index (e.g.stable-03
,testing-03
, etc).It should also build the newest version of respective branch daily.
Full Details: https://github.com/status-im/infra-nimbus/issues/58