--- /dev/null
+function Get-SSH-Sessions {
+ Get-Process sshd -IncludeUserName |
+ Where-Object UserName -notLike "*SYSTEM*" |
+ Select-Object Id
+}
+
+$runningSessions = Get-SSH-Sessions
+
+foreach ($session in $runningSessions) {
+ Stop-Process -id $session.Id
+}
--- /dev/null
+function Get-SSH-Users {
+ # Gets ssh sessions for all users not named SYSTEM
+ Get-CimInstance -ClassName Win32_Process -Filter "Name = 'sshd.exe'" |
+ Get-CimAssociatedInstance -Association Win32_SessionProcess |
+ Get-CimAssociatedInstance -Association Win32_LoggedOnUser |
+ Where-Object {$_.Name -ne 'SYSTEM'} |
+ Measure-Object
+}
+
+$usersLoggedOn = Get-SSH-Users
+
+Write-Output "Holding runner until all ssh sessions have logged out"
+while ($usersLoggedOn.Count -gt 0) {
+ $usersLoggedOn = Get-SSH-Users
+ Write-Output "."
+ Start-Sleep -s 5
+}
{# squid_no_proxy is a list of common set of fixed domains or IPs that we don't need to proxy. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/http_proxy_config.html#windows-proxy #}
{%- set squid_no_proxy = "localhost,127.0.0.1,amazonaws.com,s3.amazonaws.com,169.254.169.254,169.254.170.2,/var/run/docker.sock" -%}
+{%- macro wait_and_kill_ssh() -%}
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
+{%- endmacro -%}
+
# Template is at: .github/templates/windows_ci_workflow.yml.j2
# Generation script: .github/scripts/generate_ci_workflows.py
name: !{{ build_environment }}
http_proxy: "!{{ squid_proxy }}"
https_proxy: "!{{ squid_proxy }}"
steps:
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
+ !{{ wait_and_kill_ssh() }}
- name: Cleanup build-results and workspaces
if: always()
shell: bash
# deep clone, to allow use of git merge-base
fetch-depth: 0
!{{ common.display_ec2_information() }}
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
+ !{{ wait_and_kill_ssh() }}
- name: Cleanup workspace
if: always()
shell: bash
http_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
https_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
steps:
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup build-results and workspaces
if: always()
shell: bash
shell: bash
run: |
.github/scripts/display_ec2_information.sh
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup workspace
if: always()
shell: bash
http_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
https_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
steps:
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup build-results and workspaces
if: always()
shell: bash
shell: bash
run: |
.github/scripts/display_ec2_information.sh
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup workspace
if: always()
shell: bash
http_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
https_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
steps:
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup build-results and workspaces
if: always()
shell: bash
shell: bash
run: |
.github/scripts/display_ec2_information.sh
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup workspace
if: always()
shell: bash
http_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
https_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
steps:
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup build-results and workspaces
if: always()
shell: bash
shell: bash
run: |
.github/scripts/display_ec2_information.sh
+ - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
+ uses: seemethere/add-github-ssh-key@v1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
+ - name: Wait until all sessions have drained
+ shell: powershell
+ if: always()
+ timeout-minutes: 120
+ run: |
+ .github\scripts\wait_for_ssh_to_drain.ps1
+ - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
+ shell: powershell
+ if: always()
+ run: |
+ .github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup workspace
if: always()
shell: bash