Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
fix: fix network cleanup code on windows for contianerd nodes (#4154)
Browse files Browse the repository at this point in the history
* fix: fix network cleanup code on windows for contianerd nodes

* updating more calls to cleanupnetwork.ps1 with full path

* update collect-windows-logs.ps1 to grab azure-cni logs from system32
  • Loading branch information
marosset authored Jan 14, 2021
1 parent 3eafba2 commit 009f67b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
14 changes: 14 additions & 0 deletions scripts/collect-windows-logs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ $lockedFiles | Foreach-Object {
}
}

# azure-cni logs currently end up in system32 when called by containerd so check there for logs too
$lockedTemp = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
New-Item -Type Directory $lockedTemp
$lockedFiles | Foreach-Object {
Write-Host "Copying $_ to temp"
$src = "c:\windows\system32\$_"
if (Test-Path $src) {
$tempfile = Copy-Item $src $lockedTemp -Passthru -ErrorAction Ignore
if ($tempFile) {
$paths += $tempFile
}
}
}

# Containerd log is outside the c:\k folder
$containerd = "C:\ProgramData\containerd\root\panic.log"
if (Test-Path $containerd) {
Expand Down
9 changes: 9 additions & 0 deletions staging/provisioning/windows/cleanupnetwork.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $Global:ClusterConfiguration = ConvertFrom-Json ((Get-Content "c:\k\kubeclusterc
$global:NetworkMode = "L2Bridge"
$global:ContainerRuntime = $Global:ClusterConfiguration.Cri.Name
$global:NetworkPlugin = $Global:ClusterConfiguration.Cni.Name
$global:HNSModule = "c:\k\hns.psm1"

ipmo $global:HNSModule

Expand Down Expand Up @@ -49,13 +50,21 @@ if ($global:NetworkPlugin -eq "azure") {
taskkill /IM azure-vnet.exe /f
taskkill /IM azure-vnet-ipam.exe /f

# azure-cni logs currently end up in c:\windows\system32 when machines are configured with containerd.
# https://github.com/containerd/containerd/issues/4928
$filesToRemove = @(
"c:\k\azure-vnet.json",
"c:\k\azure-vnet.json.lock",
"c:\k\azure-vnet-ipam.json",
"c:\k\azure-vnet-ipam.json.lock"
"c:\k\azure-vnet-ipamv6.json",
"c:\k\azure-vnet-ipamv6.json.lock"
"c:\windows\system32\azure-vnet.json",
"c:\windows\system32\azure-vnet.json.lock",
"c:\windows\system32\azure-vnet-ipam.json",
"c:\windows\system32\azure-vnet-ipam.json.lock"
"c:\windows\system32\azure-vnet-ipamv6.json",
"c:\windows\system32\azure-vnet-ipamv6.json.lock"
)

foreach ($file in $filesToRemove) {
Expand Down
6 changes: 3 additions & 3 deletions staging/provisioning/windows/kubeletstart.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ if ($global:NetworkPlugin -eq "azure") {
# Find if network created by CNI exists, if yes, remove it
# This is required to keep the network non-persistent behavior
# Going forward, this would be done by HNS automatically during restart of the node
./cleanupnetwork.ps1
& "c:\k\cleanupnetwork.ps1"

# Restart Kubeproxy, which would wait, until the network is created
# This was fixed in 1.15, workaround still needed for 1.14 https://github.com/kubernetes/kubernetes/pull/78612
Restart-Service Kubeproxy
Expand Down Expand Up @@ -227,7 +227,7 @@ if ($global:NetworkPlugin -eq "kubenet") {
$process | Stop-Process | Out-Null
}

./cleanupnetwork.ps1
& "c:\k\cleanupnetwork.ps1"

Write-Host "Creating a new hns Network"
$hnsNetwork = New-HNSNetwork -Type $global:NetworkMode -AddressPrefix $podCIDR -Gateway $masterSubnetGW -Name $global:NetworkMode.ToLower() -Verbose
Expand Down
2 changes: 1 addition & 1 deletion staging/provisioning/windows/windowsnodereset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if ($global:EnableHostsConfigAgent) {
# Perform cleanup
#

./cleanupnetwork.ps1
& "c:\k\cleanupnetwork.ps1"

#
# Create required networks
Expand Down

0 comments on commit 009f67b

Please sign in to comment.