Fix issue when timeout and state=present (#43464)
* Fix issue when timeout and state=present * added changelog fragment
This commit is contained in:
parent
86f96d0212
commit
f588b1cdf9
2 changed files with 8 additions and 6 deletions
2
changelogs/fragments/win_wait_for-timeout.yaml
Normal file
2
changelogs/fragments/win_wait_for-timeout.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- win_wait_for - fix issue where timeout doesn't wait unless state=drained - https://github.com/ansible/ansible/issues/43446
|
|
@ -36,7 +36,7 @@ if ($path -ne $null) {
|
|||
if ($state -in @("stopped","drained")) {
|
||||
Fail-Json $result "state=$state should only be used for checking a port in the win_wait_for module"
|
||||
}
|
||||
|
||||
|
||||
if ($exclude_hosts -ne $null) {
|
||||
Fail-Json $result "exclude_hosts should only be used when checking a port and state=drained in the win_wait_for module"
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ Function Get-PortConnections($hostname, $port) {
|
|||
} else {
|
||||
$active_connections = $conn_info.GetActiveTcpConnections() | Where-Object { $_.LocalEndPoint.Address -eq $hostname -and $_.LocalEndPoint.Port -eq $port }
|
||||
}
|
||||
|
||||
|
||||
if ($active_connections -ne $null) {
|
||||
foreach ($active_connection in $active_connections) {
|
||||
$connections += $active_connection.RemoteEndPoint.Address
|
||||
|
@ -101,7 +101,7 @@ if ($delay -ne $null) {
|
|||
}
|
||||
|
||||
$attempts = 0
|
||||
if ($path -eq $null -and $port -eq $null -and $state -eq "drained") {
|
||||
if ($path -eq $null -and $port -eq $null -and $state -ne "drained") {
|
||||
Start-Sleep -Seconds $timeout
|
||||
} elseif ($path -ne $null) {
|
||||
if ($state -in @("present", "started")) {
|
||||
|
@ -133,7 +133,7 @@ if ($path -eq $null -and $port -eq $null -and $state -eq "drained") {
|
|||
Fail-Json $result "timeout while waiting for file $path to be present"
|
||||
} else {
|
||||
Fail-Json $result "timeout while waiting for string regex $search_regex in file $path to match"
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($state -in @("absent")) {
|
||||
# check if the file is deleted or string doesn't exist in file
|
||||
|
@ -165,7 +165,7 @@ if ($path -eq $null -and $port -eq $null -and $state -eq "drained") {
|
|||
Fail-Json $result "timeout while waiting for file $path to be absent"
|
||||
} else {
|
||||
Fail-Json $result "timeout while waiting for string regex $search_regex in file $path to not match"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($port -ne $null) {
|
||||
|
@ -252,7 +252,7 @@ if ($path -eq $null -and $port -eq $null -and $state -eq "drained") {
|
|||
$result.elapsed = $elapsed_seconds
|
||||
Fail-Json $result "timeout while waiting for $($hostname):$port to drain"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result.wait_attempts = $attempts
|
||||
|
|
Loading…
Reference in a new issue