Skip to content

Commit

Permalink
Add flag to calico windows uninstall script and pass it from hostproc…
Browse files Browse the repository at this point in the history
…ess install

The calico windows uninstall script would not run fully when it detects
it is running in a hostprocess container, but it is called by the
hostprocess installation to clean up a previous manual install, so
it needs to run fully in this special case. Fixing it by adding a flag
to indicate this situation.
  • Loading branch information
coutinhop committed Nov 7, 2022
1 parent 99109ab commit a3a36eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions node/windows-packaging/CalicoWindows/uninstall-calico.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.
param
(
[bool][parameter(Mandatory=$false)]$ExceptUpgradeService = $false
[bool][parameter(Mandatory=$false)]$ExceptUpgradeService = $false,
[bool][parameter(Mandatory=$false)]$CleanupForHostProcessInstall = $false
)

ipmo "$PSScriptRoot\libs\calico\calico.psm1" -Force
Expand All @@ -25,8 +26,10 @@ Test-CalicoConfiguration
$ErrorActionPreference = 'SilentlyContinue'

# If running in a hostprocess container, remove Calico CNI if installed.
# Skip the rest of the logic that applies to manual installations only.
if (($env:CONTAINER_SANDBOX_MOUNT_POINT) -and ($env:CALICO_NETWORKING_BACKEND -NE "none"))
# Skip the rest of the logic that applies to manual installations only,
# unless this is being run by the hostprocess installation itself (which
# will pass the -CleanupForHostProcessInstall param).
if (($env:CONTAINER_SANDBOX_MOUNT_POINT) -and ($env:CALICO_NETWORKING_BACKEND -NE "none") -and (-Not $CleanupForHostProcessInstall))
{
if ($env:CALICO_NETWORKING_BACKEND -NE "none") {
Remove-CNIPlugin
Expand Down
2 changes: 1 addition & 1 deletion node/windows-packaging/host-process-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $rootDir = "c:\CalicoWindows"
Write-Host "Uninstalling any existing Calico install before proceeding with installation..."
if ((Get-Service | where Name -Like 'Calico*') -NE $null) {
Write-Host "Calico services running. Executing $rootDir\uninstall-calico.ps1..."
& "$rootDir\uninstall-calico.ps1"
& "$rootDir\uninstall-calico.ps1" -CleanupForHostProcessInstall $true
}
# If this is a hostprocess install, and the root install dir exists, try
# removing any Calico CNI config install
Expand Down

0 comments on commit a3a36eb

Please sign in to comment.