Trying to configure a PreStop Hook which should run a script in a windows container. Observed that the prestop hook is not executing the script in OpenShift Windows Container. This is a Powershell script which moves logs to volume
Tried specifying basic hello world to the console, that is also not working.
Tried increasing terminationGracePeriodSeconds
to 1001
, had no luck with that approach.
My YAML file has a Prestop hook (see below), wonder if a Windows Container in OpenShift has any limitations with PreStop Hook processes?
lifecycle:
preStop:
exec:
command:
- 'C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe'
- '-File'
- 'C:\pathtoscriptinrepo\appscript.ps1'
I tried several ways by specifying cmd
also but it does not work.
Below is the Powershell script that is executed:
$sourcePath ="C:/somefolder/logs"
$destinationPath = "C:/Data/appname/PROD "
# Get all .log files in the source folder
$files = Get-ChildItem -Path $sourcePath -Filter "*.log"
# Move each .log file to the destination folder
foreach ($file in $files) {
$destination = Join-Path -Path $destinationPath -ChildPath $file.Name
Move-Item -Path $file.FullName -Destination $destination
Write-Host "Moved file: $($file.Name)"
}
Found that the moving of files to a volume using a Popwershell script in PreStop is not working. Any ideas or solutions ?
The service account for the Persistent Volume Claim has Full permissions