From 9f3fcbbd6820da20390306a58b15b4d911a6fd72 Mon Sep 17 00:00:00 2001 From: Antonin Bas Date: Tue, 9 Jan 2024 09:57:10 -0800 Subject: [PATCH] Fix Clean-AntreaNetwork.ps1 invocation in Prepare-AntreaAgent.ps1 In "containerized OVS" mode, Clean-AntreaNetwork.ps1 should be invoked with `-OVSRunMode "container"`. Fixes #5852 Signed-off-by: Antonin Bas --- hack/windows/Clean-AntreaNetwork.ps1 | 5 ++++- hack/windows/Prepare-AntreaAgent.ps1 | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hack/windows/Clean-AntreaNetwork.ps1 b/hack/windows/Clean-AntreaNetwork.ps1 index 191cea2b6f6..36a401801ee 100644 --- a/hack/windows/Clean-AntreaNetwork.ps1 +++ b/hack/windows/Clean-AntreaNetwork.ps1 @@ -10,7 +10,7 @@ Remove ovsdb-server and ovs-vswitchd services fom the host. The default value is $false. If this argument is set as true, this script would remove the two Windows services from the host. Otherwise, we consider that these services are supposed to be running on the host, so the script would try to recover them if their statuses are - not as expected. + not as expected. The parameter is ignored when OVSRunMode is "container". .PARAMETER OVSRunMode OVS run mode can be if OVS userspace processes were running inside a container in antrea-agent Pod or if OVS userspace processes were running as a Service on host. Default mode is . @@ -128,6 +128,9 @@ switch ($OVSRunMode) } } "container" { + # In container mode, OVS services run in containers, not as host services. + # We can remove host services if they exist. + RemoveOVSService if (Test-Path -Path $OVS_DB_PATH) { Remove-Item -Path $OVS_DB_PATH -Force } diff --git a/hack/windows/Prepare-AntreaAgent.ps1 b/hack/windows/Prepare-AntreaAgent.ps1 index baf9d716eed..78eca1ff5fc 100644 --- a/hack/windows/Prepare-AntreaAgent.ps1 +++ b/hack/windows/Prepare-AntreaAgent.ps1 @@ -32,8 +32,12 @@ if ($AntreaHnsNetwork) { } } if ($NeedCleanNetwork) { + $ovsRunMode = "service" + if ($RunOVSServices -eq $false) { + $ovsRunMode = "container" + } Write-Host "Cleaning stale Antrea network resources if they exist..." - & $CleanAntreaNetworkScript + & $CleanAntreaNetworkScript -OVSRunMode $ovsRunMode } # Enure OVS services are running. if ($RunOVSServices -eq $true) {