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

fix: Wait for management IP after creating ext network. #2049

Merged
merged 2 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion parts/k8s/windowskubeletfunc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,37 @@ if (!`$hnsNetwork)
{
Write-Host "Creating a new hns Network"
ipmo `$global:HNSModule

`$na = @(Get-NetAdapter -Physical)
if (`$na.Count -eq 0)
{
throw "Failed to find any physical network adapters"
}

# If there is more than one adapter, use the first adapter.
`$managementIP = (Get-NetIPAddress -ifIndex `$na[0].ifIndex -AddressFamily IPv4).IPAddress
`$adapterName = `$na[0].Name
write-host "Using adapter `$adapterName with IP address `$managementIP"
`$mgmtIPAfterNetworkCreate

# Fixme : use a smallest range possible, that will not collide with any pod space
New-HNSNetwork -Type `$global:NetworkMode -AddressPrefix "192.168.255.0/30" -Gateway "192.168.255.1" -Name `$global:ExternalNetwork -Verbose
New-HNSNetwork -Type `$global:NetworkMode -AddressPrefix "192.168.255.0/30" -Gateway "192.168.255.1" -AdapterName `$adapterName -Name `$global:ExternalNetwork -Verbose

# Wait for the switch to be created and the ip address to be assigned.
for (`$i=0;`$i -lt 60;`$i++)
{
`$mgmtIPAfterNetworkCreate = Get-NetIPAddress `$managementIP -ErrorAction SilentlyContinue
pradipd marked this conversation as resolved.
Show resolved Hide resolved
if (`$mgmtIPAfterNetworkCreate)
{
break
}
sleep -Milliseconds 1000
}

if (-not `$mgmtIPAfterNetworkCreate)
{
throw "Failed to find `$managementIP after creating `$global:ExternalNetwork network"
}
}

# Find if network created by CNI exists, if yes, remove it
Expand Down
31 changes: 30 additions & 1 deletion pkg/engine/templates_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.