projectcalico / calico

Cloud native networking and network security
https://docs.tigera.io/calico/latest/about/
Apache License 2.0
5.99k stars 1.33k forks source link

Nssm pathing failing because of errant \..\.. #6906

Closed benjamin-baxter closed 2 years ago

benjamin-baxter commented 2 years ago

Since the v3.24.3 release I get a terminating PowerShell error during the run of install-calico-windows.ps1. I believe this is beacuse in C:\CalicoWindows\libs\calico\calico.psm1(installed location) module at line 17 sets $baseDir = "$PSScriptRoot...." which adds a string literal \..\.. to which no directory exists. I also noticed in the package the Nssm folder is a subversion label too "nssm-2.24-103-gdee49fc" not sure if that is related?

Expected Behavior

Script runs without following error: & : The term 'C:\CalicoWindows\libs\calico\..\..\nssm-2.24\win64\nssm.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\CalicoWindows\libs\calico\calico.psm1:200 char:7 + & $NSSMPath install CalicoNode $powerShellPath + ~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\CalicoWindow...\win64\nssm.exe:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Current Behavior

Installation Fails because of the follow error: & : The term 'C:\CalicoWindows\libs\calico\..\..\nssm-2.24\win64\nssm.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\CalicoWindows\libs\calico\calico.psm1:200 char:7 + & $NSSMPath install CalicoNode $powerShellPath + ~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\CalicoWindow...\win64\nssm.exe:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Possible Solution

Change $baseDir = "$PSScriptRoot\..\.." to $baseDir = "$PSScriptRoot" on line 17 of calico.psm1 so that line 18 $NSSMPath = "$baseDir\nssm-2.24\win64\nssm.exe" Will resolve correctly at line 200 & $NSSMPath install CalicoNode $powerShellPath

Steps to Reproduce (for bugs)

  1. Run install-calico-windows.ps1
  2. See it fail
  3. ?
  4. Foosball!

Context

Kinda bummed me out. Especially so close to 1.21 being deprecated. We were really close friends.

Love to chat with you folks sometime. Was chatting with your in house recruiter last bug and they never got back to me,

Your Environment

benjamin-baxter commented 2 years ago

It was the nssm-2.24-103-gdee49fc folder being misnamed. You already caught it for 3.24.4 Thanks!

g3rzi commented 1 year ago

Fix was here: https://github.com/projectcalico/calico/pull/6916/commits/91198726379ef1a9f7185dec6a99819bed68b743

And here is the formal fix ticket #6915 . Add:

$nssmDir = Get-ChildItem $RootDir -filter "nssm*" -Directory
mv $nssmDir.fullname $RootDir\nssm-2.24

To the install-calico-windows.ps1 script in this block (rows 449-450 in 3.24.3):

Remove-Item $RootDir -Force  -Recurse -ErrorAction SilentlyContinue
Write-Host "Unzip Calico for Windows release..."
Expand-Archive -Force $CalicoZip c:\
# This is a temporary fix to make sure nssm binary is in the correct path.
<here>
ipmo -force $RootDir\libs\calico\calico.psm1
Akash2000-07 commented 11 months ago

Hi i am facing below error C:\k\install-calico-windows.ps1 : The term 'Get-HnsNetwork' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

please someone help on this